diff options
64 files changed, 364 insertions, 292 deletions
@@ -1,3 +1,80 @@ +2015-08-21 H.J. Lu <hongjiu.lu@intel.com> + + * sysdeps/unix/sysdep.h (INLINE_SYSCALL_RETURN): New. + (INLINE_SYSCALL_ERROR_RETURN): Likewise. + * sysdeps/unix/sysv/linux/adjtime.c (ADJTIME): Use + INLINE_SYSCALL_RETURN and INLINE_SYSCALL_ERROR_RETURN. + * sysdeps/unix/sysv/linux/aio_sigqueue.c (__aio_sigqueue): + Likewise. + * sysdeps/unix/sysv/linux/dl-openat64.c (openat64): Likewise. + * sysdeps/unix/sysv/linux/eventfd.c (eventfd): Likewise. + * sysdeps/unix/sysv/linux/faccessat.c (faccessat): Likewise. + * sysdeps/unix/sysv/linux/fchmodat.c (fchmodat): Likewise. + * sysdeps/unix/sysv/linux/fcntl.c (do_fcntl): Likewise. + * sysdeps/unix/sysv/linux/fstatfs64.c (__fstatfs64): Likewise. + * sysdeps/unix/sysv/linux/ftruncate64.c (__ftruncate64): Likewise. + * sysdeps/unix/sysv/linux/futimens.c (futimens): Likewise. + * sysdeps/unix/sysv/linux/futimes.c (__futimes): Likewise. + * sysdeps/unix/sysv/linux/futimesat.c (futimesat): Likewise. + * sysdeps/unix/sysv/linux/fxstat.c (__fxstat): Likewise. + * sysdeps/unix/sysv/linux/fxstat64.c (___fxstat64): Likewise. + * sysdeps/unix/sysv/linux/fxstatat.c (__fxstatat): Likewise. + * sysdeps/unix/sysv/linux/fxstatat64.c (__fxstatat64): Likewise. + * sysdeps/unix/sysv/linux/gai_sigqueue.c (__gai_sigqueue): + Likewise. + * sysdeps/unix/sysv/linux/getpriority.c (__getpriority): Likewise. + * sysdeps/unix/sysv/linux/getrlimit64.c (__getrlimit64): Likewise. + * sysdeps/unix/sysv/linux/llseek.c (__llseek): Likewise. + * sysdeps/unix/sysv/linux/lutimes.c (lutimes): Likewise. + * sysdeps/unix/sysv/linux/lxstat.c (__lxstat): Likewise. + * sysdeps/unix/sysv/linux/lxstat64.c (___lxstat64): Likewise. + * sysdeps/unix/sysv/linux/mmap64.c (__mmap64): Likewise. + * sysdeps/unix/sysv/linux/mq_close.c (mq_close): Likewise. + * sysdeps/unix/sysv/linux/mq_open.c (__mq_open): Likewise. + * sysdeps/unix/sysv/linux/mq_unlink.c (mq_unlink): Likewise. + * sysdeps/unix/sysv/linux/msgget.c (msgget): Likewise. + * sysdeps/unix/sysv/linux/prlimit.c (prlimit): Likewise. + * sysdeps/unix/sysv/linux/pt-raise.c (raise): Likewise. + * sysdeps/unix/sysv/linux/raise.c (raise): Likewise. + * sysdeps/unix/sysv/linux/readahead.c (__readahead): Likewise. + * sysdeps/unix/sysv/linux/reboot.c (reboot): Likewise. + * sysdeps/unix/sysv/linux/semget.c (semget): Likewise. + * sysdeps/unix/sysv/linux/semop.c (semop): Likewise. + * sysdeps/unix/sysv/linux/semtimedop.c (semtimedop): Likewise. + * sysdeps/unix/sysv/linux/setrlimit64.c (setrlimit64): Likewise. + * sysdeps/unix/sysv/linux/shmat.c (shmat): Likewise. + * sysdeps/unix/sysv/linux/shmdt.c (shmdt): Likewise. + * sysdeps/unix/sysv/linux/shmget.c (shmget): Likewise. + * sysdeps/unix/sysv/linux/signalfd.c (signalfd): Likewise. + * sysdeps/unix/sysv/linux/sigpending.c (sigpending): Likewise. + * sysdeps/unix/sysv/linux/sigprocmask.c ( __sigprocmask): Likewise. + * sysdeps/unix/sysv/linux/sigqueue.c (__sigqueue): Likewise. + * sysdeps/unix/sysv/linux/speed.c (cfsetospeed): Likewise. + * sysdeps/unix/sysv/linux/statfs64.c (__statfs64): Likewise. + * sysdeps/unix/sysv/linux/sysctl.c (__sysctl): Likewise. + * sysdeps/unix/sysv/linux/tcsendbrk.c (tcsendbreak): Likewise. + * sysdeps/unix/sysv/linux/tcsetattr.c (tcsetattr): Likewise. + * sysdeps/unix/sysv/linux/timer_getoverr.c (timer_getoverrun): + Likewise. + * sysdeps/unix/sysv/linux/timer_gettime.c (timer_gettime): + Likewise. + * sysdeps/unix/sysv/linux/timer_settime.c (timer_settime): + Likewise. + * sysdeps/unix/sysv/linux/truncate64.c (truncate64): Likewise. + * sysdeps/unix/sysv/linux/ustat.c (ustat): Likewise. + * sysdeps/unix/sysv/linux/utimensat.c (utimensat): Likewise. + * sysdeps/unix/sysv/linux/utimes.c (__utimes): Likewise. + * sysdeps/unix/sysv/linux/xmknod.c (__xmknod): Likewise. + * sysdeps/unix/sysv/linux/xmknodat.c (__xmknodat): Likewise. + * sysdeps/unix/sysv/linux/xstat.c (__xstat): Likewise. + * sysdeps/unix/sysv/linux/xstat64.c (___xstat64): Likewise. + * sysdeps/unix/sysv/linux/xstatconv.c (__xstat_conv): Likewise. + (__xstat64_conv): Likewise. + (__xstat32_conv): Likewise. + * sysdeps/unix/sysv/linux/sched_getaffinity.c + (__sched_getaffinity_new): Add libc_hidden_proto and + libc_hidden_def. Use INLINE_SYSCALL_ERROR_RETURN. + 2015-08-20 Joseph Myers <joseph@codesourcery.com> * timezone/Makefile (CFLAGS-zdump.c): Remove diff --git a/sysdeps/unix/sysdep.h b/sysdeps/unix/sysdep.h index 52dad582ce..c4316db4bc 100644 --- a/sysdeps/unix/sysdep.h +++ b/sysdeps/unix/sysdep.h @@ -73,3 +73,22 @@ #ifndef INLINE_SYSCALL #define INLINE_SYSCALL(name, nr, args...) __syscall_##name (args) #endif + +/* Similar to INLINE_SYSCALL, but with return type. It should only be + used with function return. */ +#ifndef INLINE_SYSCALL_RETURN +#define INLINE_SYSCALL_RETURN(name, nr, type, args...) \ + INLINE_SYSCALL (name, nr, args) +#endif + +/* Set error number and return value. It should only be used with + function return. ERR is the negative error number returned from + the majority of Linux kernels for which -ERR is no-op + with INTERNAL_SYSCALL_ERRNO. */ +#ifndef INLINE_SYSCALL_ERROR_RETURN +#define INLINE_SYSCALL_ERROR_RETURN(err, type, value) \ + ({ \ + __set_errno (-err); \ + (type) (value); \ + }) +#endif diff --git a/sysdeps/unix/sysv/linux/adjtime.c b/sysdeps/unix/sysv/linux/adjtime.c index b6fb7cf5db..ad54cf8ff8 100644 --- a/sysdeps/unix/sysv/linux/adjtime.c +++ b/sysdeps/unix/sysv/linux/adjtime.c @@ -61,10 +61,7 @@ ADJTIME (const struct TIMEVAL *itv, struct TIMEVAL *otv) tmp.tv_sec = itv->tv_sec + itv->tv_usec / 1000000L; tmp.tv_usec = itv->tv_usec % 1000000L; if (tmp.tv_sec > MAX_SEC || tmp.tv_sec < MIN_SEC) - { - __set_errno (EINVAL); - return -1; - } + return INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1); tntx.offset = tmp.tv_usec + tmp.tv_sec * 1000000L; tntx.modes = ADJ_OFFSET_SINGLESHOT; } diff --git a/sysdeps/unix/sysv/linux/aio_sigqueue.c b/sysdeps/unix/sysv/linux/aio_sigqueue.c index 6a48e6251b..c56b94f911 100644 --- a/sysdeps/unix/sysv/linux/aio_sigqueue.c +++ b/sysdeps/unix/sysv/linux/aio_sigqueue.c @@ -47,7 +47,8 @@ __aio_sigqueue (sig, val, caller_pid) info.si_uid = getuid (); info.si_value = val; - return INLINE_SYSCALL (rt_sigqueueinfo, 3, info.si_pid, sig, &info); + return INLINE_SYSCALL_RETURN (rt_sigqueueinfo, 3, int, info.si_pid, + sig, &info); } #else # include <rt/aio_sigqueue.c> diff --git a/sysdeps/unix/sysv/linux/dl-openat64.c b/sysdeps/unix/sysv/linux/dl-openat64.c index 732097dd92..ffb13f3acb 100644 --- a/sysdeps/unix/sysv/linux/dl-openat64.c +++ b/sysdeps/unix/sysv/linux/dl-openat64.c @@ -31,9 +31,9 @@ openat64 (dfd, file, oflag) assert (!__OPEN_NEEDS_MODE (oflag)); #ifdef __NR_openat - return INLINE_SYSCALL (openat, 3, dfd, file, oflag | O_LARGEFILE); + return INLINE_SYSCALL_RETURN (openat, 3, int, dfd, file, + oflag | O_LARGEFILE); #else - __set_errno (ENOSYS); - return -1; + return INLINE_SYSCALL_ERROR_RETURN (-ENOSYS, int, -1); #endif } diff --git a/sysdeps/unix/sysv/linux/eventfd.c b/sysdeps/unix/sysv/linux/eventfd.c index d4ffb3cedc..1496a0e651 100644 --- a/sysdeps/unix/sysv/linux/eventfd.c +++ b/sysdeps/unix/sysv/linux/eventfd.c @@ -25,11 +25,14 @@ int eventfd (unsigned int count, int flags) { #ifdef __NR_eventfd2 - int res = INLINE_SYSCALL (eventfd2, 2, count, flags); # ifndef __ASSUME_EVENTFD2 - if (res != -1 || errno != ENOSYS) -# endif + INTERNAL_SYSCALL_DECL (err); + int res = INTERNAL_SYSCALL (eventfd2, err, 2, count, flags); + if (!__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (res, err)) + || INTERNAL_SYSCALL_ERRNO (res, err) != ENOSYS) return res; +# endif + return INLINE_SYSCALL_RETURN (eventfd2, 2, int, count, flags); #endif #ifndef __ASSUME_EVENTFD2 @@ -38,16 +41,12 @@ eventfd (unsigned int count, int flags) kernel (sys_indirect) before implementing setting flags like O_NONBLOCK etc. */ if (flags != 0) - { - __set_errno (EINVAL); - return -1; - } + return INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1) # ifdef __NR_eventfd - return INLINE_SYSCALL (eventfd, 1, count); + return INLINE_SYSCALL_RETURN (eventfd, 1, int, count) # else - __set_errno (ENOSYS); - return -1; + return INLINE_SYSCALL_ERROR_RETURN (-ENOSYS, int, -1) # endif #elif !defined __NR_eventfd2 # error "__ASSUME_EVENTFD2 defined but not __NR_eventfd2" diff --git a/sysdeps/unix/sysv/linux/faccessat.c b/sysdeps/unix/sysv/linux/faccessat.c |
