This is the mail archive of the libc-alpha@sourceware.org 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 1/9][BZ 16892] Add linux-generic lowlevellock.h


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


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