[PATCH 1/9][BZ 16892] Add linux-generic lowlevellock.h
Chris Metcalf
cmetcalf@tilera.com
Tue Jun 10 15:23:00 GMT 2014
On 6/9/2014 4:24 PM, Bernard Ogden wrote:
> +#define lll_futex_timed_wait(futexp, val, timespec, private) \
> + ({ \
> + INTERNAL_SYSCALL_DECL (__err); \
> + long int __ret; \
> + __ret = INTERNAL_SYSCALL (futex, __err, 4, (futexp), \
> + __lll_private_flag (FUTEX_WAIT, private), \
> + (val), (timespec)); \
> + if(INTERNAL_SYSCALL_ERROR_P (__ret, __err)) \
> + __ret = -(INTERNAL_SYSCALL_ERRNO (__ret, __err)); \
> + __ret; \
> + })
Style note: space after "if". And might as well use __glibc_unlikely().
Maybe use an abstraction like INLINE_FUTEX_SYSCALL to capture the INTERNAL_SYSCALL pieces, e.g.
#define INLINE_FUTEX_SYSCALL(name, nr, args...) \
({ \
INTERNAL_SYSCALL_DECL (__err); \
long int __ret = INTERNAL_SYSCALL (name, err, nr, args); \
if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (__ret, __err))) \
__ret = -(INTERNAL_SYSCALL_ERRNO (__ret, __err)); \
__ret; \
})
Then you could use that throughout, e.g. lll_futex_timed_wait() is just a #define for INLINE_FUTEX_SYSCALL(futex, 4, (futexp), __lll_private_flag (FUTEX_WAIT, private), (val), (timespec)) and all the rest of the mechanism stays in INLINE_FUTEX_SYSCALL().
Otherwise, not tested, but both his and the tile-specific changes look OK to me.
--
Chris Metcalf, Tilera Corp.
http://www.tilera.com
More information about the Libc-alpha
mailing list