PATCH: Use __syscall_ulong_t in pselect.c
Paul Eggert
eggert@cs.ucla.edu
Thu May 17 21:36:00 GMT 2012
On 05/17/2012 01:50 PM, H.J. Lu wrote:
> + data.ss = (__syscall_ulong_t) (uintptr_t) sigmask;
Only one cast is needed here, so I'd replace this with:
data.ss = (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:
struct
{
- const sigset_t *ss;
- size_t ss_len;
+ __syscall_ptr_t ss;
+ __syscall_ulong_t ss_len;
} data;
and the code as follows:
- data.ss = sigmask;
+ data.ss = __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;
}
More information about the Libc-alpha
mailing list