summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/xtensa
AgeCommit message (Collapse)Author
2021-02-19fcntl.h: Make F_DUPFD_CLOEXEC if _USE_XOPEN2K8Paul Cercueil
The F_DUPFD_CLOEXEC flag was added in POSIX 2008.09. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
2020-08-11xtensa: add exclusive access supportMax Filippov
Add XCHAL definitions for S32C1I and EXCLUSIVE options to xtensa-config.h, include it in places that implement atomic operations and add implementations with exclusive access option opcodes. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
2020-08-11xtensa: relax memory constraint in atomic assemblyMax Filippov
Replace "a" constraints with "+m" to avoid forcing atomic variable address into a register and let the compiler use non-zero offset in load/store opcodes. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
2020-07-02Rename __unused struct members to include a namespaceEd Wildgoose
Rename various spare fields in structs to include a namespace This should avoid accidental clashes with uses of the __unused symbol in upstream projects. eg currently it causes a compile error in dhcpcd 8.x due to their re-use of the __unused symbol as a macro This follows the style of glibc which does something equivalent
2020-02-03csky: add statx conditionalsWaldemar Brodkorb
Similar to glibc commit https://sourceware.org/git/?p=glibc.git;a=commit;h=6bbfc5c09fc5b5e3d4a0cddbbd4e2e457767dae7 we need to handle Linux kernel change, which removed stat64 family from default syscall set. Signed-off-by: Waldemar Brodkorb <wbx@openadk.org> Signed-off-by: Waldemar Brodkorb <wbrodkorb@conet.de>
2019-10-30Make __syscall_error return long, as expected by syscall() callersCarlos Santos
The return type of syscall() is long so __syscall_error, which is jumped to by syscall handlers to stash an error number into errno, must return long too otherwhise it returs 4294967295L instead of -1L. For example, syscall for x86_64 is defined in libc/sysdeps/linux/x86_64/syscall.S as syscall: movq %rdi, %rax /* Syscall number -> rax. */ movq %rsi, %rdi /* shift arg1 - arg5. */ movq %rdx, %rsi movq %rcx, %rdx movq %r8, %r10 movq %r9, %r8 movq 8(%rsp),%r9 /* arg6 is on the stack. */ syscall /* Do the system call. */ cmpq $-4095, %rax /* Check %rax for error. */ jae __syscall_error /* Branch forward if it failed. */ ret /* Return to caller. */ In libc/sysdeps/linux/x86_64/__syscall_error.c, __syscall_error is defined as int __syscall_error(void) attribute_hidden; int __syscall_error(void) { register int err_no __asm__ ("%rcx"); __asm__ ("mov %rax, %rcx\n\t" "neg %rcx"); __set_errno(err_no); return -1; } So __syscall_error returns -1 as a 32-bit int in a 64-bit register, %rax (0x00000000ffffffff, whose decimal value is decimal 4294967295) and a test like this always returns false: if (syscall(number, ...) == -1) foo(); Fix the error by making __syscall_error return a long, like syscall(). The problem can be circumvented by the caller by coercing the returned value to int before comparing it to -1: if ((int) syscall(number, ...) == -1) foo(); The same problem probably occurs on other 64-bit systems but so far only x86_64 was tested, so this change must be considered experimental. Signed-off-by: Carlos Santos <unixmania@gmail.com>
2018-12-14xtensa: add custom bits/poll.hMax Filippov
Definitions of POLLWRNORM, POLLWRBAND and POLLREMOVE in xtensa linux kernel are non-standard. Provide bits/poll.h with correct values for these constants. This fixes the following strace build errors: In file included from xlat/pollflags.h:4:0, from poll.c:34: ./static_assert.h:40:24: error: static assertion failed: "POLLWRBAND != 0x0100" # define static_assert _Static_assert ^ xlat/pollflags.h:75:1: note: in expansion of macro ‘static_assert’ static_assert((POLLWRBAND) == (0x0100), "POLLWRBAND != 0x0100"); ^~~~~~~~~~~~~ ./static_assert.h:40:24: error: static assertion failed: "POLLREMOVE != 0x0800" # define static_assert _Static_assert ^ xlat/pollflags.h:117:1: note: in expansion of macro ‘static_assert’ static_assert((POLLREMOVE) == (0x0800), "POLLREMOVE != 0x0800"); ^~~~~~~~~~~~~ Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
2018-02-03bits/mman.h: consolidate header fileWaldemar Brodkorb
Sync with GNU C library and consolidate duplicate non architecture specific defines. MAP_UNINITIALIZED is only defined to 0x4000000 and used by the Linux kernel when CONFIG_MMAP_ALLOW_UNINITIALIZED is enabled. CONFIG_MMAP_ALLOW_UNINITIALIZED is only available for nommu. See Documentation/nommu-mmap.txt.
2017-07-28cleanup unused defines and includes from clone.SWaldemar Brodkorb
2017-06-21remove editor hints for viWaldemar Brodkorb
2017-06-08fcntl.h: fixup namespace for O_DIRECTORY/O_NOFOLLOW/O_CLOEXECWaldemar Brodkorb
Sync with GNU C library. Found while trying to compile linux-rdma to uClibc-ng. Reported-by: Alexey Brodkin <Alexey.Brodkin@synopsys.com>
2017-04-16libm: allow long double wrappers for all architecturesWaldemar Brodkorb
If you enable these wrappers, be sure you don't need long double precision on your embedded device, as these only enables long double warpper functions to the existing double math functions. Required to build some software as lvm2. Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
2017-02-01g/c __libc_errnomirabilos
Signed-off-by: mirabilos <m@mirbsd.org> Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
2017-01-28remove PID cachingWaldemar Brodkorb
Follow GNU C Library from c579f48edba88380635ab98cb612030e3ed8691e and remove the PID caching. These simplifies the architecture specific assembly code. The run of the test suite found no regressions, it even solves some of the test failures for x86/x86_64/sparc. Reviewed-by: Max Filippov <jcmvbkbc@gmail.com> Reviewed-by: Vineet Gupta <Vineet.Gupta1@synopsys.com> Acked-by: Matthew Fortune <Matthew.Fortune@imgtec.com> Acked-by: Alexey Brodkin <Alexey.Brodkin@synopsys.com>
2016-07-31deduplicate jmpbuf-unwind.hWaldemar Brodkorb
Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>
2016-07-17cleanup CALL_MCOUNT / PROFWaldemar Brodkorb
As this is only implemented for a few architecture and not well tested, just remove it.
2016-07-17cleanup PTR_MANGLE/PTR_DEMANGLE supportWaldemar Brodkorb
As this is only implemented for a few architecture and not well tested, just remove it. Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>
2016-04-15replace FSF addresses with URLsNikola Forró
License notices in most of the source files refer to an outdated FSF address. Replace it with URL, like in the rest of the source files.Signed-off-by: Nikola Forró <nforro@redhat.com>
2016-03-31xtensa: fix __sigsetjmp call12 caseMax Filippov
Register window saving loop in __sigsetjmp incorrectly calculates offset in the jmp_buf in case it was called with call12. The bug was introduced in commit f4b1b7ade7971141 "xtensa: fix setjmp that didn't save all registers correctly". Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
2016-02-24xtensa: fix stack unwinding over __default_sa_restorerMax Filippov
For some xtensa cores generated code gets arranged so that __default_sa_restorer immediately follows preceding function. E.g.: 40a1b: c03340 sub a3, a3, a4 40a1e: f01d retw.n 00040a20 <__default_sa_restorer>: 40a20: e1a022 movi a2, 225 40a23: 005000 syscall ... Contents of the .eh_frame section: ... 000007f4 00000014 000007f8 FDE cie=00000000 pc=0004076c..00040a20 DW_CFA_advance_loc4: 3 to 0004076f DW_CFA_def_cfa_offset: 48 Due to the way xtensa libgcc uw_frame_state_for calls _Unwind_Find_FDE for non-signal frames, FDE for the previous function is found during thread cancellation signal stack unwinding in that case. Signal stack frame is not recognized and is not unwound properly, breaking cleanup routines calling for cancelled thread. Insert padding before the __default_sa_restorer so that no FDE is found for it, MD_FALLBACK_FRAME_STATE_FOR is called by uw_frame_state_for and the frame is correctly recognized as signal frame. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
2015-12-29xtensa: fix vfork return address calculationsMax Filippov
vfork internally unwinds stack up one frame, saving the original return address in the a3 of the unwound frame. To do this in windowed ABI it needs to exchange two topmost bits of the original return address and of the helper entry point. Current code doesn't do it correctly for addresses above 0x40000000, resulting in illegal instruction exception for configurations that put code high, e.g. for noMMU. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
2015-12-07add definitions for O_PATHWaldemar Brodkorb
Only alpha, hppa and sparc need non-default value.
2015-12-05remove __UCLIBC_ASM_GLOBAL_DIRECTIVE__Waldemar Brodkorb
.globl can be used for every architecture so remove the define. Sync with GNU C library.
2015-12-05remove __UCLIBC_HAVE_ASM_GLOBAL_DOT_NAME__Waldemar Brodkorb
It's even no longer required for non-ported ppc64 architecture. Sync with GNU C library. This simplify the macros in include/libc-symbols.h.
2015-10-08xtensa: support call0 ABIMax Filippov
Most changes are mechanical replacement of 'retw' instruction with 'abi_ret' macro, defined to 'retw' or 'ret' according to ABI. Assembly code that makes calls is duplicated for call0 ABI with changed register numbers for parameters/return value and call instruction. 'entry' instructions are replaced with 'abi_entry' macro. More interesting changes: - non-leaf assembly functions (e.g. _dl_tlsdesc_dynamic, _dl_linux_resolve, SYSCALL_ERROR_HANDLER, PSEUDO) now need to preserve registers around intermediate calls they make, use temporary stack frame for that; - setjmp/longjmp only need to save and restore return address, stack pointer and callee-saved registers in the jmpbuf; - __clone and syscall functions had hardcoded offsets to parameter passed on stack, on call0 ABI they don't need stack frame, so the offset is different. Replace these offsets with FRAMESIZE macro. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
2015-06-23xtensa: add ret_ERRVAL definitionMax Filippov
ret_ERRVAL is used by mq_timedsend and mq_timedreceive, it needs to be defined to retw, otherwise error return from those functions segfaults. This fixes the following testsuite failures: .... tst-mqueue1 FAIL tst-mqueue1 got 1 expected 0 Didn't expect signal from child: got `Segmentation fault' .... tst-mqueue2 FAIL tst-mqueue2 got 1 expected 0 Didn't expect signal from child: got `Segmentation fault' .... tst-mqueue3 FAIL tst-mqueue3 got 1 expected 0 Didn't expect signal from child: got `Segmentation fault' .... tst-mqueue4 FAIL tst-mqueue4 got 1 expected 0 Didn't expect signal from child: got `Segmentation fault' .... tst-mqueue5 FAIL tst-mqueue5 got 1 expected 0 Didn't expect signal from child: got `Segmentation fault' .... tst-mqueue6 FAIL tst-mqueue6 got 1 expected 0 Didn't expect signal from child: got `Segmentation fault' Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
2015-06-23xtensa: fix stack frame size for NPTLMax Filippov
Cancellable syscalls use call8 to call functions that enable/disable cancellation, thus they cannot use the default FRAMESIZE. Redefine FRAMESIZE for such syscalls. This fixes the following testsuite failure: .... tst-mqueue8 FAIL tst-mqueue8 got 1 expected 0 going to cancel mq_receive in-time in-time mq_receive cancellation succeeded going to cancel mq_receive early Didn't expect signal from child: got `Segmentation fault' Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
2015-06-10use common ptrace.h for xtensa, fixes buildroot issues compiling enlightmentWaldemar Brodkorb
2014-09-22xtensa: add support for NPTLWaldemar Brodkorb
Changes from: https://github.com/foss-xtensa/uClibc/commits/xtensa_nptl Author: Chris Zankel <chris@zankel.net> Author: Baruch Siach <baruch@tkos.co.il>
2014-08-25fcntl.h: Define F_SETPIPE_SZ and F_GETPIPE_SZKhem Raj
Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2014-01-08xtensa: use common ptrace.hBaruch Siach
Adds support for architecture independent actions. Cc: Chris Zankel <chris@zankel.net> Signed-off-by: Baruch Siach <baruch@tkos.co.il> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2013-12-20libc/sysdeps: commonize ret_ERRVALBaruch Siach
* Add a common ret_ERRVAL definition * Remove ret_ERRVAL from architectures using the common 'ret' * Add 'undef' to architectures that need a different return instruction * Add '#include <common/sysdep.h>' to cris and ia64 that were missing it Signed-off-by: Baruch Siach <baruch@tkos.co.il> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2013-11-04xtensa: fix atomic_decrement_if_positive() return valueBaruch Siach
atomic_decrement_if_positive() returns the old value of &mem, not the (sometimes undefined) value of __tmp. Fixes the uClibc nptl/tst-sem3 test. Signed-off-by: Baruch Siach <baruch@tkos.co.il> Signed-off-by: Chris Zankel <chris@zankel.net>
2013-11-04xtensa: fix layout of struct sigcontext to match the kernelBaruch Siach
Current code breaks libgcc unwind. Signed-off-by: Baruch Siach <baruch@tkos.co.il> Signed-off-by: Chris Zankel <chris@zankel.net>
2013-04-01linux: pread/write: convert to SYSCALL_ALIGN_64BITMike Frysinger
The pread64/write64 syscalls have the 64bit register align issue for all arches. Use this new define so we can merge the powerc/xtensa versions back into the common code. SuperH is funky and also allows us to do this. We should be able to merge the mips version too, but that'll require someone to take a closer look as the current stuff doesn't look quite right. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-04-01linux: posix_fadvise: use new SYSCALL_ALIGN_64BITMike Frysinger
Now that we have a new SYSCALL_ALIGN_64BIT define for tracking the 64bit register shift behavior, use it. This allows us to delete duplicated arm/xtensa files, as well as drop a few arch ifdefs from common code. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-04-01libc: rename TRUNCATE64_HAS_4_ARGS to SYSCALL_ALIGN_64BITMike Frysinger
The reason truncate64 takes 4 args on some arches is that their ABI requires 64bit values to be aligned on register pair boundaries. Since this alignment affects more than just truncate64, rename the define to properly document its purpose. This also allows us to expand it to the other impacted syscalls (which will be done in a follow up commit). Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-02-05mman: rename MAP_UNINITIALIZE to MAP_UNINITIALIZEDBernhard Reutner-Fischer
The name was changed to include a trailing 'D' when it went into the kernel. Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2013-01-10buildsys: use kbuild styleBernhard Reutner-Fischer
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-12-05xtensa: fix setjmp that didn't save all registers correctlyChris Zankel
Setjmp was only saving the lower order of registers (a0-a3) correctly, but not the higher ones (a4-a8/a12). The change also includes additional information, and renames many of the registers, so that setjmp and longjmp look more like the inverse of each other. Signed-off-by: Chris Zankel <chris@zankel.net>
2012-11-18Replace FSF snail mail address with URLsMike Frysinger
This matches a similar change made to glibc. No functional changes here. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-11-03xtensa: add missing atomic intrinsicsChris Zankel
Add more atomic intrinsics. These are mostly non 32-bit versions, which are not support by Xtensa. This file needs some more clean-up and consolidation. Signed-off-by: Chris Zankel <chris@zankel.net>
2012-11-03xtensa: sysdep.h needs to include sys/syscall.hChris Zankel
The Xtensa version of sysdep.h didn't include sys/syscall.h. This header file is, for example, needed by not-cancel.h, which uses the INTERNAL_SYSCALL macro. Signed-off-by: Chris Zankel <chris@zankel.net>
2012-11-03xtensa: add a stub user.h fileChris Zankel
Xtensa only supports the ELF binary format, so the user.h file isn't needed. However, it's included by other files, so provide a stub user.h. Signed-off-by: Chris Zankel <chris@zankel.net>
2012-11-03xtensa: fix a misnumbered register in sigsetjmpChris Zankel
Signed-off-by: Chris Zankel <chris@zankel.net>
2012-11-03xtensa: add a set of atomic intrinsicsChris Zankel
Add a new file that provides various atomic intrinsics, which use the conditional store instruction. Signed-off-by: Chris Zankel <chris@zankel.net>
2012-11-03xtensa: add sigcontext.hChris Zankel
Signed-off-by: Chris Zankel <chris@zankel.net>
2012-10-02libc/sysdeps: add __kernel_long and __kernel_ulongChris Packham
Linux 3.4 added __kernel_long_t and __kernel_ulong_t and various exported header files were updated to use these new types. Add the definitions for __kernel_long_t and __kernel_ulong_t to the relevant kernel_types.h headers. This change was automated with the following scriptlet git grep --name-only 'typedef.*__kernel_old_dev_t' \ | xargs sed -i '/typedef.*__kernel_old_dev_t/ a\ typedef long\t\t__kernel_long_t;\ typedef unsigned long\t__kernel_ulong_t;' Whitespace in arm, avr32, hppa, sparc was then manually fixed up. Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz> -- Here's a cleaned up patch which should get the whitespace right. I'm a bit iffy about the sparc changes they make sense to me but it's not a platform I have access to. I can break this up per arch or per maintainer if requested. libc/sysdeps/linux/alpha/bits/kernel_types.h | 2 ++ libc/sysdeps/linux/arm/bits/kernel_types.h | 2 ++ libc/sysdeps/linux/avr32/bits/kernel_types.h | 2 ++ libc/sysdeps/linux/bfin/bits/kernel_types.h | 2 ++ libc/sysdeps/linux/c6x/bits/kernel_types.h | 2 ++ libc/sysdeps/linux/cris/bits/kernel_types.h | 2 ++ libc/sysdeps/linux/e1/bits/kernel_types.h | 2 ++ libc/sysdeps/linux/h8300/bits/kernel_types.h | 2 ++ libc/sysdeps/linux/hppa/bits/kernel_types.h | 2 ++ libc/sysdeps/linux/i386/bits/kernel_types.h | 2 ++ libc/sysdeps/linux/ia64/bits/kernel_types.h | 2 ++ libc/sysdeps/linux/m68k/bits/kernel_types.h | 2 ++ libc/sysdeps/linux/microblaze/bits/kernel_types.h | 2 ++ libc/sysdeps/linux/mips/bits/kernel_types.h | 4 ++++ libc/sysdeps/linux/nios2/bits/kernel_types.h | 2 ++ libc/sysdeps/linux/powerpc/bits/kernel_types.h | 4 ++++ libc/sysdeps/linux/sh/bits/kernel_types.h | 2 ++ libc/sysdeps/linux/sh64/bits/kernel_types.h | 2 ++ libc/sysdeps/linux/sparc/bits/kernel_types.h | 4 ++++ libc/sysdeps/linux/v850/bits/kernel_types.h | 2 ++ libc/sysdeps/linux/x86_64/bits/kernel_types.h | 2 ++ libc/sysdeps/linux/xtensa/bits/kernel_types.h | 2 ++ 22 files changed, 50 insertions(+) Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-06-15pread_write.c: make all archs use common codePeter S. Mazinger
c6x does not need own version at all Signed-off-by: Peter S. Mazinger <ps.m@gmx.net> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-06-15fork: provide __libc_fork only if THREADS are enabledPeter S. Mazinger
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>