This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: PATCH: Use __syscall_ulong_t in pselect.c
- From: Paul Eggert <eggert at cs dot ucla dot edu>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: "H.J. Lu" <hongjiu dot lu at intel dot com>, GNU C Library <libc-alpha at sourceware dot org>
- Date: Thu, 17 May 2012 14:36:15 -0700
- Subject: Re: PATCH: Use __syscall_ulong_t in pselect.c
- References: <20120517122708.GA32109@intel.com> <20120517205040.GA9797@intel.com>
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;
}