This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: Use __syscall_ulong_t in pselect.c

On 05/17/2012 01:50 PM, H.J. Lu wrote:
> + = (__syscall_ulong_t) (uintptr_t) sigmask;

Only one cast is needed here, so I'd replace this with: = (uintptr_t) sigmask;

But more generally, it might be better to distinguish clearly
between values that are pointers and values that are not.
That is, change the struct as follows:

-    const sigset_t *ss;
-    size_t ss_len;
+    __syscall_ptr_t ss;
+    __syscall_ulong_t ss_len;
   } data;

and the code as follows:

- = sigmask;
+ = __to_syscall_ptr (sigmask);

with the following auxiliary definitions somewhere in a
private header.  This way, programs will be less likely
to confuse sycall pointers with syscall integers.  (This
proposal shouldn't affect the generated code; it's just
a static-type-checking / clarity thing.)

   typedef struct { __syscall_ulong_t a; } __syscall_ptr_t;

   static inline __syscall_ptr_t
   __to_syscall_ptr (void const *a)
     __syscall_ptr_t p;
     p.a = (uintptr_t) a;
     return p;

   static inline void *
   __from_syscall_ptr (__syscall_ptr_t p)
     uintptr_t a = p.a;
     return (void *) a;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]