about summary refs log tree commit diff
path: root/sysdeps
Commit message (Collapse)AuthorAgeFilesLines
...
* Use clock_gettime to implement timespec_get.Zack Weinberg2019-10-302-78/+0
| | | | | | | | | | | | | | | | | | | | | timespec_get is the same function as clock_gettime, with an obnoxious coating of NIH painted on it by the ISO C committee. In addition to the rename, it takes its arguments in a different order, it returns 0 on *failure* or a positive number on *success*, and it requires that all of its TIME_* constants be positive. This last means we cannot directly reuse the existing CLOCK_* constants for it, because those have been allocated starting with CLOCK_REALTIME = 0 on all existing platforms. This patch simply promotes the sysdeps/posix implementation to universal, and removes the Linux-specific implementation, whose apparent reason for existing was to cut out one function call's worth of overhead. Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu, powerpc64-linux-gnu, powerpc-linux-gnu, and aarch64-linux-gnu. Reviewed-by: Lukasz Majewski <lukma@denx.de>
* Consolidate and deprecate ftimeZack Weinberg2019-10-302-43/+0
| | | | | | | | | | | | | | | | | | | | | | | | | ftime is an obsolete variation on gettimeofday, offering only millisecond time resolution; it was probably a system call in ooold versions of BSD Unix. For historic reasons, we had three implementations of it. These are all consolidated into time/ftime.c, and then the function is deprecated. For some reason, the implementation of ftime in terms of gettimeofday was rounding rather than truncating microseconds to milliseconds. In all the other places where we use a higher-resolution time function to implement a lower-resolution one, we truncate. ftime is changed to match, just for tidiness' sake. Like gettimeofday, ftime tries to report the time zone, and using that information is always a bug. This patch dummies out the reported timezone information; the timezone and dstflag fields of the returned "struct timeb" will always be zero. Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu, powerpc64-linux-gnu, and powerpc-linux-gnu. Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Reviewed-by: Lukasz Majewski <lukma@denx.de>
* Change most internal uses of time to __clock_gettime.Adhemerval Zanella2019-10-307-112/+35
| | | | | | | | | | | | | | | | | As for gettimeofday, time will be implemented based on clock_gettime on all platforms and internal code should use clock_gettime directly. In addition to removing a layer of indirection, this will allow us to remove the PLT-bypass gunk for gettimeofday. The changed code always assumes __clock_gettime (CLOCK_REALTIME) or __clock_gettime (CLOCK_REALTIME_COARSE) (for Linux case) cannot fail, using the same rationale for gettimeofday change. And internal helper was added (time_now). Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu, powerpc64-linux-gnu, and powerpc-linux-gnu. Reviewed-by: Lukasz Majewski <lukma@denx.de>
* Use clock_gettime to implement time.Adhemerval Zanella2019-10-303-50/+11
| | | | | | | | | | | | | | | | | Change the default implementation of time to call clock_gettime, to align with new Linux ports that are expected to only implement __NR_clock_gettime. Arch-specific implementation that either call the time vDSO or route to gettimeofday vDSO are not removed. Also for Linux, CLOCK_REALTIME_COARSE is used instead of generic CLOCK_REALTIME clockid. This takes less CPU time and its behavior better matches what the current glibc does. Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu, powerpc64-linux-gnu, powerpc-linux-gnu, and aarch64-linux-gnu. Co-authored-by: Zack Weinberg <zackw@panix.com> Reviewed-by: Lukasz Majewski <lukma@denx.de>
* Use clock_settime to implement settimeofday.Zack Weinberg2019-10-308-85/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unconditionally, on all ports, use clock_settime to implement settimeofday. Remove sysdeps/unix/clock_settime.c, which implemented clock_settime by calling settimeofday; new OS ports must henceforth provide a real implementation of clock_settime. Hurd had a real implementation of settimeofday but not of clock_settime; this patch converts it into an implementation of clock_settime. It only supports CLOCK_REALTIME and microsecond resolution; Hurd/Mach does not appear to have any support for finer-resolution clocks. The vestigial "set time zone" feature of settimeofday complicates the generic settimeofday implementation a little. The only remaining uses of this feature that aren't just bugs, are using it to inform the Linux kernel of the offset between the hardware clock and UTC, on systems where the hardware clock doesn't run in UTC (usually because of dual-booting with Windows). There currently isn't any other way to do this. However, the callers that do this call settimeofday with _only_ the timezone argument non-NULL. Therefore, glibc's new behavior is: callers of settimeofday must supply one and only one of the two arguments. If both arguments are non-NULL, or both arguments are NULL, the call fails and sets errno to EINVAL. When only the timeval argument is supplied, settimeofday calls __clock_settime(CLOCK_REALTIME), same as stime. When only the timezone argument is supplied, settimeofday calls a new internal function called __settimezone. On Linux, only, this function will pass the timezone structure to the settimeofday system call. On all other operating systems, and on Linux architectures that don't define __NR_settimeofday, __settimezone is a stub that always sets errno to ENOSYS and returns -1. The settimeoday syscall is enabled on Linux by the flag COMPAT_32BIT_TIME, which is an option to either 32-bits ABIs or COMPAT builds (defined usually by 64-bit kernels that want to support 32-bit ABIs, such as x86). The idea to future 64-bit time_t only ABIs is to not provide settimeofday syscall. The same semantics are implemented for Linux/Alpha's GLIBC_2.0 compat symbol for settimeofday. There are no longer any internal callers of __settimeofday, so the internal prototype is removed. Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu, powerpc64-linux-gnu, powerpc-linux-gnu, and aarch64-linux-gnu. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Reviewed-by: Lukasz Majewski <lukma@denx.de>
* Use clock_settime to implement stime; withdraw stime.Zack Weinberg2019-10-302-40/+0
| | | | | | | | | | | | Unconditionally, on all ports, use clock_settime to implement stime, not settimeofday or a direct syscall. Then convert stime into a compatibility symbol and remove its prototype from time.h. Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu, powerpc64-linux-gnu, powerpc-linux-gnu, and aarch64-linux-gnu. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Reviewed-by: Lukasz Majewski <lukma@denx.de>
* Change most internal uses of __gettimeofday to __clock_gettime.Zack Weinberg2019-10-3011-61/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since gettimeofday will shortly be implemented in terms of clock_gettime on all platforms, internal code should use clock_gettime directly; in addition to removing a layer of indirection, this will allow us to remove the PLT-bypass gunk for gettimeofday. (We can't quite do that yet, but it'll be coming later in this patch series.) In many cases, the changed code does fewer conversions. The changed code always assumes __clock_gettime (CLOCK_REALTIME) cannot fail. Most of the call sites were assuming gettimeofday could not fail, but a few places were checking for errors. POSIX says clock_gettime can only fail if the clock constant is invalid or unsupported, and CLOCK_REALTIME is the one and only clock constant that's required to be supported. For consistency I grepped the entire source tree for any other places that checked for errors from __clock_gettime (CLOCK_REALTIME), found one, and changed it too. (For the record, POSIX also says gettimeofday can never fail.) (It would be nice if we could declare that GNU systems will always support CLOCK_MONOTONIC as well as CLOCK_REALTIME; there are several places where we are using CLOCK_REALTIME where _MONOTONIC would be more appropriate, and/or trying to use _MONOTONIC and then falling back to _REALTIME. But the Hurd doesn't support CLOCK_MONOTONIC yet, and it looks like adding it would involve substantial changes to gnumach's internals and API. Oh well.) A few Hurd-specific files were changed to use __host_get_time instead of __clock_gettime, as this seemed tidier. We also assume this cannot fail. Skimming the code in gnumach leads me to believe the only way it could fail is if __mach_host_self also failed, and our Hurd-specific code consistently assumes that can't happen, so I'm going with that. With the exception of support/support_test_main.c, test cases are not modified, mainly because I didn't want to have to figure out which test cases were testing gettimeofday specifically. The definition of GETTIME in sysdeps/generic/memusage.h had a typo and was not reading tv_sec at all. I fixed this. It appears nobody has been generating malloc traces on a machine that doesn't have a superseding definition. There are a whole bunch of places where the code could be simplified by factoring out timespec subtraction and/or comparison logic, but I want to keep this patch as mechanical as possible. Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu, powerpc64-linux-gnu, powerpc-linux-gnu, and aarch64-linux-gnu. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Reviewed-by: Lukasz Majewski <lukma@denx.de>
* Linux/Alpha: don't use timeval32 system calls.Zack Weinberg2019-10-3018-131/+637
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Linux/Alpha has two versions of several system call wrappers that take or return data of type "struct timeval" (possibly nested inside a larger structure). The GLIBC_2.0 version is a compat symbol that calls __NR_osf_foo or __NR_old_foo and uses a struct timeval with a 32-bit tv_sec field. The GLIBC_2.1 version is used for current code, calls __NR_foo, and uses a struct timeval with a 64-bit tv_sec field. This patch changes all of the compat symbols of this type to be wrappers around their GLIBC_2.1 counterparts; the compatibility system calls will no longer be used. It serves as a proposal for part of how we do the transition to 64-bit time_t on systems that currently use 32-bit time_t: * The patched glibc will NOT use system calls that involve 32-bit time_t to implement its compatibility symbols. This will make both our lives and the kernel maintainers' lives easier. The primary argument I've seen against it is that the kernel could warn about uses of the old system calls, helping people find old binaries that need to be recompiled. I think there are several other ways we could accomplish this, e.g. scripts to scan the filesystem for binaries with references to the old symbol versions, or issuing diagnostics ourselves. * The compat symbols do NOT report failure after the Y2038 deadline. An earlier revision of this patch had them return -1 and set errno to EOVERFLOW, but Adhemerval pointed out that many of them have already performed side effects at the point where we discover the overflow, so that would break more than it fixes. Also, we don't want people to be _checking_ for EOVERFLOW from these functions; we want them to recompile with 64-bit time_t. So it's not actually useful for them to report failure to the calling code. * What they do do, when they encounter overflow, is saturate the overflowed "struct timeval"(s): tv_sec is set to INT32_MAX and tv_nsec is set to 999999. That means time stops advancing for programs with 32-bit time_t when they reach the deadline. That's obviously going to break stuff, but I think wrapping around is probably going to break _more_ stuff. I'd be interested to hear arguments against, if anyone has one. The new header file tv32-compat.h is currently Alpha-specific but I mean for it to be reused to aid in writing wrappers for all affected architectures. I only put it in sysdeps/unix/sysv/linux/alpha for now because I haven't checked whether the various "foo32" structures it defines agree with the ABI for ports other than Linux/Alpha. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* hurd: Support for file record lockingSvante Signell2019-10-301-24/+87
| | | | | | * sysdeps/mach/hurd/fcntl.c: Add support for file-record-lock RPC fixing posix file locking using the flock64 version of struct flock.
* y2038: linux: Provide __clock_getres64 implementationLukasz Majewski2019-10-271-3/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch provides new __clock_getres64 explicit 64 bit function for getting the resolution (precision) of specified clock ID. Moreover, a 32 bit version - __clock_getres has been refactored to internally use __clock_getres64. The __clock_getres is now supposed to be used on systems still supporting 32 bit time (__TIMESIZE != 64) - hence the necessary conversion from 64 bit struct __timespec64 to struct timespec. The new clock_getres_time64 syscall available from Linux 5.1+ has been used, when applicable. On systems which are not supporting clock_getres_time64 (as their clock_getres supports 64 bit time ABI) the vDSO syscall is attempted. On the contrary the non-vDSO syscall is used for clock_getres_time64 as up till now the kernel is not providing such interface. No additional checks (i.e. if tv_nsec value overflow) are performed on values returned via clock_getres{_time64} syscall, as it is assumed that the Linux kernel will either return 0 and provide correct value or error. The check for tv_sec being out of range on systems still supporting 32 bit time (__TIMESIZE != 64) without Y2038 time support is also omitted as it is _very_ unlikely that we would have a timer with resolution which exceeds 32 bit time_t range. Build tests: - The code has been tested on x86_64/x86 (native compilation): make PARALLELMFLAGS="-j8" && make xcheck PARALLELMFLAGS="-j8" - The glibc has been build tested (make PARALLELMFLAGS="-j8") for x86 (i386), x86_64-x32, and armv7 Run-time tests: - Run specific tests on ARM/x86 32bit systems (qemu): https://github.com/lmajewski/meta-y2038 and run tests: https://github.com/lmajewski/y2038-tests/commits/master - Use of cross-test-ssh.sh for ARM (armv7): make PARALLELMFLAGS="-j8" test-wrapper='./cross-test-ssh.sh root@192.168.7.2' xcheck Linux kernel, headers and minimal kernel version for glibc build test matrix: - Linux v5.1 (with clock_getres_time64) and glibc build with v5.1 as minimal kernel version (--enable-kernel="5.1.0") The __ASSUME_TIME64_SYSCALLS flag defined. - Linux v5.1 and default minimal kernel version The __ASSUME_TIME64_SYSCALLS not defined, but kernel supports clock_getres_time64 syscall. - Linux v4.19 (no clock_getres_time64 support) with default minimal kernel version for contemporary glibc This kernel doesn't support clock_getres_time64 syscall, so the fallback to clock_getres is tested. The above tests were performed with Y2038 redirection applied as well as without (so the __TIMESIZE != 64 execution path is checked as well). No regressions were observed.
* time: Introduce function to check correctness of nanoseconds valueLukasz Majewski2019-10-2712-17/+20
| | | | | | | | | | | | | | | The valid_nanoseconds () static inline function has been introduced to check if nanoseconds value is in the correct range - greater or equal to zero and less than 1000000000. The explicit #include <time.h> has been added to files where it was missing. The __syscall_slong_t type for ns has been used to avoid issues on x32. Tested with: - scripts/build-many-glibcs.py - make PARALLELMFLAGS="-j12" && make PARALLELMFLAGS="-j12" xcheck on x86_64
* Define __STATFS_MATCHES_STATFS64Alistair Francis2019-10-248-2/+32
| | | | | | | | Add a new macro __STATFS_MATCHES_STATFS64 that specifies if fsblkcnt_t matches fsblkcnt64_t and if fsfilcnt_t matches fsfilcnt64_t. As we don't have the padding we also need to update the overflow checker to not access the undefined members.
* hurd: Fix build after __pread64 usage in the dynamic loaderFlorian Weimer2019-10-241-3/+11
| | | | | | | | | | | Commit 95c1056962a3f2297c94ce47f0eaf0c5b6563231 ("elf: Use nocancel pread64() instead of lseek()+read()") added calls to __pread64 to the dynamic loader. On Hurd, this needs an implementation in the dynamic loader because the rtld-pread64 rebuild pulls in too many symbols. Fixes: 95c1056962a3f2297c94ce47f0eaf0c5b6563231 Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
* sysdeps/stat: Handle 64-bit ino_t types on 32-bit hostsAlistair Francis2019-10-234-2/+38
| | | | | | | On a 32-bit platform with a 64-bit ino_t type (__INO_T_MATCHES_INO64_T defined) we want to update the stat struct to remove the padding as it isn't required. As we don't have the padding we also need to update the overflow checker to not access the undefined members.
* S390: Remove not needed stack frame in syscall function.Stefan Liebler2019-10-232-44/+8
| | | | | | | | As an svc invocation does not clobber any user space registers despite of the return value r2 and it does not need a special stack frame. This patch gets rid of the extra frame. We just have to save and restore r6 and r7 as those are preserved across function calls.
* Remove x64 _finite tests and referencesWilco Dijkstra2019-10-2151-428/+57
| | | | | | | | | Remove _finite tests and references from x86_64. Rather than calling __exp_finite, use exp directly (since it's the same entry point). x86_64 builds and passes testsuite. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Remove math-finite.hWilco Dijkstra2019-10-211-24/+0
| | | | | | | | Remove math-finite.h redirections for math functions. Passes buildmanyglibc. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Include <kernel-features.h> explicitly in Linux clock_settime.cLukasz Majewski2019-10-201-0/+1
| | | | | | | | | | | The rewritten clock_settime code (which now supports 64 bit time on systems with __WORDSIZE == 32) for Linux now relies on the __ASSUME_TIME64_SYSCALLS flag set. Lets explicitly include the header file where it is defined to avoid any indirect inclusion (which may pose some unwanted API definitions). Tested with scripts/build-many-glibcs.py script.
* elf: Use nocancel pread64() instead of lseek()+read()Leandro Pereira2019-10-181-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Transforms this, when linking in a shared object: openat(AT_FDCWD, "/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3 read(3, "\177ELF\2\1\1\3"..., 832) = 832 lseek(3, 792, SEEK_SET) = 792 read(3, "\4\0\0\0\24\0\0\0"..., 68) = 68 fstat(3, {st_mode=S_IFREG|0755, st_size=6699224, ...}) = 0 lseek(3, 792, SEEK_SET) = 792 read(3, "\4\0\0\0\24\0\0\0"..., 68) = 68 lseek(3, 864, SEEK_SET) = 864 read(3, "\4\0\0\0\20\0\0\0"..., 32) = 32 Into this: openat(AT_FDCWD, "/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3 read(3, "\177ELF\2\1\1\3"..., 832) = 832 pread(3, "\4\0\0\0\24\0\0\0"..., 68, 792) = 68 fstat(3, {st_mode=S_IFREG|0755, st_size=6699224, ...}) = 0 pread(3, "\4\0\0\0\24\0\0\0"..., 68, 792) = 68 pread(3, "\4\0\0\0\20\0\0\0"..., 32, 864) = 32 Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* Add nocancel version of pread64()Leandro Pereira2019-10-185-2/+41
| | | | | | | This is in preparation for changes in the dynamic linker so that pread() is used instead of lseek()+read(). Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* Update sysvipc kernel-features.h files for Linux 5.1Adhemerval Zanella2019-10-1811-27/+57
| | | | | | | | | | | | | | | | | | | | | | | | Linux 5.1 adds missing SySV IPC syscalls to the syscall table for remanining one that still uses the ipc syscall on glibc (m68k, mips-o32, powerpc, s390, sh, and sparc32). However the newly added direct ipc syscall are different than the old ones: 1. They do not expect IPC_64, meaning __IPC_64 should be set to zero when new syscalls are used. And new syscalls can not be used for compat functions like __old_semctl (to emulated old sysvipc it requires to use the old __NR_ipc syscall without __IPC_64). Thus IPC_64 is redefined for newer kernels on affected ABIs. 2. semtimedop and semop does not exist on 32-bit ABIs (only semtimedop_time64 is supplied). The provided syscall wrappers only uses the wire-up syscall if __NR_semtimedop and __NR_semop are also defined. Checked on x86_64-linux-gnu and i686-linux-gnu on both a 4.15 kernel configure with default options and sysvipc tests on a 5.3.0 kernel with --enable-kernel=5.1. Tested-by: Paul A. Clarke <pc@us.ibm.com>
* S390: Add new s390 platform z15.Stefan Liebler2019-10-182-3/+3
| | | | | The new IBM z15 is added to platform string array. The macro _DL_PLATFORMS_COUNT is incremented.
* nptl: SIGCANCEL, SIGTIMER, SIGSETXID are always definedFlorian Weimer2019-10-182-78/+5
| | | | | | | | | | | All nptl targets have these signal definitions nowadays. This changes also replaces the nptl-generic version of pthread_sigmask with the Linux version. Tested on x86_64-linux-gnu and i686-linux-gnu. Built with build-many-glibcs.py. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* sysvipc: Implement semop based on semtimedopAdhemerval Zanella2019-10-172-7/+4
| | | | | | | | | | | | | | Besides semop being a subset of semtimedop, new 32-bit architectures on Linux are not expected to provide the syscall (only the 64-bit time semtimedop). Also, Linux 5.1 only wired-up semtimedop for the 64-bit architectures that missed it (powerpc, s390, and sparc). This simplifies the code to support it. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* ipc: Refactor sysvipc internal definitionsAdhemerval Zanella2019-10-1722-192/+56
| | | | | | | | | | | | | | | | | | | | | | | This patch refactor the internal sysvipc in two main points: 1. Add a new __ASSUME_SYSVIPC_DEFAULT_IPC_64 to infer the __IPC_64 value to be used along either the multiplexed __NR_ipc or wired-up syscall. The defaut value assumed for __IPC_64 is also changed from 0x100 to 0x0, aligning with Linux generic UAPI. The idea is to simplify the Linux 5.1 wire-up for sysvipc syscalls for some 32-bit ABIs (which expectes __IPC_64 being 0x0) and simplify new ports (which will no longer need to add ipc_priv.h). 2. It also removes some duplicated internal definition used on compat sysvipc symbols defined at ipc_priv.h (more specifically the __old_ipc_perm, SEMCTL_ARG_ADDRESS, MSGRCV_ARGS, and SEMTIMEDOP_IPC_ARGS). The idea is also to make it simpler to enable the new wire-up sysvipc syscall provided by Linux v5.1. There is no semantic change expected on any port. Checked with a build against all affected ABIs. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* Add PTRACE_GET_SYSCALL_INFO from Linux 5.3 to sys/ptrace.h.Joseph Myers2019-10-149-7/+96
| | | | | | | | | | | | | Linux 5.3 adds a PTRACE_GET_SYSCALL_INFO constant, with an associated structure and PTRACE_SYSCALL_INFO_* constants. This patch adds these to sys/ptrace.h in glibc (PTRACE_GET_SYSCALL_INFO in each architecture version, the rest in bits/ptrace-shared.h). As with previous such constants and associated structures, the glibc version of the structure is named struct __ptrace_syscall_info. Tested for x86_64, and with build-many-glibcs.py.
* sysvipc: Set ipc_perm mode as mode_t (BZ#18231)Adhemerval Zanella2019-10-1032-419/+336
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch sets the mode field in ipc_perm as mode_t for all architectures, as POSIX specification [1]. The changes required are as follow: 1. It moves the ipc_perm definition out of ipc.h to its own header ipc_perm.h. It also allows consolidate the IPC_* definition on only one header. 2. The generic implementation follow the kernel ipc64_perm size so the syscall can be made directly without temporary buffer copy. However, since glibc defines the MODE field as mode_t, it omits the __PAD1 field (since glibc does not export mode_t as 16-bit for any architecture). It is a two-fold improvement: 2.1. New implementation which follow Linux UAPI will not need to provide an arch-specific ipc-perm.h header neither wrongly use the wrong 16-bit definition from previous default ipc.h (as csky did). 2.1. It allows consolidate ipc_perm definition for architectures that already provide mode_t as 32-bit. 3. All kernel ABIs for the supported architectures already provides the expected padding for mode type extension to 32-bit. However, some architectures the padding has the wrong placement, so it requires the ipc control routines (msgctl, semctl, and shmctl) to adjust the mode field accordingly. Currently they are armeb, microblaze, m68k, s390, and sheb. A new assume is added, __ASSUME_SYSVIPC_BROKEN_MODE_T, which the required ABIs define. 4. For the ABIs that define __ASSUME_SYSVIPC_BROKEN_MODE_T, it also require compat symbols that do not adjust the mode field. Checked on arm-linux-gnueabihf, aarch64-linux-gnu, powerpc64le-linux-gnu, and x86_64-linux-gnu. I also checked the sysvipc tests on hppa-linux-gnu, sh4-linux-gnu, s390x-linux-gnu, and s390-linux-gnu. I also did a sanity test against armeb qemu usermode for the sysvipc tests. [BZ #18231] * sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Add bits/ipc-perm.h. * sysdeps/unix/sysv/linux/aarch64/bits/ipc.h: Remove file. * sysdeps/unix/sysv/linux/alpha/bits/ipc.h: Likewise. * sysdeps/unix/sysv/linux/hppa/bits/ipc.h: Likewise. * sysdeps/unix/sysv/linux/ia64/bits/ipc.h: Likewise. * sysdeps/unix/sysv/linux/mips/bits/ipc.h: Likewise. * sysdeps/unix/sysv/linux/powerpc/bits/ipc.h: Likewise. * sysdeps/unix/sysv/linux/s390/bits/ipc.h: Likewise. * sysdeps/unix/sysv/linux/sparc/bits/ipc.h: Likewise. * sysdeps/unix/sysv/linux/arm/kernel-features.h [__BYTE_ORDER == __BIG_ENDIAN] (__ASSUME_SYSVIPC_BROKEN_MODE_T): Define. * sysdeps/sysv/linux/microblaze/kernel-features.h: Likewise. * sysdeps/unix/sysv/linux/s390/kernel-features.h [!__s390x__] (__ASSUME_SYSVIPC_BROKEN_MODE_T): Define. * sysdeps/unix/sysv/linux/sh/kernel-features.h (__ASSUME_SYSVIPC_BROKEN_MODE_T): Define. * sysdeps/unix/sysv/linux/m68k/kernel-features.h: Likewise. * sysdeps/unix/sysv/linux/bits/ipc-perm.h: New file. * sysdeps/unix/sysv/linux/powerpc/bits/ipc-perm.h: Likewise. * sysdeps/unix/sysv/linux/sparc/bits/ipc-perm.h: Likewise. * sysdeps/unix/sysv/linux/bits/ipc.h (ipc_perm): Move to bits/ipc-perm.h. * sysdeps/unix/sysv/linux/hppa/bits/ipc-perm.h: New file. * sysdeps/unix/sysv/linux/kernel-features.h: Add comment about __ASSUME_SYSVIPC_BROKEN_MODE_T semantic. * sysdeps/unix/sysv/linux/msgctl.c (DEFAULT_VERSION): Define as 2.31 if __ASSUME_SYSVIPC_BROKEN_MODE_T is defined. (msgctl_syscall, __msgctl_mode16): New symbol. (__new_msgctl): Add bits for __ASSUME_SYSVIPC_BROKEN_MODE_T. * sysdeps/unix/sysv/linux/semctl.c: Likewise. * sysdeps/unix/sysv/linux/shmctl.c: Likewise. * sysdeps/unix/sysv/linux/arm/be/libc.abilist (GLIBC_2.31): Add msgctl, semctl, and shmctl. * sysdeps/sysv/linux/microblaze/be/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/sh/be/libc.abilist: Likewise. * conform/data/sys/ipc.h-data: Only xfail {struct ipc_perm} mode_t mode for Hurd. * sysdeps/unix/sysv/linux/m68k/Versions (libc) [GLIBC_2.31]: Add msgctl, semctl, and shmctl. * sysdeps/unix/sysv/linux/arm/be/Versions: New file. * sysdeps/unix/sysv/linux/microblaze/be/Versions: Likewise. * sysdeps/unix/sysv/linux/sh/be/Versions: Likewise. [1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_ipc.h.html
* syscall-names.list: fix typos in commentDmitry V. Levin2019-10-101-5/+4
| | | | | * sysdeps/unix/sysv/linux/syscall-names.list: Fix typos in comment, reformat the affected paragraph.
* y2038: linux: Provide __clock_settime64 implementationLukasz Majewski2019-10-101-4/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch provides new __clock_settime64 explicit 64 bit function for setting the time. Moreover, a 32 bit version - __clock_settime - has been refactored to internally use __clock_settime64. The __clock_settime is now supposed to be used on systems still supporting 32 bit time (__TIMESIZE != 64) - hence the necessary conversion to 64 bit struct timespec. The new clock_settime64 syscall available from Linux 5.1+ has been used, when applicable. In this patch the internal padding (tv_pad) of struct __timespec64 is left untouched (on systems with __WORDSIZE == 32) as Linux kernel ignores upper 32 bits of tv_nsec. Build tests: - The code has been tested on x86_64/x86 (native compilation): make PARALLELMFLAGS="-j8" && make xcheck PARALLELMFLAGS="-j8" - The glibc has been build tested (make PARALLELMFLAGS="-j8") for x86 (i386), x86_64-x32, and armv7 Run-time tests: - Run specific tests on ARM/x86 32bit systems (qemu): https://github.com/lmajewski/meta-y2038 and run tests: https://github.com/lmajewski/y2038-tests/commits/master - Use of cross-test-ssh.sh for ARM (armv7): make PARALLELMFLAGS="-j8" test-wrapper='./cross-test-ssh.sh root@192.168.7.2' xcheck Linux kernel, headers and minimal kernel version for glibc build test matrix: - Linux v5.1 (with clock_settime64) and glibc build with v5.1 as minimal kernel version (--enable-kernel="5.1.0") The __ASSUME_TIME64_SYSCALLS flag defined. - Linux v5.1 and default minimal kernel version The __ASSUME_TIME64_SYSCALLS not defined, but kernel supports __clock_settime64 syscalls. - Linux v4.19 (no clock_settime64 support) with default minimal kernel version for contemporary glibc This kernel doesn't support __clock_settime64 syscalls, so the fallback to clock_settime is tested. The above tests were performed with Y2038 redirection applied as well as without (so the __TIMESIZE != 64 execution path is checked as well). No regressions were observed. * include/time.h (__clock_settime64): Add __clock_settime alias according to __TIMESIZE define * sysdeps/unix/sysv/linux/clock_settime.c (__clock_settime): Refactor this function to be used only on 32 bit machines as a wrapper on __clock_settime64. * sysdeps/unix/sysv/linux/clock_settime.c (__clock_settime64): Add * sysdeps/unix/sysv/linux/clock_settime.c (__clock_settime64): Use clock_settime64 kernel syscall (available from 5.1+ Linux)
* mips: Do not malloc on getdents64 fallbackAdhemerval Zanella2019-10-091-59/+81
| | | | | | | | | | | | | | | | | | | | | This patch changes how the fallback getdents64 implementation calls non-LFS getdents by replacing the scratch_buffer with static buffer plus a loop on getdents calls. This avoids the potential malloc call on scratch_buffer_set_array_size for large input buffer size at the cost of more getdents syscalls. It also adds a small optimization for older kernels, where the first ENOSYS failure for getdents64 disable subsequent calls. Check the dirent tests on a mips64-linux-gnu with getdents64 code disabled. * sysdeps/unix/sysv/linux/mips/mips64/getdents64.c (__getdents64): Add small optimization for older kernel to avoid issuing __NR_getdents64 on each call and replace scratch_buffer usage with a static allocated buffer. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* sparc: Assume GOTDATA support in the toolchainFlorian Weimer2019-10-092-65/+2
| | | | | | HAVE_GCC_GOTDATA has apparently never been used. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Move pthread_attr_setschedparam implementation into libcFlorian Weimer2019-10-0728-29/+0
| | | | | | | | This is part of the libpthread removal project: <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* riscv: Remove support for variable page sizesFlorian Weimer2019-10-073-120/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | _dl_var_init is used to patch the read-only data section after relocation. Several architectures use this to update GLRO(page_size) with the correct value for the static dlopen case, where _rtld_global_ro has not been initialized by the dynamic loader. RISC-V does not need this. The RISC-V Instruction Set Manual, Volume II: Privileged Architecture, Document Version 20190608-Priv-MSU-Ratified says this: After much deliberation, we have settled on a conventional page size of 4 KiB for both RV32 and RV64. We expect this decision to ease the porting of low-level runtime software and device drivers. The TLB reach problem is ameliorated by transparent superpage support in modern operating systems [2]. Additionally, multi-level TLB hierarchies are quite inexpensive relative to the multi-level cache hierarchies whose address space they map. [2] Juan Navarro, Sitaram Iyer, Peter Druschel, and Alan Cox. Practical, transparent operating system support for superpages. SIGOPS Oper. Syst. Rev., 36(SI):89–104, December 2002. This means that the initialization of _rtld_global_ro._dl_page_size in elf/rtld.c with EXEC_PAGESIZE is sufficient for RISC-V.
* nptl: Move pthread_attr_getschedparam implementation into libcFlorian Weimer2019-10-0728-29/+0
| | | | | | | | This is part of the libpthread removal project: <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Move pthread_attr_setinheritsched implementation into libc.Florian Weimer2019-10-0428-28/+0
| | | | | | This is part of the libpthread removal project: <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html>
* [powerpc] No need to enter "Ignore Exceptions Mode"Paul A. Clarke2019-10-021-4/+15
| | | | | | | | | Since at least POWER8, there is no performance advantage to entering "Ignore Exceptions Mode", and doing so conditionally requires - the conditional logic, and - a system call. Make it a no-op for uses within glibc.
* Split up endian.h to minimize exposure of BYTE_ORDER.Alistair Francis2019-10-0152-238/+241
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With only two exceptions (sys/types.h and sys/param.h, both of which historically might have defined BYTE_ORDER) the public headers that include <endian.h> only want to be able to test __BYTE_ORDER against __*_ENDIAN. This patch creates a new bits/endian.h that can be included by any header that wants to be able to test __BYTE_ORDER and/or __FLOAT_WORD_ORDER against the __*_ENDIAN constants, or needs __LONG_LONG_PAIR. It only defines macros in the implementation namespace. The existing bits/endian.h (which could not be included independently of endian.h, and only defines __BYTE_ORDER and maybe __FLOAT_WORD_ORDER) is renamed to bits/endianness.h. I also took the opportunity to canonicalize the form of this header, which we are stuck with having one copy of per architecture. Since they are so short, this means git doesn’t understand that they were renamed from existing headers, sigh. endian.h itself is a nonstandard header and its only remaining use from a standard header is guarded by __USE_MISC, so I dropped the __USE_MISC conditionals from around all of the public-namespace things it defines. (This means, an application that requests strict library conformance but includes endian.h will still see the definition of BYTE_ORDER.) A few changes to specific bits/endian(ness).h variants deserve mention: - sysdeps/unix/sysv/linux/ia64/bits/endian.h is moved to sysdeps/ia64/bits/endianness.h. If I remember correctly, ia64 did have selectable endianness, but we have assembly code in sysdeps/ia64 that assumes it’s little-endian, so there is no reason to treat the ia64 endianness.h as linux-specific. - The C-SKY port does not fully support big-endian mode, the compile will error out if __CSKYBE__ is defined. - The PowerPC port had extra logic in its bits/endian.h to detect a broken compiler, which strikes me as unnecessary, so I removed it. - The only files that defined __FLOAT_WORD_ORDER always defined it to the same value as __BYTE_ORDER, so I removed those definitions. The SH bits/endian(ness).h had comments inconsistent with the actual setting of __FLOAT_WORD_ORDER, which I also removed. - I *removed* copyright boilerplate from the few bits/endian(ness).h headers that had it; these files record a single fact in a fashion dictated by an external spec, so I do not think they are copyrightable. As long as I was changing every copy of ieee754.h in the tree, I noticed that only the MIPS variant includes float.h, because it uses LDBL_MANT_DIG to decide among three different versions of ieee854_long_double. This patch makes it not include float.h when GCC’s intrinsic __LDBL_MANT_DIG__ is available. * string/endian.h: Unconditionally define LITTLE_ENDIAN, BIG_ENDIAN, PDP_ENDIAN, and BYTE_ORDER. Condition byteswapping macros only on !__ASSEMBLER__. Move the definitions of __BIG_ENDIAN, __LITTLE_ENDIAN, __PDP_ENDIAN, __FLOAT_WORD_ORDER, and __LONG_LONG_PAIR to... * string/bits/endian.h: ...this new file, which includes the renamed header bits/endianness.h for the definition of __BYTE_ORDER and possibly __FLOAT_WORD_ORDER. * string/Makefile: Install bits/endianness.h. * include/bits/endian.h: New wrapper. * bits/endian.h: Rename to bits/endianness.h. Add multiple-include guard. Rewrite the comment explaining what the machine-specific variants of this file should do. * sysdeps/unix/sysv/linux/ia64/bits/endian.h: Move to sysdeps/ia64. * sysdeps/aarch64/bits/endian.h * sysdeps/alpha/bits/endian.h * sysdeps/arm/bits/endian.h * sysdeps/csky/bits/endian.h * sysdeps/hppa/bits/endian.h * sysdeps/ia64/bits/endian.h * sysdeps/m68k/bits/endian.h * sysdeps/microblaze/bits/endian.h * sysdeps/mips/bits/endian.h * sysdeps/nios2/bits/endian.h * sysdeps/powerpc/bits/endian.h * sysdeps/riscv/bits/endian.h * sysdeps/s390/bits/endian.h * sysdeps/sh/bits/endian.h * sysdeps/sparc/bits/endian.h * sysdeps/x86/bits/endian.h: Rename to endianness.h; canonicalize form of file; remove redundant definitions of __FLOAT_WORD_ORDER. * sysdeps/powerpc/bits/endianness.h: Remove logic to check for broken compilers. * ctype/ctype.h * sysdeps/aarch64/nptl/bits/pthreadtypes-arch.h * sysdeps/arm/nptl/bits/pthreadtypes-arch.h * sysdeps/csky/nptl/bits/pthreadtypes-arch.h * sysdeps/ia64/ieee754.h * sysdeps/ieee754/ieee754.h * sysdeps/ieee754/ldbl-128/ieee754.h * sysdeps/ieee754/ldbl-128ibm/ieee754.h * sysdeps/m68k/nptl/bits/pthreadtypes-arch.h * sysdeps/microblaze/nptl/bits/pthreadtypes-arch.h * sysdeps/mips/ieee754/ieee754.h * sysdeps/mips/nptl/bits/pthreadtypes-arch.h * sysdeps/nios2/nptl/bits/pthreadtypes-arch.h * sysdeps/nptl/pthread.h * sysdeps/riscv/nptl/bits/pthreadtypes-arch.h * sysdeps/sh/nptl/bits/pthreadtypes-arch.h * sysdeps/sparc/sparc32/ieee754.h * sysdeps/unix/sysv/linux/generic/bits/stat.h * sysdeps/unix/sysv/linux/generic/bits/statfs.h * sysdeps/unix/sysv/linux/sys/acct.h * wctype/bits/wctype-wchar.h: Include bits/endian.h, not endian.h. * sysdeps/unix/sysv/linux/hppa/pthread.h: Don’t include endian.h. * sysdeps/mips/ieee754/ieee754.h: Use __LDBL_MANT_DIG__ in ifdefs, instead of LDBL_MANT_DIG. Only include float.h when __LDBL_MANT_DIG__ is not predefined, in which case define __LDBL_MANT_DIG__ to equal LDBL_MANT_DIG.
* Update bits/mman.h constants and tst-mman-consts.py for Linux 5.3.Joseph Myers2019-09-303-1/+5
| | | | | | | | | | | | | | | | | | The Linux 5.3 uapi headers have some rearrangement relating to MAP_* constants, which includes the effect of adding definitions of MAP_SYNC on powerpc and sparc. This patch updates the corresponding glibc bits/mman.h headers accordingly, and updates the Linux kernel version number in tst-mman-consts.py to reflect that these constants are now current with that kernel version. Tested with build-many-glibcs.py. * sysdeps/unix/sysv/linux/powerpc/bits/mman.h [__USE_MISC] (MAP_SYNC): New macro. * sysdeps/unix/sysv/linux/sparc/bits/mman.h [__USE_MISC] (MAP_SYNC): Likewise. * sysdeps/unix/sysv/linux/tst-mman-consts.py (main): Update Linux kernel version number to 5.3.
* [powerpc] Rename fesetenv_mode to fesetenv_controlPaul A. Clarke2019-09-275-6/+6
| | | | | | | fesetenv_mode is used variously to write the FPSCR exception enable bits and rounding mode bits. These are referred to as the control bits in the POWER ISA. Change the name to be reflective of its current and expected use, and match up well with fegetenv_control.
* [powerpc] libc_feholdsetround_noex_ppc_ctx: optimize FPSCR writePaul A. Clarke2019-09-271-1/+1
| | | | | | | | | | | | libc_feholdsetround_noex_ppc_ctx currently performs: 1. Read FPSCR, save to context. 2. Create new FPSCR value: clear enables and set new rounding mode. 3. Write new value to FPSCR. Since other bits just pass through, there is no need to write them. Instead, write just the changed values (enables and rounding mode), which can be a bit more efficient.
* [powerpc] Rename fegetenv_status to fegetenv_controlPaul A. Clarke2019-09-277-9/+9
| | | | | | | | | | | fegetenv_status is used variously to retrieve the FPSCR exception enable bits, rounding mode bits, or both. These are referred to as the control bits in the POWER ISA. FPSCR status bits are also returned by the 'mffs' and 'mffsl' instructions, but they are uniformly ignored by all uses of fegetenv_status. Change the name to be reflective of its current and expected use. Reviewed-By: Paul E Murphy <murphyp@linux.ibm.com>
* [powerpc] __fesetround_inline optimizationsPaul A. Clarke2019-09-271-3/+15
| | | | | | | | | On POWER9, use more efficient means to update the 2-bit rounding mode via the 'mffscrn' instruction (instead of two 'mtfsb0/1' instructions or one 'mtfsfi' instruction that modifies 4 bits). Suggested-by: Paul E. Murphy <murphyp@linux.ibm.com> Reviewed-By: Paul E Murphy <murphyp@linux.ibm.com>
* [powerpc] libc_feupdateenv_test: optimize FPSCR accessPaul A. Clarke2019-09-272-2/+18
| | | | | | | | | | | | ROUND_TO_ODD and a couple of other places use libc_feupdateenv_test to restore the rounding mode and exception enables, preserve exception flags, and test whether given exception(s) were generated. If the exception flags haven't changed, then it is sufficient and a bit more efficient to just restore the rounding mode and enables, rather than writing the full Floating-Point Status and Control Register (FPSCR). Reviewed-by: Paul E. Murphy <murphyp@linux.ibm.com>
* [powerpc] fenv_private.h clean upPaul A. Clarke2019-09-278-117/+38
| | | | | | | | | | | fenv_private.h includes unused functions, magic macro constants, and some replicated common code fragments. Remove unused functions, replace magic constants with constants from fenv_libc.h, and refactor replicated code. Suggested-by: Paul E. Murphy <murphyp@linux.ibm.com> Reviewed-By: Paul E Murphy <murphyp@linux.ibm.com>
* Add TCP_TX_DELAY from Linux 5.3 to netinet/tcp.h.Joseph Myers2019-09-271-0/+1
| | | | | | | | | This patch adds the new TCP_TX_DELAY constant from Linux 5.3 to sysdeps/gnu/netinet/tcp.h. Tested for x86_64. * sysdeps/gnu/netinet/tcp.h (TCP_TX_DELAY): New macro.
* Fix tst-sigcontext-get_pc rule name from a43565ac447b1Adhemerval Zanella2019-09-251-1/+1
| | | | | | | | Checked on powerpc64le-linux-gnu. * sysdeps/unix/sysv/linux/Makefile (CFLAGS-tst-sigcontextinfo-get_pc.c): Rename to CFLAGS-tst-sigcontext-get_pc.c.
* Fix vDSO initialization on arm and mipsAndreas Schwab2019-09-242-4/+4
|
* [powerpc] SET_RESTORE_ROUND optimizations and bug fixPaul A. Clarke2019-09-192-25/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SET_RESTORE_ROUND brackets a block of code, temporarily setting and restoring the rounding mode and letting everything else, including exceptions generated within the block, pass through. On powerpc, the current code clears the exception enables, which will hide exceptions generated within the block. This issue was introduced by me in commit e905212627350d54b58426214b5a54ddc852b0c9. Fix this by not clearing exception enable bits in the prologue. Also, since we are no longer changing the enable bits in either the prologue or the epilogue, there is no need to test for entering/exiting non-stop mode. Also, optimize the prologue get/save/set rounding mode operations for POWER9 and later by using 'mffscrn' when possible. Suggested-by: Paul E. Murphy <murphyp@linux.ibm.com> Reviewed-by: Paul E. Murphy <murphyp@linux.ibm.com> Fixes: e905212627350d54b58426214b5a54ddc852b0c9 2019-09-19 Paul A. Clarke <pc@us.ibm.com> * sysdeps/powerpc/fpu/fenv_libc.h (fegetenv_and_set_rn): New. (__fe_mffscrn): New. * sysdeps/powerpc/fpu/fenv_private.h (libc_feholdsetround_ppc_ctx): Do not clear enable bits, remove obsolete code, use fegetenv_and_set_rn. (libc_feresetround_ppc): Remove obsolete code, use fegetenv_and_set_rn.
* S390: Use _HP_TIMING_S390_H instead of _HP_TIMING_H.Stefan Liebler2019-09-191-2/+2
| | | | | | | | | | Use macro _HP_TIMING_S390_H instead of _HP_TIMING_H in s390 specific hp-timing.h ChangeLog: * sysdeps/s390/hp-timing.h (_HP_TIMING_H): Undefine. (_HP_TIMING_S390_H): Define.
* Update syscall-names.list for Linux 5.3.Joseph Myers2019-09-181-2/+4
| | | | | | | | | | | | This patch updates syscall-names.list for Linux 5.3, adding two new syscalls. Tested with build-many-glibcs.py. * sysdeps/unix/sysv/linux/syscall-names.list: Update kernel version to 5.3. (clone3): New syscall. (pidfd_open): Likewise.