bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH hurd 04/30] libports: add `ports_lookup_payload' and `ports_p


From: Samuel Thibault
Subject: Re: [PATCH hurd 04/30] libports: add `ports_lookup_payload' and `ports_payload_get_name'
Date: Tue, 2 Dec 2014 00:58:15 +0100
User-agent: Mutt/1.5.21+34 (58baf7c9f32f) (2010-12-30)

Justus Winter, le Thu 27 Nov 2014 14:18:44 +0100, a écrit :
> These two functions map payloads to objects and port names. The former
> can be used like `ports_lookup_port' to look up objects, the latter to
> map payloads to port names if the server function expects a
> `mach_port_t'.
> 
> * libports/ports.h: Add function ports_payload_get_name.
> * libports/lookup-payload.c: New file.
> * libports/ports.h (ports_lookup_payload): Add declaration.
> * libports/Makefile (SRCS): Add lookup-payload.c.

Ack.

> ---
>  libports/Makefile        |  2 +-
>  libports/extern-inline.c | 22 ++++++++++++++++++++
>  libports/ports.h         | 53 
> ++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 76 insertions(+), 1 deletion(-)
>  create mode 100644 libports/extern-inline.c
> 
> diff --git a/libports/Makefile b/libports/Makefile
> index 30da1c1..f49cb9f 100644
> --- a/libports/Makefile
> +++ b/libports/Makefile
> @@ -36,7 +36,7 @@ SRCS = create-bucket.c create-class.c \
>   interrupt-operation.c interrupt-on-notify.c interrupt-notified-rpcs.c \
>   dead-name.c create-port.c import-port.c default-uninhibitable-rpcs.c \
>   claim-right.c transfer-right.c create-port-noinstall.c create-internal.c \
> - interrupted.c
> + interrupted.c extern-inline.c
>  
>  installhdrs = ports.h
>  
> diff --git a/libports/extern-inline.c b/libports/extern-inline.c
> new file mode 100644
> index 0000000..fbc9e53
> --- /dev/null
> +++ b/libports/extern-inline.c
> @@ -0,0 +1,22 @@
> +/* Run time callable functions for extern inlines.
> +   Copyright (C) 2014 Free Software Foundation, Inc.
> +
> +   Written by Justus Winter <4winter@informatik.uni-hamburg.de>
> +
> +   This file is part of the GNU Hurd.
> +
> +   The GNU Hurd is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU General Public License as
> +   published by the Free Software Foundation; either version 2, or (at
> +   your option) any later version.
> +
> +   The GNU Hurd is distributed in the hope that it will be useful, but
> +   WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   General Public License for more details.
> +
> +   You should have received a copy of the GNU General Public License
> +   along with the GNU Hurd.  If not, see <http://www.gnu.org/licenses/>.  */
> +
> +#define PORTS_DEFINE_EI
> +#include "ports.h"
> diff --git a/libports/ports.h b/libports/ports.h
> index 652edb8..a625b47 100644
> --- a/libports/ports.h
> +++ b/libports/ports.h
> @@ -29,6 +29,12 @@
>  #include <pthread.h>
>  #include <refcount.h>
>  
> +#ifdef PORTS_DEFINE_EI
> +#define PORTS_EI
> +#else
> +#define PORTS_EI __extern_inline
> +#endif
> +
>  /* These are global values for common flags used in the various structures.
>     Not all of these are meaningful in all flag fields.  */
>  #define PORTS_INHIBITED              0x0100 /* block RPC's */
> @@ -234,6 +240,53 @@ mach_port_t ports_get_send_right (void *port);
>  void *ports_lookup_port (struct port_bucket *bucket,
>                        mach_port_t port, struct port_class *class);
>  
> +/* Like ports_lookup_port, but uses PAYLOAD to look up the object.  If
> +   this function is used, PAYLOAD must be a pointer to the port
> +   structure.  */
> +extern void *ports_lookup_payload (struct port_bucket *bucket,
> +                                unsigned long payload,
> +                                struct port_class *class);
> +
> +/* This returns the ports name.  This function can be used as
> +   intranpayload function turning payloads back into port names.  If
> +   this function is used, PAYLOAD must be a pointer to the port
> +   structure.  */
> +extern mach_port_t ports_payload_get_name (unsigned int payload);
> +
> +#if defined(__USE_EXTERN_INLINES) || defined(PORTS_DEFINE_EI)
> +
> +PORTS_EI void *
> +ports_lookup_payload (struct port_bucket *bucket,
> +                   unsigned long payload,
> +                   struct port_class *class)
> +{
> +  struct port_info *pi = (struct port_info *) payload;
> +
> +  if (pi && bucket && pi->bucket != bucket)
> +    pi = NULL;
> +
> +  if (pi && class && pi->class != class)
> +    pi = NULL;
> +
> +  if (pi)
> +    refcounts_unsafe_ref (&pi->refcounts, NULL);
> +
> +  return pi;
> +}
> +
> +PORTS_EI mach_port_t
> +ports_payload_get_name (unsigned int payload)
> +{
> +  struct port_info *pi = (struct port_info *) payload;
> +
> +  if (pi)
> +    return pi->port_right;
> +
> +  return MACH_PORT_NULL;
> +}
> +
> +#endif /* Use extern inlines.  */
> +
>  /* Allocate another reference to PORT. */
>  void ports_port_ref (void *port);
>  
> -- 
> 2.1.3
> 

-- 
Samuel
 > Quelqu'un aurait-il une solution pour réinitialiser un MBR
 Si tu veux qu'il soit complètement blanc (pas souhaitable, à mon avis) :
 dd if=/dev/zero of=/dev/hda bs=512 count=1 (sous Linux)
 -+- OT in Guide du linuxien (très) pervers - "Pour les K difficiles" -+-



reply via email to

[Prev in Thread] Current Thread [Next in Thread]