diff options
Diffstat (limited to 'libc/sysdeps')
24 files changed, 160 insertions, 91 deletions
diff --git a/libc/sysdeps/linux/common-generic/bits/kernel_stat.h b/libc/sysdeps/linux/common-generic/bits/kernel_stat.h index 7a97bb4d7..e874a4a9f 100644 --- a/libc/sysdeps/linux/common-generic/bits/kernel_stat.h +++ b/libc/sysdeps/linux/common-generic/bits/kernel_stat.h @@ -18,7 +18,7 @@ * However that requires more #ifndef in relevant wrappers, * further uglifying them */ -#define kernel_stat64 stat +#define kernel_stat64 stat64 #endif /* _BITS_STAT_STRUCT_H */ diff --git a/libc/sysdeps/linux/common/adjtimex.c b/libc/sysdeps/linux/common/adjtimex.c index f45d54371..2fd7977f6 100644 --- a/libc/sysdeps/linux/common/adjtimex.c +++ b/libc/sysdeps/linux/common/adjtimex.c @@ -9,8 +9,16 @@ #include <sys/syscall.h> #include <sys/timex.h> - +#if defined(__NR_adjtimex) _syscall1(int, adjtimex, struct timex *, buf) +#else +#include <time.h> +int adjtimex(struct timex *buf) +{ + return clock_adjtime(CLOCK_REALTIME, buf); +} +#endif + libc_hidden_def(adjtimex) weak_alias(adjtimex,__adjtimex) #if defined __UCLIBC_NTP_LEGACY__ diff --git a/libc/sysdeps/linux/common/bits/stab.def b/libc/sysdeps/linux/common/bits/stab.def index 8a2b8f39d..8d16c5c2c 100644 --- a/libc/sysdeps/linux/common/bits/stab.def +++ b/libc/sysdeps/linux/common/bits/stab.def @@ -17,7 +17,7 @@ <http://www.gnu.org/licenses/>. */ /* This contains contribution from Cygnus Support. */ - + /* Global variable. Only the name is significant. To find the address, look in the corresponding external symbol. */ __define_stab (N_GSYM, 0x20, "GSYM") @@ -177,7 +177,7 @@ __define_stab (N_NBLCS, 0xF8, "NBLCS") /* Second symbol entry containing a length-value for the preceding entry. The value is the length. */ __define_stab (N_LENG, 0xfe, "LENG") - + /* The above information, in matrix format. STAB MATRIX diff --git a/libc/sysdeps/linux/common/clock_gettime.c b/libc/sysdeps/linux/common/clock_gettime.c index 4d787b9b7..b924d860b 100644 --- a/libc/sysdeps/linux/common/clock_gettime.c +++ b/libc/sysdeps/linux/common/clock_gettime.c @@ -11,10 +11,14 @@ #include <sys/syscall.h> #include <time.h> +#ifdef __VDSO_SUPPORT__ +#include "ldso.h" +#endif + #if defined(__UCLIBC_USE_TIME64__) && defined(__NR_clock_gettime64) #include "internal/time64_helpers.h" -int clock_gettime(clockid_t clock_id, struct timespec *tp) +int __libc_clock_gettime(clockid_t clock_id, struct timespec *tp) { struct __ts64_struct __ts64; int __ret = INLINE_SYSCALL(clock_gettime64, 2, clock_id, &__ts64); @@ -26,11 +30,14 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp) return __ret; } #elif defined(__NR_clock_gettime) -_syscall2(int, clock_gettime, clockid_t, clock_id, struct timespec*, tp) +int __libc_clock_gettime(clockid_t clock_id, struct timespec *tp) +{ + return INLINE_SYSCALL(clock_gettime, 2, clock_id, tp); +} #else # include <sys/time.h> -int clock_gettime(clockid_t clock_id, struct timespec* tp) +int __libc_clock_gettime(clockid_t clock_id, struct timespec* tp) { struct timeval tv; int retval = -1; @@ -53,3 +60,12 @@ int clock_gettime(clockid_t clock_id, struct timespec* tp) return retval; } #endif + +int clock_gettime(clockid_t clock_id, struct timespec *tp) +{ +#if defined(__VDSO_SUPPORT__) && defined(ARCH_VDSO_CLOCK_GETTIME) + return ARCH_VDSO_CLOCK_GETTIME(clock_id, tp); +#else + return __libc_clock_gettime(clock_id, tp); +#endif +} diff --git a/libc/sysdeps/linux/common/futimens.c b/libc/sysdeps/linux/common/futimens.c index 03e58f4b5..2f3d72420 100644 --- a/libc/sysdeps/linux/common/futimens.c +++ b/libc/sysdeps/linux/common/futimens.c @@ -8,7 +8,7 @@ #include <sys/syscall.h> #include <time.h> -#ifdef __NR_utimensat +#if defined(__NR_utimensat) || defined(__NR_utimensat_time64) /* To avoid superfluous warnings about passing NULL to the non-null annotated * 2nd param "__path" below, we bypass inclusion of sys/stat.h and use * a non annotated, local decl. diff --git a/libc/sysdeps/linux/common/futimesat.c b/libc/sysdeps/linux/common/futimesat.c index fd19fea7c..bf36550dd 100644 --- a/libc/sysdeps/linux/common/futimesat.c +++ b/libc/sysdeps/linux/common/futimesat.c @@ -7,6 +7,7 @@ */ #include <sys/syscall.h> +#include <sys/stat.h> #include <sys/time.h> #ifdef __NR_futimesat diff --git a/libc/sysdeps/linux/common/gettimeofday.c b/libc/sysdeps/linux/common/gettimeofday.c index ed18b2be5..9b29fe5a0 100755 --- a/libc/sysdeps/linux/common/gettimeofday.c +++ b/libc/sysdeps/linux/common/gettimeofday.c @@ -14,30 +14,18 @@ #include "ldso.h" #endif -#ifdef __VDSO_SUPPORT__ -typedef int (*gettimeofday_func)(struct timeval * tv, __timezone_ptr_t tz); -#endif - int gettimeofday(struct timeval * tv, __timezone_ptr_t tz) { - - #ifdef __VDSO_SUPPORT__ - if ( _dl__vdso_gettimeofday != 0 ){ - gettimeofday_func func= _dl__vdso_gettimeofday; - return func( tv, tz ); - - }else{ - _syscall2_body(int, gettimeofday, struct timeval *, tv, __timezone_ptr_t, tz) - } - #else - if (!tv) - return 0; - - struct timespec __ts; - int __ret = clock_gettime(CLOCK_REALTIME, &__ts); - tv->tv_sec = __ts.tv_sec; - tv->tv_usec = (suseconds_t)__ts.tv_nsec / 1000; - return __ret; - #endif + if (!tv) + return 0; +#if defined(__VDSO_SUPPORT__) && defined(ARCH_VDSO_GETTIMEOFDAY) + return ARCH_VDSO_GETTIMEOFDAY(tv, tz); +#else + struct timespec __ts; + int __ret = clock_gettime(CLOCK_REALTIME, &__ts); + tv->tv_sec = __ts.tv_sec; + tv->tv_usec = (suseconds_t)__ts.tv_nsec / 1000; + return __ret; +#endif } diff --git a/libc/sysdeps/linux/common/not-cancel.h b/libc/sysdeps/linux/common/not-cancel.h index 9d1588494..e4fb1d7fe 100644 --- a/libc/sysdeps/linux/common/not-cancel.h +++ b/libc/sysdeps/linux/common/not-cancel.h @@ -113,9 +113,9 @@ extern __typeof(pause) __pause_nocancel; #ifdef __NR_nanosleep # define nanosleep_not_cancel(requested_time, remaining) \ INLINE_SYSCALL (nanosleep, 2, requested_time, remaining) -/*#else +#else # define nanosleep_not_cancel(requested_time, remaining) \ - __nanosleep_nocancel (requested_time, remaining)*/ + __nanosleep_nocancel (requested_time, remaining) #endif #if 0 diff --git a/libc/sysdeps/linux/common/pselect.c b/libc/sysdeps/linux/common/pselect.c index 7a446a589..f9d16d6c8 100644 --- a/libc/sysdeps/linux/common/pselect.c +++ b/libc/sysdeps/linux/common/pselect.c @@ -34,7 +34,7 @@ static int __NC(pselect)(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, const struct timespec *timeout, const sigset_t *sigmask) { -#ifdef __NR_pselect6 +#if defined(__NR_pselect6) || defined(__NR_pselect6_time64) /* The Linux kernel can in some situations update the timeout value. * We do not want that so use a local variable. */ diff --git a/libc/sysdeps/linux/common/utimes.c b/libc/sysdeps/linux/common/utimes.c index e6fc578f3..a28594dfd 100644 --- a/libc/sysdeps/linux/common/utimes.c +++ b/libc/sysdeps/linux/common/utimes.c @@ -9,7 +9,7 @@ #include <sys/syscall.h> #include <sys/time.h> -#if defined __NR_utimensat && !defined __NR_utimes +#if (defined (__NR_utimensat) || defined(__NR_utimensat_time64)) && !defined __NR_utimes # include <fcntl.h> # include <stddef.h> int utimes(const char *file, const struct timeval tvp[2]) @@ -50,6 +50,6 @@ int utimes(const char *file, const struct timeval tvp[2]) } #endif -#if defined __NR_utimensat || defined __NR_utimes || defined __NR_utime +#if defined __NR_utimensat || defined __NR_utimensat_time64 || defined __NR_utimes || defined __NR_utime libc_hidden_def(utimes) #endif diff --git a/libc/sysdeps/linux/common/wait4.c b/libc/sysdeps/linux/common/wait4.c index cd042d5e7..486ffaab8 100644 --- a/libc/sysdeps/linux/common/wait4.c +++ b/libc/sysdeps/linux/common/wait4.c @@ -10,6 +10,7 @@ #include <sys/wait.h> #include <sys/resource.h> +#if defined(__NR_wait4) # define __NR___syscall_wait4 __NR_wait4 static __always_inline _syscall4(int, __syscall_wait4, __kernel_pid_t, pid, int *, status, int, opts, struct rusage *, rusage) @@ -32,6 +33,59 @@ pid_t __wait4_nocancel(pid_t pid, int *status, int opts, struct rusage *rusage) return __syscall_wait4(pid, status, opts, rusage); #endif } + +#else +pid_t __wait4_nocancel(pid_t pid, int *status, int opts, struct rusage *rusage) +{ + idtype_t type; + int __res; + siginfo_t info; + + info.si_pid = 0; + + if (pid < -1) { + type = P_PGID; + pid = -pid; + } else if (pid == -1) { + type = P_ALL; + } else if (pid == 0) { + type = P_PGID; + } else { + type = P_PID; + } + + __res = INLINE_SYSCALL(waitid, 5, type, pid, &info, opts|WEXITED, rusage); + + if ( __res < 0 ) + return __res; + + if (info.si_pid && status) { + int sw = 0; + switch (info.si_code) { + case CLD_CONTINUED: + sw = 0xffff; + break; + case CLD_DUMPED: + sw = (info.si_status & 0x7f) | 0x80; + break; + case CLD_EXITED: + sw = (info.si_status & 0xff) << 8; + break; + case CLD_KILLED: + sw = info.si_status & 0x7f; + break; + case CLD_STOPPED: + case CLD_TRAPPED: + sw = (info.si_status << 8) + 0x7f; + break; + } + *status = sw; + } + + return info.si_pid; +} +#endif + #ifdef __USE_BSD strong_alias(__wait4_nocancel,wait4) #endif diff --git a/libc/sysdeps/linux/csky/bits/uClibc_arch_features.h b/libc/sysdeps/linux/csky/bits/uClibc_arch_features.h index 3f5dab80c..1b866cb90 100644 --- a/libc/sysdeps/linux/csky/bits/uClibc_arch_features.h +++ b/libc/sysdeps/linux/csky/bits/uClibc_arch_features.h @@ -17,9 +17,6 @@ /* can your target use syscall6() for mmap ? */ #undef __UCLIBC_MMAP_HAS_6_ARGS__ -/* does your target use statx */ -#define __UCLIBC_HAVE_STATX__ - #ifdef __CSKYABIV2__ #undef __UCLIBC_SYSCALL_ALIGN_64BIT__ #else diff --git a/libc/sysdeps/linux/i386/sigaction.c b/libc/sysdeps/linux/i386/sigaction.c index cf6daa787..515ef99f2 100644 --- a/libc/sysdeps/linux/i386/sigaction.c +++ b/libc/sysdeps/linux/i386/sigaction.c @@ -31,15 +31,16 @@ extern void restore_rt(void) __asm__ ("__restore_rt") attribute_hidden; extern void restore(void) __asm__ ("__restore") attribute_hidden; -/* If ACT is not NULL, change the action for SIG to *ACT. +/* If ACT is not NULL, change mask, handler and flags for SIG to ACT's If OACT is not NULL, put the old action for SIG in *OACT. */ int __libc_sigaction(int sig, const struct sigaction *act, struct sigaction *oact) { struct sigaction kact; if (act) { - memcpy(&kact, act, sizeof(kact)); - kact.sa_flags |= SA_RESTORER; + memcpy(&kact.sa_mask, &act->sa_mask, sizeof(sigset_t)); + kact.sa_handler = act->sa_handler; + kact.sa_flags = act->sa_flags; kact.sa_restorer = (act->sa_flags & SA_SIGINFO) ? &restore_rt : &restore; act = &kact; } diff --git a/libc/sysdeps/linux/riscv32/crt1.S b/libc/sysdeps/linux/riscv32/crt1.S index 15aa0763c..5e33046d4 100644 --- a/libc/sysdeps/linux/riscv32/crt1.S +++ b/libc/sysdeps/linux/riscv32/crt1.S @@ -45,9 +45,6 @@ .globl _start .type _start,%function - .weak _init - .weak _fini - _start: call .Lload_gp mv a5, a0 /* rtld_fini. */ @@ -55,9 +52,9 @@ _start: la a0, main REG_L a1, 0(sp) /* argc. */ addi a2, sp, SZREG /* argv. */ + mv a3, zero + mv a4, zero andi sp, sp, ALMASK /* Align stack. */ - lla a3, _init - lla a4, _fini mv a6, sp /* stack_end. */ tail __uClibc_main@plt diff --git a/libc/sysdeps/linux/riscv32/jmpbuf-unwind.h b/libc/sysdeps/linux/riscv32/jmpbuf-unwind.h index 2e5f37f10..fb5d65ddd 100644 --- a/libc/sysdeps/linux/riscv32/jmpbuf-unwind.h +++ b/libc/sysdeps/linux/riscv32/jmpbuf-unwind.h @@ -23,8 +23,8 @@ /* Test if longjmp to JMPBUF would unwind the frame containing a local variable at ADDRESS. */ -#define _JMPBUF_UNWINDS(jmpbuf, address, demangle) \ - ((void *) (address) < (void *) demangle ((jmpbuf)[0].__sp)) +#define _JMPBUF_UNWINDS(jmpbuf, address) \ + ((void *) (address) < (void *) ((jmpbuf)[0].__sp)) #define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \ _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj) @@ -33,9 +33,6 @@ static inline uintptr_t __attribute__ ((unused)) _jmpbuf_sp (__jmp_buf regs) { uintptr_t sp = regs[0].__sp; -#ifdef PTR_DEMANGLE - PTR_DEMANGLE (sp); -#endif return sp; } diff --git a/libc/sysdeps/linux/riscv64/crt1.S b/libc/sysdeps/linux/riscv64/crt1.S index 15aa0763c..5e33046d4 100644 --- a/libc/sysdeps/linux/riscv64/crt1.S +++ b/libc/sysdeps/linux/riscv64/crt1.S @@ -45,9 +45,6 @@ .globl _start .type _start,%function - .weak _init - .weak _fini - _start: call .Lload_gp mv a5, a0 /* rtld_fini. */ @@ -55,9 +52,9 @@ _start: la a0, main REG_L a1, 0(sp) /* argc. */ addi a2, sp, SZREG /* argv. */ + mv a3, zero + mv a4, zero andi sp, sp, ALMASK /* Align stack. */ - lla a3, _init - lla a4, _fini mv a6, sp /* stack_end. */ tail __uClibc_main@plt diff --git a/libc/sysdeps/linux/sparc/Makefile.arch b/libc/sysdeps/linux/sparc/Makefile.arch index d34624f36..c9529b344 100644 --- a/libc/sysdeps/linux/sparc/Makefile.arch +++ b/libc/sysdeps/linux/sparc/Makefile.arch @@ -6,7 +6,7 @@ # CSRC-y := brk.c __syscall_error.c sigaction.c -SSRC-y := __longjmp.S setjmp.S bsd-setjmp.S bsd-_setjmp.S \ +SSRC-y := __longjmp.S setjmp.S sigreturn_stub.S bsd-setjmp.S bsd-_setjmp.S \ syscall.S urem.S udiv.S umul.S sdiv.S rem.S pipe.S fork.S vfork.S clone.S CSRC-$(UCLIBC_HAS_CONTEXT_FUNCS) += makecontext.c diff --git a/libc/sysdeps/linux/sparc/sigaction.c b/libc/sysdeps/linux/sparc/sigaction.c index 7895e3acd..447943e3a 100644 --- a/libc/sysdeps/linux/sparc/sigaction.c +++ b/libc/sysdeps/linux/sparc/sigaction.c @@ -30,8 +30,8 @@ _syscall5(int, rt_sigaction, int, a, int, b, int, c, int, d, int, e) -static void __rt_sigreturn_stub(void); -static void __sigreturn_stub(void); +void __rt_sigreturn_stub(void); +void __sigreturn_stub(void); int __libc_sigaction(int sig, const struct sigaction *act, struct sigaction *oact) { @@ -75,24 +75,3 @@ libc_hidden_weak(sigaction) # endif #endif - -static void -__rt_sigreturn_stub(void) -{ - __asm__( - "mov %0, %%g1\n\t" - "ta 0x10\n\t" - : /* no outputs */ - : "i" (__NR_rt_sigreturn) - ); -} -static void -__sigreturn_stub(void) -{ - __asm__( - "mov %0, %%g1\n\t" - "ta 0x10\n\t" - : /* no outputs */ - : "i" (__NR_sigreturn) - ); -} diff --git a/libc/sysdeps/linux/sparc/sigreturn_stub.S b/libc/sysdeps/linux/sparc/sigreturn_stub.S new file mode 100644 index 000000000..33f51409b --- /dev/null +++ b/libc/sysdeps/linux/sparc/sigreturn_stub.S @@ -0,0 +1,14 @@ +#include <sysdep.h> + + nop + nop + +ENTRY_NOCFI (__rt_sigreturn_stub) + mov __NR_rt_sigreturn, %g1 + ta 0x10 +END_NOCFI (__rt_sigreturn_stub) + +ENTRY_NOCFI (__sigreturn_stub) + mov __NR_sigreturn, %g1 + ta 0x10 +END_NOCFI (__sigreturn_stub) diff --git a/libc/sysdeps/linux/sparc/sysdep.h b/libc/sysdeps/linux/sparc/sysdep.h index c3897ec08..761d21454 100644 --- a/libc/sysdeps/linux/sparc/sysdep.h +++ b/libc/sysdeps/linux/sparc/sysdep.h @@ -17,6 +17,15 @@ C_LABEL(name) \ cfi_startproc; +#define ENTRY_NOCFI(name) \ + .align 4; \ + .global C_SYMBOL_NAME(name); \ + .type name, @function; \ +C_LABEL(name) + +#define END_NOCFI(name) \ + .size name, . - name + #define END(name) \ cfi_endproc; \ .size name, . - name diff --git a/libc/sysdeps/linux/sparc64/Makefile.arch b/libc/sysdeps/linux/sparc64/Makefile.arch index 37b539b3b..cc4000b78 100644 --- a/libc/sysdeps/linux/sparc64/Makefile.arch +++ b/libc/sysdeps/linux/sparc64/Makefile.arch @@ -5,7 +5,7 @@ CSRC-y := __syscall_error.c sigaction.c SSRC-y := __longjmp.S setjmp.S bsd-setjmp.S bsd-_setjmp.S brk.S fork.S \ - syscall.S pipe.S vfork.S clone.S + syscall.S pipe.S vfork.S clone.S sigreturn_stub.S CSRC-y += $(addprefix soft-fp/, \ qp_add.c qp_cmp.c qp_cmpe.c qp_div.c qp_dtoq.c qp_feq.c qp_fge.c \ diff --git a/libc/sysdeps/linux/sparc64/sigaction.c b/libc/sysdeps/linux/sparc64/sigaction.c index d8aaad0fb..b28fa659a 100644 --- a/libc/sysdeps/linux/sparc64/sigaction.c +++ b/libc/sysdeps/linux/sparc64/sigaction.c @@ -26,7 +26,7 @@ /* SPARC 64bit userland requires a kernel that has rt signals anyway. */ -static void __rt_sigreturn_stub (void); +void __rt_sigreturn_stub (void); int __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact) { @@ -67,11 +67,3 @@ libc_hidden_weak(sigaction) # endif #endif -static void -__rt_sigreturn_stub (void) -{ - __asm__ ("mov %0, %%g1\n\t" - "ta 0x6d\n\t" - : /* no outputs */ - : "i" (__NR_rt_sigreturn)); -} diff --git a/libc/sysdeps/linux/sparc64/sigreturn_stub.S b/libc/sysdeps/linux/sparc64/sigreturn_stub.S new file mode 100644 index 000000000..a5c9bb47f --- /dev/null +++ b/libc/sysdeps/linux/sparc64/sigreturn_stub.S @@ -0,0 +1,10 @@ +#include <sysdep.h> + + nop + nop + +ENTRY_NOCFI (__rt_sigreturn_stub) + mov __NR_rt_sigreturn, %g1 + ta 0x6d +END_NOCFI (__rt_sigreturn_stub) + diff --git a/libc/sysdeps/linux/sparc64/sysdep.h b/libc/sysdeps/linux/sparc64/sysdep.h index 31008c34b..5a4c36348 100644 --- a/libc/sysdeps/linux/sparc64/sysdep.h +++ b/libc/sysdeps/linux/sparc64/sysdep.h @@ -83,6 +83,15 @@ C_LABEL(name) \ cfi_endproc; \ .size name, . - name +#define ENTRY_NOCFI(name) \ + .align 4; \ + .global C_SYMBOL_NAME(name); \ + .type name, @function; \ +C_LABEL(name) + +#define END_NOCFI(name) \ + .size name, . - name + #define LOC(name) .L##name #undef PSEUDO |