summaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv/linux/fcntl.c
AgeCommit message (Collapse)Author
2018-01-01Update copyright dates with scripts/update-copyrights.Joseph Myers
* All files with FSF copyright notices: Update copyright dates using scripts/update-copyrights. * locale/programs/charmap-kw.h: Regenerated. * locale/programs/locfile-kw.h: Likewise.
2017-08-31Remove NO_CANCELLATION macroAdhemerval Zanella
The NO_CANCELLATION macro is used currently on generic headers to define non cancellable syscalls and on Linux fcntl to implement the non cancellable variation. Former should be single-handled by not-cancel.h header and former could be simplified build both cancellable and non cancellable for default objects and alias the non-cancellable to default one for rtld ones (since Linux already support cancellation as default). This patch thus removes the NO_CANCELLATION macro and its usage. The generic non cancellable fcntl is route to internal fcntl. Checked on x86_64-linux-gnu and i686-linux-gnu. Also checked with a build again major ABIs. * sysdeps/generic/not-cancel.h (NO_CANCELLATION): Remove macro. * sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h (NO_CANCELLATION): Likewise. * sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h (NO_CANCELLATION): Likewise. * sysdeps/unix/sysv/linux/arm/sysdep-cancel.h (NO_CANCELLATION): Likewise. * sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h (NO_CANCELLATION): Likewise. * sysdeps/unix/sysv/linux/i386/sysdep-cancel.h (NO_CANCELLATION): Likewise. * sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h (NO_CANCELLATION): Likewise. * sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h (NO_CANCELLATION): Likewise. * sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h (NO_CANCELLATION): Likewise. * sysdeps/unix/sysv/linux/mips/sysdep-cancel.h (NO_CANCELLATION): Likewise. * sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h (NO_CANCELLATION): Likewise. * sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h (NO_CANCELLATION): Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h (NO_CANCELLATION): Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h (NO_CANCELLATION): Likewise. * sysdeps/unix/sysv/linux/sh/sysdep-cancel.h (NO_CANCELLATION): Likewise * sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h (NO_CANCELLATION): Likewise. * sysdeps/unix/sysv/linux/tile/sysdep-cancel.h (NO_CANCELLATION): Likewise. * sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h (NO_CANCELLATION): Likewise. * sysdeps/unix/sysv/linux/not-cancel.h (__fcntl_nocancel): Add hidden prototype. * sysdeps/unix/sysv/linux/fcntl.c (__fcntl_nocancel): Define only for !IS_IN (rtld) and remove NO_CANCELLATION usage.
2017-06-30Consolidate Linux fcntl implementationAdhemerval Zanella
This patch consolidates the fcntl Linux syscall generation on sysdeps/unix/sysv/linux/fcntl.c. It basically removes all the architecture specific implementations. Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32, aarch64-linux-gnu, arm-linux-gnueabihf, and powerpc64le-linux-gnu. * sysdeps/unix/sysv/linux/arm/fcntl.c: Remove file. * sysdeps/unix/sysv/linux/generic/wordsize-32/fcntl.c: Likewise. * sysdeps/unix/sysv/linux/hppa/fcntl.c: Likewise. * sysdeps/unix/sysv/linux/i386/fcntl.c: Likewise. * sysdeps/unix/sysv/linux/m68k/fcntl.c: Likewise. * sysdeps/unix/sysv/linux/microblaze/fcntl.c: Likewise. * sysdeps/unix/sysv/linux/mips/mips32/fcntl.c: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n32/fcntl.c: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/fcntl.c: Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/fcntl.c: Likewise. * sysdeps/unix/sysv/linux/sh/fcntl.c: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/fcntl.c: Likewise. * sysdeps/unix/sysv/linux/fcntl.c: New file. * sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c: Refactor to use default implementation.
2017-01-01Update copyright dates with scripts/update-copyrights.Joseph Myers
2016-01-04Update copyright dates with scripts/update-copyrights.Joseph Myers
2015-10-13Use INLINE_SYSCALL_ERROR_RETURN_VALUEH.J. Lu
This patch replaces { __set_errno (ERRNO); return -1; } with INLINE_SYSCALL_ERROR_RETURN_VALUE (ERRNO). * sysdeps/unix/sysv/linux/adjtime.c (ADJTIME): Use INLINE_SYSCALL_ERROR_RETURN_VALUE. * 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/futimens.c (futimens): Likewise. * sysdeps/unix/sysv/linux/futimes.c (__futimes): Likewise. * sysdeps/unix/sysv/linux/fxstat.c (__fxstat): Likewise. * sysdeps/unix/sysv/linux/fxstatat.c (__fxstatat): Likewise. * sysdeps/unix/sysv/linux/fxstatat64.c (__fxstatat64): 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_open.c (__mq_open): Likewise. * sysdeps/unix/sysv/linux/mq_unlink.c (mq_unlink): Likewise. * sysdeps/unix/sysv/linux/prlimit.c (prlimit): Likewise. * sysdeps/unix/sysv/linux/readahead.c (__readahead): Likewise. * sysdeps/unix/sysv/linux/shmat.c (shmat): Likewise. * sysdeps/unix/sysv/linux/signalfd.c (signalfd): Likewise. * sysdeps/unix/sysv/linux/speed.c (cfsetospeed): Likewise. * sysdeps/unix/sysv/linux/tcsetattr.c (tcsetattr): Likewise. * sysdeps/unix/sysv/linux/ustat.c (ustat): Likewise. * sysdeps/unix/sysv/linux/utimensat.c (utimensat): 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/xstatconv.c (__xstat_conv): Likewise. (__xstat64_conv): Likewise. (__xstat32_conv): Likewise.
2015-08-21Revert "Add INLINE_SYSCALL_RETURN/INLINE_SYSCALL_ERROR_RETURN"H.J. Lu
This reverts commit 0c5b8b5941e036dcaac69cecee9f01fdf9218e6e.
2015-08-21Add INLINE_SYSCALL_RETURN/INLINE_SYSCALL_ERROR_RETURNH.J. Lu
For ia32 PIC, the first thing of many syscalls does is to call __x86.get_pc_thunk.reg to load PC into reg in case there is an error, which is required for setting errno. In most cases, there are no errors. But we still call __x86.get_pc_thunk.reg. This patch adds INLINE_SYSCALL_RETURN and INLINE_SYSCALL_ERROR_RETURN so that i386 can optimize setting errno by branching to the internal __syscall_error without PLT. INLINE_SYSCALL_ERROR_RETURN is designed to take the negative error number returned from the majority of Linux kernels for which negating is a no-op with INTERNAL_SYSCALL_ERRNO. With i386 INLINE_SYSCALL_RETURN, INLINE_SYSCALL_ERROR_RETURN and i386 syscall inlining optimization for GCC 5, for sysdeps/unix/sysv/linux/fchmodat.c with -O2 -march=i686 -mtune=generic, GCC 5.2 now generates: <fchmodat>: 0: push %ebx 1: mov 0x14(%esp),%eax 5: mov 0x8(%esp),%ebx 9: mov 0xc(%esp),%ecx d: mov 0x10(%esp),%edx 11: test $0xfffffeff,%eax 16: jne 38 <fchmodat+0x38> 18: test $0x1,%ah 1b: jne 48 <fchmodat+0x48> 1d: mov $0x132,%eax 22: call *%gs:0x10 29: cmp $0xfffff000,%eax 2e: ja 58 <fchmodat+0x58> 30: pop %ebx 31: ret 32: lea 0x0(%esi),%esi 38: pop %ebx 39: mov $0xffffffea,%eax 3e: jmp 3f <fchmodat+0x3f> 3f: R_386_PC32 __syscall_error 43: nop 44: lea 0x0(%esi,%eiz,1),%esi 48: pop %ebx 49: mov $0xffffffa1,%eax 4e: jmp 4f <fchmodat+0x4f> 4f: R_386_PC32 __syscall_error 53: nop 54: lea 0x0(%esi,%eiz,1),%esi 58: pop %ebx 59: jmp 5a <fchmodat+0x5a> 5a: R_386_PC32 __syscall_error instead of <fchmodat>: 0: sub $0x8,%esp 3: mov 0x18(%esp),%eax 7: mov %ebx,(%esp) a: call b <fchmodat+0xb> b: R_386_PC32 __x86.get_pc_thunk.bx f: add $0x2,%ebx 11: R_386_GOTPC _GLOBAL_OFFSET_TABLE_ 15: mov %edi,0x4(%esp) 19: test $0xfffffeff,%eax 1e: jne 70 <fchmodat+0x70> 20: test $0x1,%ah 23: jne 88 <fchmodat+0x88> 25: mov 0x14(%esp),%edx 29: mov 0x10(%esp),%ecx 2d: mov 0xc(%esp),%edi 31: xchg %ebx,%edi 33: mov $0x132,%eax 38: call *%gs:0x10 3f: xchg %edi,%ebx 41: cmp $0xfffff000,%eax 46: ja 58 <fchmodat+0x58> 48: mov (%esp),%ebx 4b: mov 0x4(%esp),%edi 4f: add $0x8,%esp 52: ret 53: nop 54: lea 0x0(%esi,%eiz,1),%esi 58: mov 0x0(%ebx),%edx 5a: R_386_TLS_GOTIE __libc_errno 5e: neg %eax 60: mov %eax,%gs:(%edx) 63: mov $0xffffffff,%eax 68: jmp 48 <fchmodat+0x48> 6a: lea 0x0(%esi),%esi 70: mov 0x0(%ebx),%eax 72: R_386_TLS_GOTIE __libc_errno 76: movl $0x16,%gs:(%eax) 7d: mov $0xffffffff,%eax 82: jmp 48 <fchmodat+0x48> 84: lea 0x0(%esi,%eiz,1),%esi 88: mov 0x0(%ebx),%eax 8a: R_386_TLS_GOTIE __libc_errno 8e: movl $0x5f,%gs:(%eax) 95: mov $0xffffffff,%eax 9a: jmp 48 <fchmodat+0x48> * 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-01-02Update copyright dates with scripts/update-copyrights.Joseph Myers
2014-06-20Remove __ASSUME_F_GETOWN_EX.Joseph Myers
This patch removes __ASSUME_F_GETOWN_EX now it can be assumed to be true unconditionally. Tested x86_64 that disassembly of installed shared libraries is unchanged by this patch. * sysdeps/unix/sysv/linux/kernel-features.h (__ASSUME_F_GETOWN_EX): Remove macro. * sysdeps/unix/sysv/linux/fcntl.c: Do not include <kernel-features.h>. (miss_F_GETOWN_EX): Remove variable or macro. (do_fcntl): Do not check miss_F_GETOWN_EX. (do_fcntl) [!__ASSUME_F_GETOWN_EX]: Remove conditional code.
2014-01-01Update copyright notices with scripts/update-copyrightsAllan McRae
2013-01-02Update copyright notices with scripts/update-copyrights.Joseph Myers
2012-02-09Replace FSF snail mail address with URLs.Paul Eggert
2009-10-29Fix F_GETOWN on some Linux archs.Ulrich Drepper
The syscall conventions on some Linux archs prevented F_GETOWN from working correctly in some situations. This can be rectified when using the new F_GETOWN_EX command.
2004-07-16Update.Ulrich Drepper
* sysdeps/unix/sysv/linux/fcntl.c (__fcntl_nocancel): Remove static inline __attribute ((always_inline)). Don't define if NO_CANCELLATION. (__libc_fcntl): Use INLINE_SYSCALL directly instead of __fcntl_nocancel. * sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c (__fcntl_nocancel): Remove static inline __attribute ((always_inline)). Don't define if NO_CANCELLATION. (__libc_fcntl): Use INLINE_SYSCALL directly instead of __fcntl_nocancel. * sysdeps/unix/sysv/linux/i386/fcntl.c (__fcntl_nocancel): Define to __libc_fcntl if NO_CANCELLATION and __ASSUME_FCNTL64 == 0. Don't define at all if NO_CANCELLATION and __ASSUME_FCNTL64 > 0. (__libc_fcntl): Don't define if __fcntl_nocancel is a macro.
2004-07-09Update.Ulrich Drepper
2004-07-09 Ulrich Drepper <drepper@redhat.com> * sysdeps/unix/sysv/linux/fcntl.c (__fcntl_nocancel): Move attribute to the front for gcc 3.5+. * sysdeps/unix/sysv/linux/i386/fcntl.c: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c: Likewise. * include/fcntl.h: Don't declare __fcntl_nocancel here if NO_CANCELLATION is defined.
2004-07-06Update.Ulrich Drepper
2004-07-05 Ulrich Drepper <drepper@redhat.com> * elf/dl-init.c: Don't define and use _dl_starting_up if HAVE_INLINED_SYSCALLS is defined and the variable is not used. * elf/dl-support.c: Likewise. * elf/rtld.c: Likewise. * elf/dl-misc.c (_dl_debug_vdprintf): Use writev syscall directly if HAVE_INLINED_SYSCALLS is defined. * sysdeps/powerpc/powerpc64/dl-machine.h: Don't rest _dl_starting_up here. * sysdeps/powerpc/powerpc32/dl-start.S: Likewise. * sysdeps/unix/sysv/linux/configure.in: Define HAVE_INLINED_SYSCALLS. * config.h.in: Add entry for HAVE_INLINED_SYSCALLS. * sysdeps/posix/profil.c: If compiled for ld.so, omit code which is needed to stop profiling. * elf/dl-open.c (dl_open_worker): If a newly opened object is to be profile make sure it cannot be unloaded. * sysdeps/unix/sysv/linux/dl-origin.c: Inline readlink syscall. * sysdeps/unix/sysv/linux/fcntl.c: If compiled without cancellation support, make sure the helper function is inlined. * sysdeps/unix/sysv/linux/pread.c: Likewise. * sysdeps/unix/sysv/linux/pwrite.c: Likewise. * sysdeps/unix/sysv/linux/i386/fcntl.c: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c: Likewise.
2003-09-05Update.Andreas Jaeger
* sysdeps/unix/sysv/linux/fcntl.c (__fcntl_nocancel): Likewise.
2003-09-04Update.Ulrich Drepper
* sysdeps/generic/utmp_file.c: Use not-cancelable syscalls all over the place. It would be allowed to have these fucntions as cancellation points but the cleanup would be ugly and a lot of work. * sysdeps/generic/not-cancel.h (fcntl_not_cancel): Define. * sysdeps/unix/sysv/linux/not-cancel.h (fcntl_not_cancel): Define. * include/fcntl.h (__fcntl_nocancel): Declare. * sysdeps/unix/sysv/linux/fcntl.c: New file. * sysdeps/unix/sysv/linux/i386/fcntl.c (__libc_fcntl): Only enable cancellation if absolutely needed. (__fcntl_nocancel): Define. * posix/unistd.h (gethostid): Remove __THROW. Clarify comment. * sysdeps/unix/sysv/linux/Makefile (CFLAGS-gethostid.c): Add -fexceptions. * sysdeps/unix/sysv/linux/gethostid.c (gethostid): Use extend_alloca. * resolv/res_init.c (__res_nclose): Use close_not_cancel_no_status instead of __close.