Commit Graph

4415 Commits

Author SHA1 Message Date
Nathan Lynch b65d3e5f0f ARM: VDSO support
Beginning with the upcoming 4.1 release, Linux on a subset of 32-bit
ARM hardware will provide fast user-space implementations of the
following system calls:

- gettimeofday
- clock_gettime

The kernel implementation depends on the ARMv7 Generic Timers
Extension to accelerate these system calls.  So CPUs such as
Cortex-A15 and -A7 benefit, while Cortex-A9, -A8, and pre-v7 CPUs do
not.  On systems where the VDSO does not provide any speedup, the
kernel prevents the relevant symbol lookups from succeeding.

On OMAP5 (Cortex-A15) gettimeofday latency decreases from ~350ns to
~120ns.  On BeagleBone Black (Cortex-A8) it goes from ~650ns to
~660ns, which to my mind is an acceptable cost.

Verified that no new test failures are introduced on kernels with and
without the VDSO.

	* sysdeps/unix/sysv/linux/arm/Makefile: (sysdep_routines):
	Include dl-vdso.
	* sysdeps/unix/sysv/linux/arm/init-first.c: New file:
	Use VDSO routines for gettimeofday, clock_gettime if
	available.
	* sysdeps/unix/sysv/linux/arm/libc-vdso.h: New file:
	Declare VDSO symbols.
	* sysdeps/unix/sysv/linux/arm/sysdep.h:
	[HAVE_GETTIMEOFDAY_VSYSCALL]: Define.
	[HAVE_CLOCK_GETTIME_VSYSCALL]: Define.
	* sysdeps/unix/sysv/linux/arm/Versions: Add
	__vdso_clock_gettime.
2015-06-04 21:10:43 +00:00
Adhemerval Zanella 34caaafd1a Use inline syscalls for non-cancellable versions
This patch uses inline calls (through INLINE_SYSCALL macro) to define
the non-cancellable functions macros to avoid use of the
syscall_nocancel entrypoint.
2015-06-04 14:52:34 -03:00
Joseph Myers e0c349b40c Use better variable names in MIPS syscall macros.
Carlos noted in
<https://sourceware.org/ml/libc-alpha/2015-05/msg00680.html> that
various ports use potentially problematic short variables names in
their syscall macros, which could shadow variables with the same name
from containing scopes.

This patch fixes variables called err and ret in MIPS macros.  (I left
result_var and _sys_result - separate variables in different macros,
which need separate names - alone.)

Tested for mips64 (all three ABIs) that installed stripped shared
libraries are unchanged by this patch.

	* sysdeps/unix/sysv/linux/mips/mips32/sysdep.h (INLINE_SYSCALL):
	Use variable name _sc_err instead of err.
	[__mips16] (INTERNAL_SYSCALL_NCS): Use variable name _sc_ret
	instead of ret.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
	(INLINE_SYSCALL): Use variable name _sc_err instead of err.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
	(INLINE_SYSCALL): Likewise.
2015-06-02 20:38:49 +00:00
Adhemerval Zanella 1395ef2107 x86: clock_gettime and timespec_get vDSO cleanup
This patch removes the x86 specific timespec_get and clock_gettime
implementation to use generic HAVE_CLOCK_GETTIME_VSYSCALL way.
2015-06-01 22:25:02 -03:00
Martin Sebor db8fed87d9 powerpc: setcontext.S uses power6 mtfsf when not supported [BZ #18116]
The attached patch fixes a glibc build failure with gcc 5 on powerpc64le
caused by a recent change in gcc where the compiler defines the
_ARCH_PWR6 macro when processing assembly files but doesn't invoke the
assembler in the corresponding machine mode (unless it has been
explicitly configured to target POWER 6 or later).  A bug had been filed
with gcc for this (65341) but was closed as won't fix. Glibc relies on
the _ARCH_PWR6 macro in a few .S files to make use of Power ISA 2.5
instructions (specifically, the four-argument form of the mtfsf insn).
A similar problem had occurred in the past (bug 10118) but the fix that
was committed for it didn't anticipate this new problem.
2015-06-01 16:19:50 -03:00
Chris Metcalf 1827059925 tile: use better variable naming in INLINE_SYSCALL
At issue for INLINE_SYSCALL was that it used "err" and "val"
as variable names in a #define, so that if it was used in a context
where the "caller" was also using "err" or "val", and those
variables were passed in to INLINE_SYSCALL, we would end up
referencing the internal shadowed variables instead.

For example, "char val" in check_may_shrink_heap() in
sysdeps/unix/sysv/linux/malloc-sysdep.h was being shadowed by
the syscall return "val" in INLINE_SYSCALL, causing the "char val"
not to get updated at all, and may_shrink_heap ended up always false.

A similar fix was made to INTERNAL_VSYSCALL_CALL.
2015-05-26 20:29:56 -04:00
Roland McGrath 68c97aef62 Split timed-wait functions out of nptl/lowlevellock.c. 2015-05-26 14:49:13 -07:00
Adhemerval Zanella 97554e4382 Consolidate gettimeofday across aarch64/s390/tile
This patch removes the architecture specific gettimeofday implementation
to use the vDSO symbol and consolidate it on a common Linux one.
Similar to clock_gettime and clock_getres vDSO implementation, each port
that supports gettimeofday through vDSO should just implement INLINE_VSYSCALL
to access the symbol and define HAVE_{GETTIME,GETRES}_VSYSCAL as 1.
2015-05-26 17:03:35 -03:00
Szabolcs Nagy a06b40cdf5 struct stat is not posix conform
On 21/05/15 05:29, Siddhesh Poyarekar wrote:
> On Wed, May 20, 2015 at 06:55:02PM +0100, Szabolcs Nagy wrote:
>> i guess it's ok for consistency if i fix struct stat64
>> too to use __USE_XOPEN2K8.
>>
>> i will run some tests and come back with a patch
>
> I also think it would be appropriate to change this code in other
> architectures (microblaze and nacl IIRC) to make all of them
> consistent.  It is a mechanical enough change IMO that all arch
> maintainer acks is not necessary.
>

here is the patch with consistent __USE_XOPEN2K8

ok to commit?

2015-05-21  Szabolcs Nagy  <szabolcs.nagy@arm.com>

	[BZ #18234]
	* conform/data/sys/stat.h-data (struct stat): Add tests for st_atim,
	st_mtim and st_ctim members.

	* sysdeps/nacl/bits/stat.h (struct stat, struct stat64): Make
	st_atim, st_ctim, st_mtim visible under __USE_XOPEN2K8 only.

	* sysdeps/unix/sysv/linux/generic/bits/stat.h (struct stat,):
	(struct stat64): Likewise.

	* sysdeps/unix/sysv/linux/ia64/bits/stat.h (struct stat,):
	(struct stat64): Likewise.

	* sysdeps/unix/sysv/linux/microblaze/bits/stat.h (struct stat,):
	(struct stat64): Likewise.
2015-05-26 22:27:24 +05:30
Adhemerval Zanella f534255e4d Consolidate vDSO macros and usage
This patch consolidate the Linux vDSO define and usage across all ports
that uses it.  The common vDSO definitions and calling through
{INLINE/INTERNAL}_VSYSCALL macros are moved to a common header
sysdep-vdso.h and vDSO name declaration and prototype is defined
using a common macro.

Also PTR_{MANGLE,DEMANGLE} is added to ports that does not use them
for vDSO calls (aarch64, powerpc, s390, and tile) and thus it will
reflect in code changes.  For ports that already implement pointer
mangling/demangling in vDSO system (i386, x32, x86_64) this patch
is mainly a code refactor.

Checked on x32, x86_64, x32, ppc64le, and aarch64.
2015-05-26 10:10:36 -03:00
Adhemerval Zanella 60dce8b904 Remove socket.S implementation
This patch removes the socket.S implementation for all ports and replace
it by a C implementation using socketcall.  For ports that implement
the syscall directly, there is no change.

The patch idea is to simplify the socket function implementation that
uses the socketcall to be based on C implemetation instead of a pseudo
assembly implementation with arch specific parts.  The patch then remove
the assembly implementatation for the ports which uses socketcall
(i386, microblaze, mips, powerpc, sparc, m68k, s390 and sh).

I have cross-build GLIBC for afore-mentioned ports and tested on both
i386 and ppc32 without regressions.
2015-05-22 17:38:06 -03:00
Joseph Myers cf06a4e357 Fix pathconf basename namespace (bug 18444).
pathconf (sysdeps/unix/sysv/linux/pathconf.c) uses basename.  But
pathconf is in POSIX back to 1990 while basename is only reserved with
external linkage in those standards including XPG functions.  This
patch fixes this namespace issue in the usual way, renaming basename
to __basename and making it into a weak alias.

Tested for x86_64 and x86 (testsuite, and that disassembly of
installed shared libraries is unchanged by the patch).

	[BZ #18444]
	* string/basename.c (basename): Rename to __basename and define as
	weak alias of __basename.  Use libc_hidden_weak.
	* include/string.h (__basename): Declare.  Use libc_hidden_proto.
	* sysdeps/unix/sysv/linux/pathconf.c (distinguish_extX): Call
	__basename instead of basename.
	* conform/Makefile (test-xfail-POSIX2008/unistd.h/linknamespace):
	Remove variable.
	(test-xfail-XOPEN2K8/unistd.h/linknamespace): Likewise.
2015-05-22 17:09:36 +00:00
Roland McGrath 7cea621278 NaCl: Set tid field to a unique value. 2015-05-20 14:52:05 -07:00
Roland McGrath 5e2aa9a421 Move usleep.c using nanosleep to sysdeps/posix. 2015-05-20 14:18:21 -07:00
Adhemerval Zanella 96dffc26dc i386: Remove six-argument specialized implementations
This patch removes the specialized i386 assembly implementations for
fallocate{64}, pselect, and sync_file_range now that i386 have
support for 6 argument syscalls.
2015-05-20 16:37:52 -03:00
Adhemerval Zanella 95b07fbcc7 Fix non-portable echo usage in sysdeps/unix/make-syscalls.sh
This patch changes the way make-syscall-sh script uses echo to follow
POSIX spec.
2015-05-14 16:38:46 -03:00
Roland McGrath d2ee815ad6 Refactor scandir/scandirat to use common tail. 2015-05-13 12:34:11 -07:00
Roland McGrath 83c1089325 Break __scandir_cancel_handler out into its own file. 2015-05-13 12:33:56 -07:00
H.J. Lu d9efd775ba Remove a trailing `\' in make-syscalls.sh
[BZ #18409]
	* sysdeps/unix/make-syscalls.sh: Remove a trailing `\'.
2015-05-13 09:11:12 -07:00
Carlos O'Donell c92d40c0bc Bug 18125: Call exit after last linked context.
There appears to be a discrepancy among the implementations
of setcontext with regards to the function called once the last
linked-to context has finished executing via setcontext.

The POSIX standard says:
~~~
If the uc_link member of the ucontext_t structure pointed to by
the ucp argument is equal to 0, then this context is the main
context, and the thread will exit when this context returns.
~~~

It says "exit" not "exit immediately" nor "exit without running
functions registered with atexit or on_exit."

Therefore the AArch64, ARM, hppa and NIOS II implementations are
wrong and no test detects it.

It is questionable if this should even be fixed or just documented
that the above 4 targets are wrong. The functions are deprecated
and nobody should be using them, but at the same time it silly to
have cross-target differences that make it hard to port old
applications from say x86_64 to AArch64.

Therefore I will ix the 4 arches, and checkin a regression
test to prevent it from changing again.

https://sourceware.org/ml/libc-alpha/2015-03/msg00720.html
2015-05-08 11:29:38 -04:00
Florian Weimer d0ccd0d977 __ASSUME_FALLOCATE is always true on 32-bit architectures
This means we can clean up the generic code a bit.  The 64-bit
variant still needs to support !__ASSUME_FALLOCATE for alpha.
2015-05-05 08:28:35 +02:00
Florian Weimer 4bd40bcf44 i386: Remove fallocate, fallocate64, posix_fallocate, posix_fallocate64
With 6-argument system call support, the generic Linux implementations of
these system calls work, and there is no need for i386-specific versions.
2015-05-05 08:27:28 +02:00
Joseph Myers 0833cecd26 Remove MIPS version of waitid.c.
Since glibc is no longer built with -Winline, a special MIPS version
of waitid.c to disable -Winline is no longer needed, and this patch
removes it.  Tested that glibc does indeed build with the patch
applied.

	* sysdeps/unix/sysv/linux/mips/mips32/waitid.c: Remove file.
2015-04-30 16:25:46 +00:00
David S. Miller 3f2e21e9cf Update sparc localplt.data
* sysdeps/unix/sysv/linux/sparc/sparc32/localplt.data: Remove
	__tls_get_addr.
	* sysdeps/unix/sysv/linux/sparc/sparc64/localplt.data: Likewise.
2015-04-27 14:53:13 -07:00
Stefan Liebler f7fba80508 S/390: Get cache information via sysconf
This patch adds support to query cache information on s390
via sysconf() function - e.g. with _SC_LEVEL1_ICACHE_SIZE.
The attributes size, linesize and assoc can be queried
for cache level 1 - 4 via "extract cpu attribute" instruction,
which was first available with z10.

* NEWS: Mention sysconf() cache information support for s390.
* sysdeps/unix/sysv/linux/s390/sysconf.c: New File.
2015-04-24 13:37:39 +02:00
Adhemerval Zanella 7bf8fb1042 libc-vdso.h place consolidation
This patch moves the libc-vdso.h internal header from bits folder to
default architecture one and also corrects the remaning includes in
the files.
2015-04-20 08:51:17 -03:00
David S. Miller f70925993a Convert sparc over to lowlevellock-futex.h
* sysdeps/unix/sysv/linux/sparc/lowlevellock.h: Make use of
	lowlevellock-futex.h
2015-04-16 13:05:41 -07:00
James Cowgill d5856d06c3 [BZ #17930] MIPS: Define SHM_NORESERVE.
[BZ #17930]
	* sysdeps/unix/sysv/linux/mips/bits/shm.h (SHM_NORESERVE): Define.
2015-04-07 17:23:54 +00:00
Richard Henderson cc47c82476 alpha: Unconditionally include dl-sysdep.h in sysdep.h
Fixes a -Wundef error wrt RTLD_PRIVATE_ERRNO.
2015-04-06 10:36:44 -07:00
Andreas Schwab b763f6ae85 aarch64: Increase MINSIGSTKSZ and SIGSTKSZ (bug 16850) 2015-04-02 12:18:11 +02:00
Joseph Myers 9fa55373e1 Remove unused macros from i386 lowlevellock.h.
In the course of the work on six-argument syscalls I noticed that the
i386 lowlevellock.h contained some unused macro definitions (already
unused before my patch).  This patch removes them.

Tested for x86 that installed stripped shared libraries are unchanged
by this patch.

	* sysdeps/unix/sysv/linux/i386/lowlevellock.h (LLL_EBX_LOAD):
	Remove macro.
	(LLL_EBX_REG): Likewise.
	(LLL_ENTER_KERNEL): Likewise.
2015-03-25 21:21:18 +00:00
Joseph Myers a9fe4c5aa8 Support six-argument syscalls from C for 32-bit x86, use generic lowlevellock-futex.h (bug 18138).
This patch follows the approach outlined in
<https://sourceware.org/ml/libc-alpha/2015-03/msg00656.html> to
support six-argument syscalls from INTERNAL_SYSCALL for 32-bit x86,
making them call a function __libc_do_syscall that takes the syscall
number and three syscall arguments in the registers in which the
kernel expects them, along with a pointer to a structure containing
the other three arguments.

In turn, this allows the generic lowlevellock-futex.h to be used on
32-bit x86, so supporting lll_futex_timed_wait_bitset (and so allowing
FUTEX_CLOCK_REALTIME to be used in various cases, so fixing bug 18138
for 32-bit x86 and leaving hppa as the only architecture missing
lll_futex_timed_wait_bitset).  The change to lowlevellock.h's
definition of SYS_futex is because the generic lowlevelloc-futex.h
ends up bringing in bits/syscall.h which defines SYS_futex to
__NR_futex, so resulting in redefinition errors.  The revised
definition in lowlevellock.h is in line with what the x86_64 version
does.

__libc_do_syscall is only needed in libpthread at present (meaning
nothing special needs to be done to make it shared-only in most
libraries containing it, static in libc only, as on ARM).

Tested for 32-bit x86, with the glibc testsuite and with the test in
bug 18138.  The failures seen

FAIL: nptl/tst-cleanupx4
FAIL: rt/tst-cpuclock2

are pre-existing.

	[BZ #18138]
	* sysdeps/unix/sysv/linux/i386/sysdep.h (struct
	libc_do_syscall_args): New structure.
	(INTERNAL_SYSCALL_MAIN_0): New macro.
	(INTERNAL_SYSCALL_MAIN_1): Likewise.
	(INTERNAL_SYSCALL_MAIN_2): Likewise.
	(INTERNAL_SYSCALL_MAIN_3): Likewise.
	(INTERNAL_SYSCALL_MAIN_4): Likewise.
	(INTERNAL_SYSCALL_MAIN_5): Likewise.
	(INTERNAL_SYSCALL_MAIN_6): Likewise.  Call __libc_do_syscall.
	(INTERNAL_SYSCALL): Define to use INTERNAL_SYSCALL_MAIN_##nr.
	Replace conditional definitions by conditional definitions of ....
	(INTERNAL_SYSCALL_MAIN_INLINE): ... this.  New macro.
	* sysdeps/unix/sysv/linux/i386/libc-do-syscall.S: New file.
	* sysdeps/unix/sysv/linux/i386/Makefile [$(subdir) = nptl]
	(libpthread-sysdep_routines): Add libc-do-syscall.
	* sysdeps/unix/sysv/linux/i386/lowlevellock-futex.h: Remove file.
	* sysdeps/unix/sysv/linux/i386/lowlevellock.h (SYS_futex): Define
	to __NR_futex not 240.
2015-03-25 15:17:54 +00:00
Alan Modra afcd9480fe powerpc __tls_get_addr call optimization
This patch is glibc support for a PowerPC TLS optimization, inspired
by Alexandre Oliva's TLS optimization for other processors,
http://www.lsd.ic.unicamp.br/~oliva/writeups/TLS/RFC-TLSDESC-x86.txt

In essence, this optimization uses a zero module id in the tls_index
GOT entry to indicate that a TLS variable is allocated space in the
static TLS area.  A special plt call linker stub for __tls_get_addr
checks for such a tls_index and if found, returns the offset
immediately.  The linker communicates the fact that the special
__tls_get_addr stub is used by setting a bit in the dynamic tag
DT_PPC64_OPT/DT_PPC_OPT.  glibc communicates to the linker that this
optimization is available by the presence of __tls_get_addr_opt.

tst-tlsmod2.so is built with -Wl,--no-tls-get-addr-optimize for
tst-tls-dlinfo, which otherwise would fail since it tests that no
static tls is allocated.  The ld option --no-tls-get-addr-optimize has
been available since binutils-2.20 so doesn't need a configure test.

	* NEWS: Advertise TLS optimization.
	* elf/elf.h (R_PPC_TLSGD, R_PPC_TLSLD, DT_PPC_OPT, PPC_OPT_TLS): Define.
	(DT_PPC_NUM): Increment.
	* elf/dynamic-link.h (HAVE_STATIC_TLS): Define.
	(CHECK_STATIC_TLS): Use here.
	* sysdeps/powerpc/powerpc32/dl-machine.h (elf_machine_rela): Optimize
	TLS descriptors.
	* sysdeps/powerpc/powerpc64/dl-machine.h (elf_machine_rela): Likewise.
	* sysdeps/powerpc/dl-tls.c: New file.
	* sysdeps/powerpc/Versions: Add __tls_get_addr_opt.
	* sysdeps/powerpc/tst-tlsopt-powerpc.c: New tls test.
	* sysdeps/unix/sysv/linux/powerpc/Makefile: Add new test.
	Build tst-tlsmod2.so with --no-tls-get-addr-optimize.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/ld.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/ld.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/ld-le.abilist: Likewise.
2015-03-25 15:53:47 +10:30
Florian Weimer 98734cc501 pthread_setaffinity (Linux variant): Rewrite to use VLA instead of alloca
extend_alloca was used to emulate VLA deallocation.  The new version
also handles the res == 0 corner case more explicitly, by returning 0
instead of the (potentially undefined, but usually zero) system call
error.
2015-03-23 16:34:48 +01:00
Alan Modra 59261ad3eb Remove HAVE_ASM_PPC_REL16 references
In bc0cdc498 the configure check for HAVE_ASM_PPC_REL16 was removed
on the grounds that the minimum binutils supports rel16 relocs.  This
is true, but not all references to HAVE_ASM_PPC_REL16 in the sources
were removed.

	* config.h.in: Remove HAVE_ASM_PPC_REL16.
	* sysdeps/powerpc/powerpc32/tls-macros.h: Remove HAVE_ASM_PPC_REL16
	and false branch of conditional.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext-common.S:
	Likewise.
2015-03-23 15:33:59 +10:30
Chris Metcalf becb26b84b linux-generic: add a README 2015-03-19 13:33:01 -04:00
Stefan Liebler 2e807f2959 S/390: Fix setcontext/swapcontext which are not restoring sigmask. 2015-03-12 11:08:11 +01:00
Adhemerval Zanella 5ca10a0c9a powerpc: Remove HAVE_ASM_GLOBAL_DOT_NAME define
With AIX port deprecated there is no need to check/define
HAVE_ASM_GLOBAL_DOT_NAME anymore since the current minimum binutils
supported (2.22) does not emit global symbol with dot.

This patch removes all the HAVE_ASM_GLOBAL_DOT_NAME definition and
checks for powerpc64 port.
2015-03-11 09:01:05 -04:00
Joseph Myers 6d08b0223a Correct __ASSUME_PRLIMIT64 for hppa/microblaze/sh (bug 17779).
__ASSUME_PRLIMIT64 is defined in kernel-features.h for kernels 2.6.36
and later, but hppa, microblaze and sh did not add the prlimit64
syscall until 2.6.37.  This patch adds corresponding undefines of
__ASSUME_PRLIMIT64 to those architectures' kernel-features.h files.

(This concludes the kernel-features.h fixes arising out of the review
- limited to macros defined in the architecture-independent
kernel-features.h file - I did in connection with the move to 2.6.32
minimum kernel version.  For that subset of macros - I didn't check
any purely architecture-specific macros - I think they are now defined
for the correct kernel versions on each architecture after this
patch.)

	[BZ #17779]
	* sysdeps/unix/sysv/linux/hppa/kernel-features.h
	[__LINUX_KERNEL_VERSION < 0x020625] (__ASSUME_PRLIMIT64):
	Undefine.
	* sysdeps/unix/sysv/linux/microblaze/kernel-features.h
	[__LINUX_KERNEL_VERSION < 0x020625] (__ASSUME_PRLIMIT64):
	Likewise.
	* sysdeps/unix/sysv/linux/sh/kernel-features.h
	[__LINUX_KERNEL_VERSION < 0x020625] (__ASSUME_PRLIMIT64):
	Likewise.
2015-03-02 23:05:55 +00:00
John David Anglin 49f476f479 hppa: fix __O_SYNC to match the kernel 2015-02-27 01:46:01 -05:00
Cong Wang cb43bb0d68 in.h: Coordinate in6_pktinfo and ip6_mtuinfo for kernel and glibc [BZ #15850]
Similarly to what we did for in6_addr, we need a macro
to guard in6_pktinfo and ip6_mtuinfo too.

Cc: Carlos O'Donell <carlos@redhat.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
2015-02-25 00:13:28 -05:00
Miroslav Lichvar b433df00ae Update timex.h for ADJ_SETOFFSET.
ADJ_SETOFFSET is a new adjtimex() mode that can be used to precisely
step the clock. It was introduced in kernel 2.6.39.
2015-02-24 23:53:30 -05:00
Eric Rannaud 65f6f938cd linux: open and openat ignore 'mode' with O_TMPFILE in flags
Both open and openat load their last argument 'mode' lazily, using
va_arg() only if O_CREAT is found in oflag. This is wrong, mode is also
necessary if O_TMPFILE is in oflag.

By chance on x86_64, the problem wasn't evident when using O_TMPFILE
with open, as the 3rd argument of open, even when not loaded with
va_arg, is left untouched in RDX, where the syscall expects it.

However, openat was not so lucky, and O_TMPFILE couldn't be used: mode
is the 4th argument, in RCX, but the syscall expects its 4th argument in
a different register than the glibc wrapper, in R10.

Introduce a macro __OPEN_NEEDS_MODE (oflag) to test if either O_CREAT or
O_TMPFILE is set in oflag.

Tested on Linux x86_64.

	[BZ #17523]
	* io/fcntl.h (__OPEN_NEEDS_MODE): New macro.
	* io/bits/fcntl2.h (open): Use it.
	(openat): Likewise.
	* io/open.c (__libc_open): Likewise.
	* io/open64.c (__libc_open64): Likewise.
	* io/open64_2.c (__open64_2): Likewise.
	* io/open_2.c (__open_2): Likewise.
	* io/openat.c (__openat): Likewise.
	* io/openat64.c (__openat64): Likewise.
	* io/openat64_2.c (__openat64_2): Likewise.
	* io/openat_2.c (__openat_2): Likewise.
	* sysdeps/mach/hurd/open.c (__libc_open): Likewise.
	* sysdeps/mach/hurd/openat.c (__openat): Likewise.
	* sysdeps/posix/open64.c (__libc_open64): Likewise.
	* sysdeps/unix/sysv/linux/dl-openat64.c (openat64): Likewise.
	* sysdeps/unix/sysv/linux/generic/open.c (__libc_open): Likewise.
	(__open_nocancel): Likewise.
	* sysdeps/unix/sysv/linux/generic/open64.c (__libc_open64): Likewise.
	* sysdeps/unix/sysv/linux/open64.c (__libc_open64): Likewise.
	* sysdeps/unix/sysv/linux/openat.c (__OPENAT): Likewise.
2015-02-24 13:19:22 +05:30
Mike Frysinger cda700b4c8 hppa: fix build failure with RTLD_PRIVATE_ERRNO
Pull in dl-sysdep.h like every other linux sysdep.h header does when it
wants to use RTLD_PRIVATE_ERRNO.
2015-02-24 00:10:42 -05:00
Stefan Liebler 7133957fe8 s390: Use generic lowlevellock-futex.h
* sysdeps/unix/sysv/linux/s390/lowlevellock.h: Include
      <sysdeps/nptl/lowlevellock.h> and remove macros and
      functions that are now defined there.
      (SYS_futex): Remove.
      (lll_compare_and_swap): Remove.
      * sysdeps/s390/bits/atomic.h (atomic_exchange_acq): Define.
2015-02-20 10:48:06 +01:00
Steve Ellcey 9ee16d8b34 2015-02-18 Steve Ellcey <sellcey@imgtec.com>
* sysdeps/unix/sysv/linux/mips/bits/endian.h: Remove.
	* sysdeps/mips/bits/endian.h: Fix comments.
2015-02-18 10:51:37 -08:00
Joseph Myers 1a2325c06c Fix posix_spawn getrlimit64 namespace (bug 17991).
posix_spawn (a standard POSIX function) brings in a use of getrlimit64
(not a standard POSIX function).  This patch fixes this by using
__getrlimit64 and making getrlimit64 a weak alias.

This is more complicated than some such changes because of files that
define getrlimit64 in their own way using symbol versioning after
including the main sysdeps/unix/sysv/linux/getrlimit64.c with a
getrlimit macro defined.  There are various existing patterns for such
cases in glibc; the one I've used here is that a getrlimit64 macro
disables the weak_alias / libc_hidden_weak calls, leaving it to the
including file to define the getrlimit64 name in whatever way is
appropriate.

Tested for x86_64 and x86 that installed stripped shared libraries are
unchanged by this patch.

	[BZ #17991]
	* include/sys/resource.h (__getrlimit64): Declare.  Use
	libc_hidden_proto.
	* resource/getrlimit64.c (getrlimit64): Rename to __getrlimit64
	and define as weak alias of __getrlimit64.  Use libc_hidden_weak.
	* sysdeps/posix/spawni.c (__spawni): Call __getrlimit64 instead of
	getrlimit64.
	* sysdeps/unix/sysv/linux/getrlimit64.c (getrlimit64): Rename to
	__getrlimit64.
	[!getrlimit64] (getrlimit64): Define as weak alias of
	__getrlimit64.  Use libc_hidden_weak.
	* sysdeps/unix/sysv/linux/i386/getrlimit64.c (getrlimit64): Define
	using __getrlimit64 not __new_getrlimit64.
	(__GI_getrlimit64): Likewise.
	* sysdeps/unix/sysv/linux/mips/getrlimit64.c (getrlimit64):
	Likewise.
	(__GI_getrlimit64): Likewise.
	(__old_getrlimit64): Use __getrlimit64 not __new_getrlimit64.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list
	(getrlimit): Add __getrlimit64 alias.
	* sysdeps/unix/sysv/linux/wordsize-64/syscalls.list (getrlimit):
	Likewise.
	* conform/Makefile (test-xfail-XOPEN2K/spawn.h/linknamespace):
	Remove variable.
	(test-xfail-POSIX2008/spawn.h/linknamespace): Likewise.
	(test-xfail-XOPEN2K8/spawn.h/linknamespace): Likewise.
2015-02-18 00:26:35 +00:00
Stefan Liebler f20bfc9b5e S390: Build failure due to nptl/pt-longjmp.c changes. 2015-02-17 08:47:49 +01:00
Torvald Riegel 71c06b69d3 ia64: Remove custom lowlevellock.h
ia64 seems to use the same implementation of low-level locks as the
generic Linux lowlevellock.h.  The futex syscalls are somewhat
different, but Roland thought it shouldn't matter.  Note that the futex
calls are on the slow path always (except for PI mutexes).

Removing the custom low-level lock implementation will make further
refactoring easier, for example adding proper error checking to futex
operations.
2015-02-17 02:45:12 -05:00
Mike Frysinger a9a05adb24 ia64: drop custom getpagesize
This is equivalent to the common linux version now, so we can drop it.
2015-02-17 02:37:20 -05:00