From 3b96fc2ea791adfaeef265854d3a58259a0d3f19 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 22 Oct 2009 00:43:19 -0400 Subject: sysctl: avoid inline initialization Assign each field one by one rather than stack initialization as gcc will call memset() to zero out the rest of the structure -- which we don't care about as the field is unused and not seen outside of the libc. Signed-off-by: Mike Frysinger --- libc/sysdeps/linux/common/sysctl.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) (limited to 'libc/sysdeps/linux/common') diff --git a/libc/sysdeps/linux/common/sysctl.c b/libc/sysdeps/linux/common/sysctl.c index 11d53cd8e..f65a3eaa2 100644 --- a/libc/sysdeps/linux/common/sysctl.c +++ b/libc/sysdeps/linux/common/sysctl.c @@ -10,10 +10,6 @@ #include #if defined __NR__sysctl && (defined __USE_GNU || defined __USE_BSD) -/* psm: including sys/sysctl.h would depend on kernel headers */ -extern int sysctl (int *__name, int __nlen, void *__oldval, - size_t *__oldlenp, void *__newval, size_t __newlen) __THROW; - struct __sysctl_args { int *name; int nlen; @@ -24,21 +20,17 @@ struct __sysctl_args { unsigned long __unused[4]; }; -static __always_inline -_syscall1(int, _sysctl, struct __sysctl_args *, args) - int sysctl(int *name, int nlen, void *oldval, size_t * oldlenp, void *newval, size_t newlen) { - struct __sysctl_args args = { - .name = name, - .nlen = nlen, - .oldval = oldval, - .oldlenp = oldlenp, - .newval = newval, - .newlen = newlen - }; - - return _sysctl(&args); + /* avoid initializing on the stack as gcc will call memset() */ + struct __sysctl_args args; + args.name = name; + args.nlen = nlen; + args.oldval = oldval; + args.oldlenp = oldlenp; + args.newval = newval; + args.newlen = newlen; + return INLINE_SYSCALL(_sysctl, 1, &args); } #endif -- cgit v1.2.3 From 155bf12e232ca9eb16f6f21a78163cbf556f294f Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 22 Oct 2009 09:01:03 -0400 Subject: disable _POSIX_SPAWN define We don't provide spawn.h let alone any other spawn funcs/types, so don't set up the _POSIX_SPAWN define that some packages (like vlc) check. Signed-off-by: Mike Frysinger --- libc/sysdeps/linux/common/bits/posix_opt.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'libc/sysdeps/linux/common') diff --git a/libc/sysdeps/linux/common/bits/posix_opt.h b/libc/sysdeps/linux/common/bits/posix_opt.h index dfe259b7c..46d169759 100644 --- a/libc/sysdeps/linux/common/bits/posix_opt.h +++ b/libc/sysdeps/linux/common/bits/posix_opt.h @@ -128,7 +128,9 @@ #define _POSIX_SPIN_LOCKS 200112L /* The `spawn' function family is supported. */ +#if 0 /* no support in uClibc (yet) */ #define _POSIX_SPAWN 200112L +#endif /* We have POSIX timers. */ #define _POSIX_TIMERS 200112L -- cgit v1.2.3 From fa1bb23a599da9283f190ab525b971c55475f5f9 Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Wed, 18 Nov 2009 13:24:07 +0100 Subject: _Exit(): add weak alias to _exit() for C99 Signed-off-by: Bernhard Reutner-Fischer --- libc/sysdeps/linux/common/_exit.c | 1 + 1 file changed, 1 insertion(+) (limited to 'libc/sysdeps/linux/common') diff --git a/libc/sysdeps/linux/common/_exit.c b/libc/sysdeps/linux/common/_exit.c index fbeed0d8a..6cece0878 100644 --- a/libc/sysdeps/linux/common/_exit.c +++ b/libc/sysdeps/linux/common/_exit.c @@ -21,3 +21,4 @@ void attribute_noreturn _exit(int status) INLINE_SYSCALL(exit, 1, status); } libc_hidden_def(_exit) +weak_alias(_exit,_Exit) -- cgit v1.2.3 From 4c5c4502d0d6ae2e6cd495b1084a6c9d34a8cab3 Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Thu, 19 Nov 2009 18:49:24 +0100 Subject: DO_XSI_MATH: add config knob Signed-off-by: Bernhard Reutner-Fischer --- extra/Configs/Config.in.arch | 11 +++++++++++ libc/sysdeps/linux/common/bits/mathcalls.h | 2 ++ libm/Makefile.in | 8 ++++++-- 3 files changed, 19 insertions(+), 2 deletions(-) (limited to 'libc/sysdeps/linux/common') diff --git a/extra/Configs/Config.in.arch b/extra/Configs/Config.in.arch index 76ab0022f..8a02cb1a2 100644 --- a/extra/Configs/Config.in.arch +++ b/extra/Configs/Config.in.arch @@ -160,6 +160,17 @@ config DO_C99_MATH If your applications require the newer C99 math library functions, then answer Y. +config DO_XSI_MATH + bool "Enable XSI math extensions to the ISO C standard (bessel)" + depends on UCLIBC_HAS_FLOATS + default n + help + X/Open System Interfaces extensions to ISO C math functions + (differential equation functions): + + j0, j1, jn - Bessel functions of the first kind + y0, y1, yn - Bessel functions of the second kind + config UCLIBC_HAS_FENV bool "Enable C99 Floating-point environment" depends on UCLIBC_HAS_FLOATS diff --git a/libc/sysdeps/linux/common/bits/mathcalls.h b/libc/sysdeps/linux/common/bits/mathcalls.h index 811738238..df2e21cc8 100644 --- a/libc/sysdeps/linux/common/bits/mathcalls.h +++ b/libc/sysdeps/linux/common/bits/mathcalls.h @@ -244,6 +244,7 @@ __END_NAMESPACE_C99 /* Return nonzero if VALUE is not a number. */ __MATHDECL_PRIV (int,isnan,, (_Mdouble_ __value), (__const__)) +# ifdef __DO_XSI_MATH__ /* Bessel functions. */ __MATHCALL (j0,, (_Mdouble_)) __MATHCALL (j1,, (_Mdouble_)) @@ -251,6 +252,7 @@ __MATHCALL (jn,, (int, _Mdouble_)) __MATHCALL (y0,, (_Mdouble_)) __MATHCALL (y1,, (_Mdouble_)) __MATHCALL (yn,, (int, _Mdouble_)) +# endif #endif diff --git a/libm/Makefile.in b/libm/Makefile.in index d17d64fae..56b2d76c3 100644 --- a/libm/Makefile.in +++ b/libm/Makefile.in @@ -56,8 +56,8 @@ LD_MSRC := ldouble_wrappers.c ifeq ($(DO_C99_MATH),y) libm_CSRC := \ e_acos.c e_acosh.c e_asin.c e_atan2.c e_atanh.c e_cosh.c \ - e_exp.c e_fmod.c e_hypot.c e_j0.c \ - e_j1.c e_jn.c e_lgamma_r.c e_log.c e_log2.c e_log10.c \ + e_exp.c e_fmod.c e_hypot.c \ + e_lgamma_r.c e_log.c e_log2.c e_log10.c \ e_pow.c e_remainder.c e_rem_pio2.c e_scalb.c e_sinh.c \ e_sqrt.c k_cos.c k_rem_pio2.c k_sin.c k_standard.c k_tan.c \ s_asinh.c s_atan.c s_cbrt.c s_ceil.c s_copysign.c s_cos.c \ @@ -209,6 +209,10 @@ libm_CSRC := \ FL_MOBJ := sqrtf.o endif +ifeq ($(DO_XSI_MATH),y) +libm_CSRC += e_j0.c e_j1.c e_jn.c +endif + # assume that arch specific versions are provided as single sources/objects ifeq ($(UCLIBC_HAS_FPU),y) ifeq ($(DO_C99_MATH),y) -- cgit v1.2.3 From 8793e73bdbc8c9b4c4ad218bc9159eecf36ebcaa Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Thu, 19 Nov 2009 23:00:32 +0100 Subject: SUSv4: disable isascii, toascii, _toupper, _tolower [__]isascii need to be defined all the time for the build. Signed-off-by: Peter S. Mazinger Signed-off-by: Bernhard Reutner-Fischer --- include/ctype.h | 33 +++++++++++++++++---------- libc/sysdeps/linux/common/bits/uClibc_ctype.h | 2 ++ test/ctype/ctype.c | 2 ++ 3 files changed, 25 insertions(+), 12 deletions(-) (limited to 'libc/sysdeps/linux/common') diff --git a/include/ctype.h b/include/ctype.h index 2d62847fe..dcfeb1b3e 100644 --- a/include/ctype.h +++ b/include/ctype.h @@ -66,7 +66,8 @@ libc_hidden_proto(tolower) extern int toupper(int __c) __THROW; libc_hidden_proto(toupper) -#if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN +#if (defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN) && \ + defined __UCLIBC_SUSV4_LEGACY__ /* Return nonzero iff C is in the ASCII set (i.e., is no more than 7 bits wide). */ extern int isascii(int __c) __THROW; @@ -203,11 +204,12 @@ libc_hidden_proto(__ctype_tolower) #endif /* __UCLIBC_HAS_XLOCALE__ */ - +#ifdef __UCLIBC_SUSV4_LEGACY__ #define __isascii(c) (((c) & ~0x7f) == 0) /* If C is a 7 bit value. */ #define __toascii(c) ((c) & 0x7f) /* Mask off high bits. */ +#endif -#if defined _LIBC && (defined IS_IN_libc || defined NOT_IN_libc) +#ifdef _LIBC /* These are uClibc-specific. */ #define __isdigit_char(C) (((unsigned char)((C) - '0')) <= 9) #define __isdigit_int(C) (((unsigned int)((C) - '0')) <= 9) @@ -278,13 +280,12 @@ __NTH (toupper (int __c)) # define toupper(c) __tobody(c, toupper, __UCLIBC_CTYPE_TOUPPER, (c)) # endif /* Optimizing gcc */ -# if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN +# if (defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN) \ + && defined __UCLIBC_SUSV4_LEGACY__ # define isascii(c) __isascii (c) # define toascii(c) __toascii (c) -# if defined __UCLIBC_SUSV4_LEGACY__ -# define _tolower(c) ((int) (__UCLIBC_CTYPE_TOLOWER)[(int) (c)]) -# define _toupper(c) ((int) (__UCLIBC_CTYPE_TOUPPER)[(int) (c)]) -# endif +# define _tolower(c) ((int) (__UCLIBC_CTYPE_TOLOWER)[(int) (c)]) +# define _toupper(c) ((int) (__UCLIBC_CTYPE_TOUPPER)[(int) (c)]) # endif #endif /* not __cplusplus */ @@ -334,8 +335,8 @@ libc_hidden_proto(isxdigit_l) extern int isblank_l(int, __locale_t) __THROW; libc_hidden_proto(isblank_l) -# if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN - +# if (defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN) \ + && defined __UCLIBC_SUSV4_LEGACY__ /* Return nonzero iff C is in the ASCII set (i.e., is no more than 7 bits wide). */ extern int isascii_l (int __c) __THROW; @@ -378,7 +379,8 @@ libc_hidden_proto(toupper_l) # define __isxdigit_l(c,l) __isctype_l((c), _ISxdigit, (l)) # define __isblank_l(c,l) __isctype_l((c), _ISblank, (l)) -# if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN +# if (defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN) \ + && defined __UCLIBC_SUSV4_LEGACY__ # define __isascii_l(c,l) ((l), __isascii (c)) # define __toascii_l(c,l) ((l), __toascii (c)) # endif @@ -396,7 +398,8 @@ libc_hidden_proto(toupper_l) # define isxdigit_l(c,l) __isxdigit_l ((c), (l)) # define isblank_l(c,l) __isblank_l ((c), (l)) -# if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN +# if (defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN) \ + && defined __UCLIBC_SUSV4_LEGACY__ # define isascii_l(c,l) __isascii_l ((c), (l)) # define toascii_l(c,l) __toascii_l ((c), (l)) # endif @@ -409,4 +412,10 @@ __END_DECLS #endif /* __UCLIBC_HAS_CTYPE_TABLES__ */ +/* We define {__,}isascii for internal use only */ +#if defined _LIBC && !defined __UCLIBC_SUSV4_LEGACY__ +# define __isascii(c) (((c) & ~0x7f) == 0) +# define isascii(c) __isascii (c) +#endif + #endif /* ctype.h */ diff --git a/libc/sysdeps/linux/common/bits/uClibc_ctype.h b/libc/sysdeps/linux/common/bits/uClibc_ctype.h index 43371286b..22d2df03a 100644 --- a/libc/sysdeps/linux/common/bits/uClibc_ctype.h +++ b/libc/sysdeps/linux/common/bits/uClibc_ctype.h @@ -103,12 +103,14 @@ __BEGIN_DECLS /* Now some non-ansi/iso c99 macros. */ +#ifndef __UCLIBC_SUSV4_LEGACY__ #define __isascii(c) (((c) & ~0x7f) == 0) #define __toascii(c) ((c) & 0x7f) /* Works correctly *only* on lowercase letters! */ #define _toupper(c) ((c) ^ 0x20) /* Works correctly *only* on letters (of any case) and numbers */ #define _tolower(c) ((c) | 0x20) +#endif __END_DECLS diff --git a/test/ctype/ctype.c b/test/ctype/ctype.c index 352b2d2c8..f38f722b2 100644 --- a/test/ctype/ctype.c +++ b/test/ctype/ctype.c @@ -56,6 +56,7 @@ int main( int argc, char **argv) +#ifdef __UCLIBC_SUSV4_LEGACY__ /* isascii() */ { int buffer[]={ 'a', 'z', 'A', 'Z', '\n', -1}; @@ -71,6 +72,7 @@ int main( int argc, char **argv) TEST( isascii(c)==0); } } +#endif /* iscntrl() */ -- cgit v1.2.3 From 6d3ed00a41a94889854e76fd2aee0e685eba2b2e Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Fri, 20 Nov 2009 09:41:04 +0100 Subject: ppoll: get NULL from stddef.h Signed-off-by: Bernhard Reutner-Fischer --- libc/sysdeps/linux/common/ppoll.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'libc/sysdeps/linux/common') diff --git a/libc/sysdeps/linux/common/ppoll.c b/libc/sysdeps/linux/common/ppoll.c index c9efe8d08..02c8013a5 100644 --- a/libc/sysdeps/linux/common/ppoll.c +++ b/libc/sysdeps/linux/common/ppoll.c @@ -20,10 +20,10 @@ #include #include #include +#define __need_NULL +#include #if defined __NR_ppoll && defined __UCLIBC_LINUX_SPECIFIC__ - - int ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout, const sigset_t *sigmask) @@ -39,5 +39,4 @@ ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout, return INLINE_SYSCALL(ppoll, 5, fds, nfds, timeout, sigmask, _NSIG / 8); } libc_hidden_def(ppoll) - #endif -- cgit v1.2.3 From ef85033ac8e07fd45d6f45463dcfecf9c78ae7ef Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Fri, 20 Nov 2009 20:05:07 +0100 Subject: futimens: add function Signed-off-by: Bernhard Reutner-Fischer --- include/sys/stat.h | 1 + libc/sysdeps/linux/common/futimens.c | 23 +++++++++ libc/sysdeps/linux/common/utimensat.c | 2 + test/.gitignore | 2 + test/time/tst-futimens1.c | 90 +++++++++++++++++++++++++++++++++++ 5 files changed, 118 insertions(+) create mode 100644 libc/sysdeps/linux/common/futimens.c create mode 100644 test/time/tst-futimens1.c (limited to 'libc/sysdeps/linux/common') diff --git a/include/sys/stat.h b/include/sys/stat.h index d84ace5a2..170a4e633 100644 --- a/include/sys/stat.h +++ b/include/sys/stat.h @@ -375,6 +375,7 @@ extern int utimensat (int __fd, __const char *__path, __const struct timespec __times[2], int __flags) __THROW __nonnull ((2)); +libc_hidden_proto(utimensat) #endif #ifdef __USE_XOPEN2K8 diff --git a/libc/sysdeps/linux/common/futimens.c b/libc/sysdeps/linux/common/futimens.c new file mode 100644 index 000000000..090dfa69c --- /dev/null +++ b/libc/sysdeps/linux/common/futimens.c @@ -0,0 +1,23 @@ +/* vi: set sw=4 ts=4: */ +/* + * futimens() implementation for uClibc + * + * Copyright (C) 2009 Bernhard Reutner-Fischer + * + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ + +#include +#define __need_timespec +#include +#ifdef __NR_utimensat +extern int utimensat (int __fd, __const char *__path, + __const struct timespec __times[2], + int __flags) __THROW; +libc_hidden_proto(utimensat) + +int futimens (int fd, __const struct timespec ts[2]) +{ + return utimensat(fd, 0, ts, 0); +} +#endif diff --git a/libc/sysdeps/linux/common/utimensat.c b/libc/sysdeps/linux/common/utimensat.c index 3c5af8586..2cfb8247d 100644 --- a/libc/sysdeps/linux/common/utimensat.c +++ b/libc/sysdeps/linux/common/utimensat.c @@ -11,6 +11,8 @@ #ifdef __NR_utimensat _syscall4(int, utimensat, int, fd, const char *, path, const struct timespec *, times, int, flags) +libc_hidden_def(utimensat) #else /* should add emulation with utimens() and /proc/self/fd/ ... */ #endif + diff --git a/test/.gitignore b/test/.gitignore index d438af7d0..1e7cd584e 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -237,6 +237,8 @@ string/tst-strxfrm termios/termios time/clocktest time/test_time +time/tst-ftime_l +time/tst-futimens1 time/tst-mktime time/tst-mktime3 time/tst-strptime2 diff --git a/test/time/tst-futimens1.c b/test/time/tst-futimens1.c new file mode 100644 index 000000000..a452de2c7 --- /dev/null +++ b/test/time/tst-futimens1.c @@ -0,0 +1,90 @@ +/* vi: set sw=4 ts=4: */ +/* testcase + * Copyright (C) 2009 Bernhard Reutner-Fischer + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ +#include +#include +#include +#include +#include +#include +#include + +struct +{ + char *name; /* name of file to open */ + int flags; /* flags for file descriptor */ + const struct timespec ts[2]; + int err; /* expected errno */ +} tests [] = +{ + {"futimens.tst", (O_CREAT|O_TRUNC), {{0,0},{0,0}}, 0}, + {"futimens.tst", (O_CREAT|O_TRUNC), {{99,0},{0,0}}, 0}, + {"futimens.tst", (O_CREAT|O_TRUNC), {{0,99},{0,0}}, 0}, + {"futimens.tst", (O_CREAT|O_TRUNC), {{0,0},{99,0}}, 0}, + {"futimens.tst", (O_CREAT|O_TRUNC), {{0,0},{0,99}}, 0}, + {"futimens.tst", (O_CREAT|O_TRUNC), {{11,2},{3,4}}, 0}, +}; +int do_test(int argc, char **argv) { + char *name; + int i, errors; + errors = argc - argc + 0; + + for (i=0; i < (int) (sizeof(tests)/sizeof(tests[0])); ++i) { + int err, fd; + struct stat sb; + name = tests[i].name; + if (*name != '.') + unlink(name); + fd = open(name, tests[i].flags); + if (fd < 0) + abort(); + errno = 0; + err = futimens(fd, tests[i].ts); + if ((errno && !err) || (!errno && err)) { + err = errno; + printf("%s: FAILED test %d (errno and return value disagree)\n", + argv[0], i); + ++errors; + } else + err = errno; + if (err != tests[i].err) { + printf("%s: FAILED test %d (expected errno %d, got %d)\n", + argv[0], i, tests[i].err, err); + ++errors; + continue; + } + if (stat(name, &sb) < 0) { + printf("%s: FAILED test %d (verification)\n", argv[0], i); + ++errors; + continue; + } else { + unsigned wrong = tests[i].ts[0].tv_sec != sb.st_atim.tv_sec || + tests[i].ts[0].tv_nsec != sb.st_atim.tv_nsec || + tests[i].ts[1].tv_sec != sb.st_mtim.tv_sec || + tests[i].ts[1].tv_nsec != sb.st_mtim.tv_nsec; + if (wrong) { + ++errors; + if (tests[i].ts[0].tv_sec != sb.st_atim.tv_sec) + printf("%s: FAILED test %d (access time, sec: expected %ld, got %ld)\n", + argv[0], i, tests[i].ts[0].tv_sec, sb.st_atim.tv_sec); + if (tests[i].ts[0].tv_nsec != sb.st_atim.tv_nsec) + printf("%s: FAILED test %d (access time, nsec: expected %ld, got %ld)\n", + argv[0], i, tests[i].ts[0].tv_nsec, sb.st_atim.tv_nsec); + + if (tests[i].ts[1].tv_sec != sb.st_mtim.tv_sec) + printf("%s: FAILED test %d (modification time, sec: expected %ld, got %ld)\n", + argv[0], i, tests[i].ts[1].tv_sec, sb.st_mtim.tv_sec); + if (tests[i].ts[1].tv_nsec != sb.st_mtim.tv_nsec) + printf("%s: FAILED test %d (modification time, nsec: expected %ld, got %ld)\n", + argv[0], i, tests[i].ts[1].tv_nsec, sb.st_mtim.tv_nsec); + } + } + } + if (*name != '.') + unlink(name); + printf("%d errors.\n", errors); + return (!errors) ? EXIT_SUCCESS : EXIT_FAILURE; +} +#include -- cgit v1.2.3