From f51fb26dbcceee9e48d10facc830bd4a549f6cc2 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 22 Oct 2009 00:39:44 -0400 Subject: sparc: use HIDDEN_JUMPTARGET for errno Signed-off-by: Mike Frysinger --- libc/sysdeps/linux/sparc/fork.S | 2 +- libc/sysdeps/linux/sparc/pipe.S | 2 +- libc/sysdeps/linux/sparc/vfork.S | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'libc') diff --git a/libc/sysdeps/linux/sparc/fork.S b/libc/sysdeps/linux/sparc/fork.S index 00157cffd..7ead409f0 100644 --- a/libc/sysdeps/linux/sparc/fork.S +++ b/libc/sysdeps/linux/sparc/fork.S @@ -33,7 +33,7 @@ __libc_fork: bcc,a 9000f nop save %sp,-96,%sp - call __errno_location + call HIDDEN_JUMPTARGET(__errno_location) nop st %i0,[%o0] jmpl %i7+8,%g0 diff --git a/libc/sysdeps/linux/sparc/pipe.S b/libc/sysdeps/linux/sparc/pipe.S index 0226e3f5c..76a5b9617 100644 --- a/libc/sysdeps/linux/sparc/pipe.S +++ b/libc/sysdeps/linux/sparc/pipe.S @@ -52,7 +52,7 @@ pipe: restore %o0,%g0,%o0 .Lerror: - call __errno_location + call HIDDEN_JUMPTARGET(__errno_location) or %g0,EINVAL,%i0 st %i0,[%o0] ret diff --git a/libc/sysdeps/linux/sparc/vfork.S b/libc/sysdeps/linux/sparc/vfork.S index 35ca037d8..ed3e1a079 100644 --- a/libc/sysdeps/linux/sparc/vfork.S +++ b/libc/sysdeps/linux/sparc/vfork.S @@ -38,7 +38,7 @@ __vfork: bcc,a 9000f nop save %sp,-96,%sp - call __errno_location + call HIDDEN_JUMPTARGET(__errno_location) nop st %i0,[%o0] jmpl %i7+8,%g0 -- cgit v1.2.3 From bc5922f17d546bbd82644d0be03bb078bba1f85f Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 22 Oct 2009 00:39:59 -0400 Subject: sparc: use fputs to write to stderr This also has the advantage of fputs() having a hidden alias while puts does not. Signed-off-by: Mike Frysinger --- libc/sysdeps/linux/sparc/qp_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libc') diff --git a/libc/sysdeps/linux/sparc/qp_ops.c b/libc/sysdeps/linux/sparc/qp_ops.c index 5b0dc5e87..123be53fb 100644 --- a/libc/sysdeps/linux/sparc/qp_ops.c +++ b/libc/sysdeps/linux/sparc/qp_ops.c @@ -5,7 +5,7 @@ static void fakedef(void) { - puts("Unimplemented _Q* func called, exiting\n"); + fputs("Unimplemented _Q* func called, exiting\n", stderr); exit(-1); } -- cgit v1.2.3 From 829779686b0a263ad3582aecc1cc7a296c38a1c9 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 22 Oct 2009 00:41:29 -0400 Subject: inet_ntop4: avoid inline initialization We only need to set the first byte to 0, but gcc likes to zero out the rest of the string with memset() when using this initialization style. Signed-off-by: Mike Frysinger --- libc/inet/ntop.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'libc') diff --git a/libc/inet/ntop.c b/libc/inet/ntop.c index 57a0b8ccd..fa733e0ad 100644 --- a/libc/inet/ntop.c +++ b/libc/inet/ntop.c @@ -51,10 +51,12 @@ static const char * inet_ntop4(const u_char *src, char *dst, size_t size) { - char tmp[sizeof ("255.255.255.255") + 1] = "\0"; + char tmp[sizeof ("255.255.255.255") + 1]; int octet; int i; + tmp[0] = '\0'; + i = 0; for (octet = 0; octet <= 3; octet++) { -- cgit v1.2.3 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') 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 3aa584adcfa3a1ed4292d99e5fa2a6bc578f8b80 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 22 Oct 2009 01:04:07 -0400 Subject: regex: call memcpy() ourselves Call the hidden memcpy() ourselves otherwise gcc will emit a call to the public memcpy() which goes through the PLT. Signed-off-by: Mike Frysinger --- libc/misc/regex/regex_old.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libc') diff --git a/libc/misc/regex/regex_old.c b/libc/misc/regex/regex_old.c index 3550698d3..cbfb7ae7c 100644 --- a/libc/misc/regex/regex_old.c +++ b/libc/misc/regex/regex_old.c @@ -8085,7 +8085,8 @@ regexec ( int len = strlen (string); boolean want_reg_info = !preg->no_sub && nmatch > 0; - private_preg = *preg; + /* use hidden memcpy() ourselves rather than gcc calling public memcpy() */ + memcpy(&private_preg, preg, sizeof(*preg)); private_preg.not_bol = !!(eflags & REG_NOTBOL); private_preg.not_eol = !!(eflags & REG_NOTEOL); -- 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') 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 2c3ed060512a2e90ec9f912cf1a5eb1ecd700fb9 Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Sat, 14 Nov 2009 15:57:47 +0100 Subject: realpath: SUSv4 compliant Signed-off-by: Mike Frysinger Signed-off-by: Bernhard Reutner-Fischer --- include/stdlib.h | 4 +--- libc/stdlib/realpath.c | 22 ++++++++-------------- 2 files changed, 9 insertions(+), 17 deletions(-) (limited to 'libc') diff --git a/include/stdlib.h b/include/stdlib.h index e462c1c93..536f81a1e 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -659,7 +659,6 @@ extern char *canonicalize_file_name (__const char *__name) __THROW __nonnull ((1)) __wur; #endif -#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED /* Return the canonical absolute name of file NAME. If RESOLVED is null, the result is malloc'd; otherwise, if the canonical name is PATH_MAX chars or more, returns null with `errno' set to @@ -667,8 +666,7 @@ extern char *canonicalize_file_name (__const char *__name) returns the name in RESOLVED. */ /* we choose to handle __resolved==NULL as crash :) */ extern char *realpath (__const char *__restrict __name, - char *__restrict __resolved) __THROW __wur __nonnull((2)); -#endif + char *__restrict __resolved) __THROW __wur; /* Shorthand for type of comparison functions. */ diff --git a/libc/stdlib/realpath.c b/libc/stdlib/realpath.c index 1a00c3112..80c25f098 100644 --- a/libc/stdlib/realpath.c +++ b/libc/stdlib/realpath.c @@ -36,19 +36,10 @@ #define MAX_READLINKS 32 -#ifdef __STDC__ char *realpath(const char *path, char got_path[]) -#else -char *realpath(path, got_path) -const char *path; -char got_path[]; -#endif { char copy_path[PATH_MAX]; - /* use user supplied buffer directly - reduces stack usage */ - /* char got_path[PATH_MAX]; */ - char *max_path; - char *new_path; + char *max_path, *new_path, *allocated_path; size_t path_len; int readlinks = 0; #ifdef S_IFLNK @@ -72,12 +63,13 @@ char got_path[]; /* Copy so that path is at the end of copy_path[] */ strcpy(copy_path + (PATH_MAX-1) - path_len, path); path = copy_path + (PATH_MAX-1) - path_len; + allocated_path = got_path ? NULL : (got_path = malloc(PATH_MAX)); max_path = got_path + PATH_MAX - 2; /* points to last non-NUL char */ new_path = got_path; if (*path != '/') { /* If it's a relative pathname use getcwd for starters. */ if (!getcwd(new_path, PATH_MAX - 1)) - return NULL; + goto err; new_path += strlen(new_path); if (new_path[-1] != '/') *new_path++ = '/'; @@ -114,6 +106,8 @@ char got_path[]; while (*path != '\0' && *path != '/') { if (new_path > max_path) { __set_errno(ENAMETOOLONG); + err: + free(allocated_path); return NULL; } *new_path++ = *path++; @@ -122,7 +116,7 @@ char got_path[]; /* Protect against infinite loops. */ if (readlinks++ > MAX_READLINKS) { __set_errno(ELOOP); - return NULL; + goto err; } path_len = strlen(path); /* See if last (so far) pathname component is a symlink. */ @@ -133,13 +127,13 @@ char got_path[]; if (link_len < 0) { /* EINVAL means the file exists but isn't a symlink. */ if (errno != EINVAL) { - return NULL; + goto err; } } else { /* Safe sex check. */ if (path_len + link_len >= PATH_MAX - 2) { __set_errno(ENAMETOOLONG); - return NULL; + goto err; } /* Note: readlink doesn't add the null byte. */ /* copy_path[link_len] = '\0'; - we don't need it too */ -- 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') 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') 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 5f37f10508892a4180a1934764dfeb7ce0b1ff19 Mon Sep 17 00:00:00 2001 From: "Peter S. Mazinger" Date: Sat, 17 Oct 2009 02:04:20 +0200 Subject: assert: make linenumber unsigned Move attribute_noreturn to header. Signed-off-by: Peter S. Mazinger Signed-off-by: Bernhard Reutner-Fischer --- include/assert.h | 8 ++++---- libc/misc/assert/__assert.c | 7 +++---- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'libc') diff --git a/include/assert.h b/include/assert.h index 439179d8d..40b16059b 100644 --- a/include/assert.h +++ b/include/assert.h @@ -51,15 +51,15 @@ __BEGIN_DECLS /* This prints an "Assertion failed" message and aborts. */ -extern void __assert __P((const char *, const char *, int, const char *)); +extern void __assert(const char *, const char *, unsigned int, const char *) + __THROW __attribute__ ((__noreturn__)); libc_hidden_proto(__assert) __END_DECLS # define assert(expr) \ - (__ASSERT_VOID_CAST ((expr) ? 0 : \ - (__assert (__STRING(expr), __FILE__, __LINE__, \ - __ASSERT_FUNCTION), 0))) + (__ASSERT_VOID_CAST ((expr) ? 0 : \ + (__assert (__STRING(expr), __FILE__, __LINE__, __ASSERT_FUNCTION), 0))) /* Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__' which contains the name of the function currently being defined. diff --git a/libc/misc/assert/__assert.c b/libc/misc/assert/__assert.c index ff9e47dcf..18c6f5ecf 100644 --- a/libc/misc/assert/__assert.c +++ b/libc/misc/assert/__assert.c @@ -29,8 +29,6 @@ #include #include -#include -#include /* Get the prototype from assert.h as a double-check. */ @@ -43,8 +41,8 @@ static smallint in_assert; /* bss inits to 0. */ -void attribute_noreturn __assert(const char *assertion, const char * filename, - int linenumber, register const char * function) +void __assert(const char *assertion, const char * filename, + unsigned int linenumber, register const char * function) { if (!in_assert) { in_assert = 1; @@ -62,6 +60,7 @@ void attribute_noreturn __assert(const char *assertion, const char * filename, assertion ); } + /* shouldn't we? fflush(stderr); */ abort(); } -- 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') 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 a193e5a08463ea97f55cb66ccd001f156ec7aa87 Mon Sep 17 00:00:00 2001 From: "Peter S. Mazinger" Date: Sat, 17 Oct 2009 03:36:43 +0200 Subject: msgrcv is of type ssize_t Signed-off-by: Peter S. Mazinger Signed-off-by: Bernhard Reutner-Fischer --- include/sys/msg.h | 10 +++++++--- libc/misc/sysvipc/msgq.c | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'libc') diff --git a/include/sys/msg.h b/include/sys/msg.h index 1fd64b2ac..cdc96be9b 100644 --- a/include/sys/msg.h +++ b/include/sys/msg.h @@ -1,4 +1,5 @@ -/* Copyright (C) 1995,1996,1997,1999,2000,2003 Free Software Foundation, Inc. +/* Copyright (C) 1995-1997,1999,2000,2003,2006,2007 + Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -21,6 +22,9 @@ #include +#define __need_size_t +#include + /* Get common definition of System V style IPC. */ #include @@ -66,8 +70,8 @@ extern int msgget (key_t __key, int __msgflg) __THROW; This function is a cancellation point and therefore not marked with __THROW. */ -extern int msgrcv (int __msqid, void *__msgp, size_t __msgsz, - long int __msgtyp, int __msgflg); +extern ssize_t msgrcv (int __msqid, void *__msgp, size_t __msgsz, + long int __msgtyp, int __msgflg); /* Send message to message queue. diff --git a/libc/misc/sysvipc/msgq.c b/libc/misc/sysvipc/msgq.c index e43a9ed04..dac886f7f 100644 --- a/libc/misc/sysvipc/msgq.c +++ b/libc/misc/sysvipc/msgq.c @@ -43,9 +43,9 @@ struct new_msg_buf{ #ifdef L_msgrcv #ifdef __NR_msgrcv -_syscall5(int, msgrcv, int, msqid, void *, msgp, size_t, msgsz, long int, msgtyp, int, msgflg) +_syscall5(ssize_t, msgrcv, int, msqid, void *, msgp, size_t, msgsz, long int, msgtyp, int, msgflg) #else -int msgrcv (int msqid, void *msgp, size_t msgsz, +ssize_t msgrcv (int msqid, void *msgp, size_t msgsz, long int msgtyp, int msgflg) { struct new_msg_buf temp; -- cgit v1.2.3 From 9a9fe3ad32b7f42650d6acdab484782320ae8e6d Mon Sep 17 00:00:00 2001 From: "Peter S. Mazinger" Date: Sat, 17 Oct 2009 03:45:53 +0200 Subject: sync some headers and disable unused prototypes Signed-off-by: Peter S. Mazinger Signed-off-by: Bernhard Reutner-Fischer --- include/inttypes.h | 148 +++++++++++++++++++++++++++++---- include/langinfo.h | 48 +++++++---- include/locale.h | 10 +-- include/net/ethernet.h | 10 ++- include/net/if_arp.h | 10 ++- include/netinet/ether.h | 4 + include/paths.h | 1 - include/regexp.h | 20 +++-- include/rpc/auth.h | 4 + include/rpc/auth_des.h | 4 + include/signal.h | 2 + include/stdlib.h | 26 +++--- include/sys/mman.h | 6 +- include/sys/poll.h | 2 - include/sys/shm.h | 3 +- include/sys/socket.h | 9 +- include/sys/statvfs.h | 8 +- include/sys/timex.h | 2 + include/sys/utsname.h | 23 +++-- include/sys/wait.h | 2 +- libc/sysdeps/linux/mips/bits/termios.h | 1 + 21 files changed, 268 insertions(+), 75 deletions(-) (limited to 'libc') diff --git a/include/inttypes.h b/include/inttypes.h index b1d4302a2..137d3dbd4 100644 --- a/include/inttypes.h +++ b/include/inttypes.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. +/* Copyright (C) 1997-2001, 2004, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -70,8 +70,8 @@ typedef wchar_t __gwchar_t; # define PRIdLEAST64 __PRI64_PREFIX "d" # define PRIdFAST8 "d" -# define PRIdFAST16 "d" -# define PRIdFAST32 "d" +# define PRIdFAST16 __PRIPTR_PREFIX "d" +# define PRIdFAST32 __PRIPTR_PREFIX "d" # define PRIdFAST64 __PRI64_PREFIX "d" @@ -86,8 +86,8 @@ typedef wchar_t __gwchar_t; # define PRIiLEAST64 __PRI64_PREFIX "i" # define PRIiFAST8 "i" -# define PRIiFAST16 "i" -# define PRIiFAST32 "i" +# define PRIiFAST16 __PRIPTR_PREFIX "i" +# define PRIiFAST32 __PRIPTR_PREFIX "i" # define PRIiFAST64 __PRI64_PREFIX "i" /* Octal notation. */ @@ -102,8 +102,8 @@ typedef wchar_t __gwchar_t; # define PRIoLEAST64 __PRI64_PREFIX "o" # define PRIoFAST8 "o" -# define PRIoFAST16 "o" -# define PRIoFAST32 "o" +# define PRIoFAST16 __PRIPTR_PREFIX "o" +# define PRIoFAST32 __PRIPTR_PREFIX "o" # define PRIoFAST64 __PRI64_PREFIX "o" /* Unsigned integers. */ @@ -118,8 +118,8 @@ typedef wchar_t __gwchar_t; # define PRIuLEAST64 __PRI64_PREFIX "u" # define PRIuFAST8 "u" -# define PRIuFAST16 "u" -# define PRIuFAST32 "u" +# define PRIuFAST16 __PRIPTR_PREFIX "u" +# define PRIuFAST32 __PRIPTR_PREFIX "u" # define PRIuFAST64 __PRI64_PREFIX "u" /* lowercase hexadecimal notation. */ @@ -134,8 +134,8 @@ typedef wchar_t __gwchar_t; # define PRIxLEAST64 __PRI64_PREFIX "x" # define PRIxFAST8 "x" -# define PRIxFAST16 "x" -# define PRIxFAST32 "x" +# define PRIxFAST16 __PRIPTR_PREFIX "x" +# define PRIxFAST32 __PRIPTR_PREFIX "x" # define PRIxFAST64 __PRI64_PREFIX "x" /* UPPERCASE hexadecimal notation. */ @@ -150,8 +150,8 @@ typedef wchar_t __gwchar_t; # define PRIXLEAST64 __PRI64_PREFIX "X" # define PRIXFAST8 "X" -# define PRIXFAST16 "X" -# define PRIXFAST32 "X" +# define PRIXFAST16 __PRIPTR_PREFIX "X" +# define PRIXFAST32 __PRIPTR_PREFIX "X" # define PRIXFAST64 __PRI64_PREFIX "X" @@ -311,7 +311,7 @@ extern intmax_t strtoimax (__const char *__restrict __nptr, extern uintmax_t strtoumax (__const char *__restrict __nptr, char ** __restrict __endptr, int __base) __THROW; -#if defined __UCLIBC_HAS_WCHAR__ && __UCLIBC_HAS_WCHAR__ +#ifdef __UCLIBC_HAS_WCHAR__ /* Like `wcstol' but convert to `intmax_t'. */ extern intmax_t wcstoimax (__const __gwchar_t *__restrict __nptr, __gwchar_t **__restrict __endptr, int __base) @@ -323,6 +323,126 @@ extern uintmax_t wcstoumax (__const __gwchar_t *__restrict __nptr, __THROW; #endif +#if 0 /*def __USE_EXTERN_INLINES*/ + +# if __WORDSIZE == 64 + +extern long int __strtol_internal (__const char *__restrict __nptr, + char **__restrict __endptr, + int __base, int __group) + __THROW __nonnull ((1)) __wur; +/* Like `strtol' but convert to `intmax_t'. */ +__extern_inline intmax_t +__NTH (strtoimax (__const char *__restrict nptr, char **__restrict endptr, + int base)) +{ + return __strtol_internal (nptr, endptr, base, 0); +} + +extern unsigned long int __strtoul_internal (__const char * + __restrict __nptr, + char ** __restrict __endptr, + int __base, int __group) + __THROW __nonnull ((1)) __wur; +/* Like `strtoul' but convert to `uintmax_t'. */ +__extern_inline uintmax_t +__NTH (strtoumax (__const char *__restrict nptr, char **__restrict endptr, + int base)) +{ + return __strtoul_internal (nptr, endptr, base, 0); +} + +extern long int __wcstol_internal (__const __gwchar_t * __restrict __nptr, + __gwchar_t **__restrict __endptr, + int __base, int __group) + __THROW __nonnull ((1)) __wur; +/* Like `wcstol' but convert to `intmax_t'. */ +__extern_inline intmax_t +__NTH (wcstoimax (__const __gwchar_t *__restrict nptr, + __gwchar_t **__restrict endptr, int base)) +{ + return __wcstol_internal (nptr, endptr, base, 0); +} + +extern unsigned long int __wcstoul_internal (__const __gwchar_t * + __restrict __nptr, + __gwchar_t ** + __restrict __endptr, + int __base, int __group) + __THROW __nonnull ((1)) __wur; +/* Like `wcstoul' but convert to `uintmax_t'. */ +__extern_inline uintmax_t +__NTH (wcstoumax (__const __gwchar_t *__restrict nptr, + __gwchar_t **__restrict endptr, int base)) +{ + return __wcstoul_internal (nptr, endptr, base, 0); +} + +# else /* __WORDSIZE == 32 */ + +__extension__ +extern long long int __strtoll_internal (__const char *__restrict __nptr, + char **__restrict __endptr, + int __base, int __group) + __THROW __nonnull ((1)) __wur; +/* Like `strtol' but convert to `intmax_t'. */ +__extern_inline intmax_t +__NTH (strtoimax (__const char *__restrict nptr, char **__restrict endptr, + int base)) +{ + return __strtoll_internal (nptr, endptr, base, 0); +} + +__extension__ +extern unsigned long long int __strtoull_internal (__const char * + __restrict __nptr, + char ** + __restrict __endptr, + int __base, + int __group) + __THROW __nonnull ((1)) __wur; +/* Like `strtoul' but convert to `uintmax_t'. */ +__extern_inline uintmax_t +__NTH (strtoumax (__const char *__restrict nptr, char **__restrict endptr, + int base)) +{ + return __strtoull_internal (nptr, endptr, base, 0); +} + +__extension__ +extern long long int __wcstoll_internal (__const __gwchar_t * + __restrict __nptr, + __gwchar_t **__restrict __endptr, + int __base, int __group) + __THROW __nonnull ((1)) __wur; +/* Like `wcstol' but convert to `intmax_t'. */ +__extern_inline intmax_t +__NTH (wcstoimax (__const __gwchar_t *__restrict nptr, + __gwchar_t **__restrict endptr, int base)) +{ + return __wcstoll_internal (nptr, endptr, base, 0); +} + + +__extension__ +extern unsigned long long int __wcstoull_internal (__const __gwchar_t * + __restrict __nptr, + __gwchar_t ** + __restrict __endptr, + int __base, + int __group) + __THROW __nonnull ((1)) __wur; +/* Like `wcstoul' but convert to `uintmax_t'. */ +__extern_inline uintmax_t +__NTH (wcstoumax (__const __gwchar_t *__restrict nptr, + __gwchar_t **__restrict endptr, int base)) +{ + return __wcstoull_internal (nptr, endptr, base, 0); +} + +# endif /* __WORDSIZE == 32 */ +#endif /* Use extern inlines. */ + __END_DECLS #endif /* inttypes.h */ diff --git a/include/langinfo.h b/include/langinfo.h index f289a66c0..2e2ee4ec8 100644 --- a/include/langinfo.h +++ b/include/langinfo.h @@ -1,5 +1,5 @@ /* Access to locale-dependent parameters. - Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1995-2002,2003,2004,2005 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -32,13 +32,20 @@ __BEGIN_DECLS (LC_*) and an item index within the category. Some code may depend on the item values within a category increasing monotonically with the indices. */ +#if 0 +#define _NL_ITEM(category, index) (((category) << 16) | (index)) + +/* Extract the category and item index from a constructed `nl_item' value. */ +#define _NL_ITEM_CATEGORY(item) ((int) (item) >> 16) +#define _NL_ITEM_INDEX(item) ((int) (item) & 0xffff) +#else #define _NL_ITEM(category, index) \ (((category) << __NL_ITEM_CATEGORY_SHIFT) | (index)) /* Extract the category and item index from a constructed `nl_item' value. */ #define _NL_ITEM_CATEGORY(item) ((int) (item) >> __NL_ITEM_CATEGORY_SHIFT) #define _NL_ITEM_INDEX(item) ((int) (item) & __NL_ITEM_INDEX_MASK) - +#endif /* Enumeration of locale items that can be queried with `nl_langinfo'. */ enum @@ -312,6 +319,9 @@ enum _NL_CTYPE_INDIGITS8_WC, _NL_CTYPE_INDIGITS9_WC, _NL_CTYPE_OUTDIGIT0_MB, +#else + _NL_CTYPE_OUTDIGIT0_MB = _NL_ITEM (__LC_CTYPE, 0), +#endif _NL_CTYPE_OUTDIGIT1_MB, _NL_CTYPE_OUTDIGIT2_MB, _NL_CTYPE_OUTDIGIT3_MB, @@ -321,6 +331,7 @@ enum _NL_CTYPE_OUTDIGIT7_MB, _NL_CTYPE_OUTDIGIT8_MB, _NL_CTYPE_OUTDIGIT9_MB, +#if 0 _NL_CTYPE_OUTDIGIT0_WC, _NL_CTYPE_OUTDIGIT1_WC, _NL_CTYPE_OUTDIGIT2_WC, @@ -340,6 +351,7 @@ enum _NL_CTYPE_TRANSLIT_DEFAULT_MISSING, _NL_CTYPE_TRANSLIT_IGNORE_LEN, _NL_CTYPE_TRANSLIT_IGNORE, + _NL_CTYPE_MAP_TO_NONASCII, _NL_CTYPE_EXTRA_MAP_1, _NL_CTYPE_EXTRA_MAP_2, _NL_CTYPE_EXTRA_MAP_3, @@ -354,17 +366,7 @@ enum _NL_CTYPE_EXTRA_MAP_12, _NL_CTYPE_EXTRA_MAP_13, _NL_CTYPE_EXTRA_MAP_14, -#else /* 0 */ - _NL_CTYPE_OUTDIGIT0_MB = _NL_ITEM (__LC_CTYPE, 0), - _NL_CTYPE_OUTDIGIT1_MB, - _NL_CTYPE_OUTDIGIT2_MB, - _NL_CTYPE_OUTDIGIT3_MB, - _NL_CTYPE_OUTDIGIT4_MB, - _NL_CTYPE_OUTDIGIT5_MB, - _NL_CTYPE_OUTDIGIT6_MB, - _NL_CTYPE_OUTDIGIT7_MB, - _NL_CTYPE_OUTDIGIT8_MB, - _NL_CTYPE_OUTDIGIT9_MB, +#else /* 0 */ _NL_CTYPE_CODESET_NAME, /* uClibc note: MUST BE LAST ENTRY!!! */ CODESET = _NL_CTYPE_CODESET_NAME, #define CODESET CODESET @@ -433,6 +435,10 @@ enum __N_SIGN_POSN, #ifdef __USE_GNU # define N_SIGN_POSN __N_SIGN_POSN +#endif +#if 0 /* moved below for some reason on uClibc */ + _NL_MONETARY_CRNCYSTR, +#define CRNCYSTR _NL_MONETARY_CRNCYSTR #endif __INT_P_CS_PRECEDES, #ifdef __USE_GNU @@ -458,10 +464,10 @@ enum #ifdef __USE_GNU # define INT_N_SIGN_POSN __INT_N_SIGN_POSN #endif - +#if 1 /* moved here from above */ _NL_MONETARY_CRNCYSTR, #define CRNCYSTR _NL_MONETARY_CRNCYSTR - +#endif #if 0 _NL_MONETARY_DUO_INT_CURR_SYMBOL, _NL_MONETARY_DUO_CURRENCY_SYMBOL, @@ -591,10 +597,18 @@ enum _NL_IDENTIFICATION_CODESET, _NL_NUM_LC_IDENTIFICATION, #endif + /* This marks the highest value used. */ _NL_NUM }; +/* This macro produces an item you can pass to `nl_langinfo' or + `nl_langinfo_l' to get the name of the locale in use for CATEGORY. */ +#define _NL_LOCALE_NAME(category) _NL_ITEM ((category), -1) +#ifdef __USE_GNU +# define NL_LOCALE_NAME(category) _NL_LOCALE_NAME (category) +#endif + /* Return the current locale's value for ITEM. If ITEM is invalid, an empty string is returned. @@ -606,8 +620,7 @@ extern char *nl_langinfo (nl_item __item) __THROW; libc_hidden_proto(nl_langinfo) -#ifdef __UCLIBC_HAS_XLOCALE__ -#ifdef __USE_GNU +#if defined __USE_GNU && defined __UCLIBC_HAS_XLOCALE__ /* This interface is for the extended locale model. See for more information. */ @@ -618,7 +631,6 @@ libc_hidden_proto(nl_langinfo) extern char *nl_langinfo_l (nl_item __item, __locale_t l); libc_hidden_proto(nl_langinfo_l) #endif -#endif __END_DECLS diff --git a/include/locale.h b/include/locale.h index cdb3a09d9..b740908f0 100644 --- a/include/locale.h +++ b/include/locale.h @@ -39,6 +39,7 @@ __BEGIN_DECLS #define LC_COLLATE __LC_COLLATE #define LC_MONETARY __LC_MONETARY #define LC_MESSAGES __LC_MESSAGES +#define LC_ALL __LC_ALL #if 0 #define LC_PAPER __LC_PAPER #define LC_NAME __LC_NAME @@ -47,9 +48,10 @@ __BEGIN_DECLS #define LC_MEASUREMENT __LC_MEASUREMENT #define LC_IDENTIFICATION __LC_IDENTIFICATION #endif -#define LC_ALL __LC_ALL +__BEGIN_NAMESPACE_STD + /* Structure giving information about numeric and monetary notation. */ struct lconv { @@ -121,8 +123,6 @@ struct lconv }; -__BEGIN_NAMESPACE_STD - /* Set and/or return the current locale. */ extern char *setlocale (int __category, __const char *__locale) __THROW; @@ -133,7 +133,7 @@ libc_hidden_proto(localeconv) __END_NAMESPACE_STD -#if defined(__USE_GNU) && defined(__UCLIBC_HAS_LOCALE__) +#if defined __USE_GNU && defined __UCLIBC_HAS_LOCALE__ /* The concept of one static locale per category is not very well thought out. Many applications will need to process its data using information from several different locales. Another application is @@ -145,7 +145,7 @@ __END_NAMESPACE_STD Attention: all these functions are *not* standardized in any form. This is a proof-of-concept implementation. */ -#if defined(__UCLIBC_HAS_XLOCALE__) +#ifdef __UCLIBC_HAS_XLOCALE__ /* Get locale datatype definition. */ # include #endif diff --git a/include/net/ethernet.h b/include/net/ethernet.h index 7ca8e8348..0242d5899 100644 --- a/include/net/ethernet.h +++ b/include/net/ethernet.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1997, 1999, 2001 Free Software Foundation, Inc. +/* Copyright (C) 1997, 1999, 2001, 2008 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -45,9 +45,17 @@ struct ether_header /* Ethernet protocol ID's */ #define ETHERTYPE_PUP 0x0200 /* Xerox PUP */ +#define ETHERTYPE_SPRITE 0x0500 /* Sprite */ #define ETHERTYPE_IP 0x0800 /* IP */ #define ETHERTYPE_ARP 0x0806 /* Address resolution */ #define ETHERTYPE_REVARP 0x8035 /* Reverse ARP */ +#define ETHERTYPE_AT 0x809B /* AppleTalk protocol */ +#define ETHERTYPE_AARP 0x80F3 /* AppleTalk ARP */ +#define ETHERTYPE_VLAN 0x8100 /* IEEE 802.1Q VLAN tagging */ +#define ETHERTYPE_IPX 0x8137 /* IPX */ +#define ETHERTYPE_IPV6 0x86dd /* IP protocol version 6 */ +#define ETHERTYPE_LOOPBACK 0x9000 /* used to test interfaces */ + #define ETHER_ADDR_LEN ETH_ALEN /* size of ethernet addr */ #define ETHER_TYPE_LEN 2 /* bytes in type field */ diff --git a/include/net/if_arp.h b/include/net/if_arp.h index 46f035bef..9608652ee 100644 --- a/include/net/if_arp.h +++ b/include/net/if_arp.h @@ -1,5 +1,5 @@ /* Definitions for Address Resolution Protocol. - Copyright (C) 1997, 1999, 2001 Free Software Foundation, Inc. + Copyright (C) 1997,1999,2001,2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1997. @@ -96,7 +96,7 @@ struct arphdr #define ARPHRD_ADAPT 264 #define ARPHRD_ROSE 270 #define ARPHRD_X25 271 /* CCITT X.25. */ -#define ARPHDR_HWX25 272 /* Boards with X.25 in firmware. */ +#define ARPHRD_HWX25 272 /* Boards with X.25 in firmware. */ #define ARPHRD_PPP 512 #define ARPHRD_CISCO 513 /* Cisco HDLC. */ #define ARPHRD_HDLC ARPHRD_CISCO @@ -126,6 +126,12 @@ struct arphdr #define ARPHRD_FCFABRIC 787 /* Fibrechanel fabric. */ #define ARPHRD_IEEE802_TR 800 /* Magic type ident for TR. */ #define ARPHRD_IEEE80211 801 /* IEEE 802.11. */ +#define ARPHRD_IEEE80211_PRISM 802 /* IEEE 802.11 + Prism2 header. */ +#define ARPHRD_IEEE80211_RADIOTAP 803 /* IEEE 802.11 + radiotap header. */ + +#define ARPHRD_VOID 0xFFFF /* Void type, nothing is known. */ +#define ARPHRD_NONE 0xFFFE /* Zero header length. */ + /* ARP ioctl request. */ struct arpreq diff --git a/include/netinet/ether.h b/include/netinet/ether.h index 3d8902f50..5e89dfe9e 100644 --- a/include/netinet/ether.h +++ b/include/netinet/ether.h @@ -25,7 +25,9 @@ /* Get definition of `struct ether_addr'. */ #include +#ifdef _LIBC #define ETHER_FILE_NAME "/etc/ethers" +#endif __BEGIN_DECLS @@ -41,6 +43,7 @@ extern struct ether_addr *ether_aton_r (__const char *__asc, struct ether_addr *__addr) __THROW; libc_hidden_proto(ether_aton_r) +#if 0 /* Map 48 bit Ethernet number ADDR to HOSTNAME. */ extern int ether_ntohost (char *__hostname, __const struct ether_addr *__addr) __THROW; @@ -52,6 +55,7 @@ extern int ether_hostton (__const char *__hostname, struct ether_addr *__addr) /* Scan LINE and set ADDR and HOSTNAME. */ extern int ether_line (__const char *__line, struct ether_addr *__addr, char *__hostname) __THROW; +#endif __END_DECLS diff --git a/include/paths.h b/include/paths.h index ae892c4cf..305937fc5 100644 --- a/include/paths.h +++ b/include/paths.h @@ -64,7 +64,6 @@ #define _PATH_VI "/usr/bin/vi" #define _PATH_WTMP "/var/log/wtmp" -/* uClibc */ #ifdef _LIBC #define _PATH_PASSWD "/etc/passwd" #define _PATH_GROUP "/etc/group" diff --git a/include/regexp.h b/include/regexp.h index b7b50b710..57b7f93ea 100644 --- a/include/regexp.h +++ b/include/regexp.h @@ -1,4 +1,5 @@ -/* Copyright (C) 1996, 1997, 1998, 1999, 2004 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 1998, 1999, 2004, 2008 + Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1996. @@ -81,6 +82,7 @@ __BEGIN_DECLS +#if 0 /* Interface variables. They contain the results of the successful calls to `setp' and `advance'. */ extern char *loc1; @@ -89,6 +91,7 @@ extern char *loc2; /* The use of this variable in the `advance' function is not supported. */ extern char *locs; +#endif #ifndef __DO_NOT_DEFINE_COMPILE @@ -129,8 +132,9 @@ compile (char *__restrict instring, char *__restrict expbuf, __expr_ptr = (regex_t *) expbuf; /* The remaining space in the buffer can be used for the compiled pattern. */ - __expr_ptr->buffer = expbuf + sizeof (regex_t); - __expr_ptr->allocated = endbuf - (char *) __expr_ptr->buffer; + __expr_ptr->__REPB_PREFIX (buffer) = expbuf + sizeof (regex_t); + __expr_ptr->__REPB_PREFIX (allocated) + = endbuf - (char *) __expr_ptr->__REPB_PREFIX (buffer); while ((__ch = (GETC ())) != eof) { @@ -162,7 +166,10 @@ compile (char *__restrict instring, char *__restrict expbuf, } __input_buffer[__current_size++] = __ch; } - __input_buffer[__current_size++] = '\0'; + if (__current_size) + __input_buffer[__current_size++] = '\0'; + else + __input_buffer = ""; /* Now compile the pattern. */ __error = regcomp (__expr_ptr, __input_buffer, REG_NEWLINE); @@ -198,11 +205,13 @@ compile (char *__restrict instring, char *__restrict expbuf, } /* Everything is ok. */ - RETURN ((char *) (__expr_ptr->buffer + __expr_ptr->used)); + RETURN ((char *) (__expr_ptr->__REPB_PREFIX (buffer) + + __expr_ptr->__REPB_PREFIX (used))); } #endif +#if 0 /* Find the next match in STRING. The compiled regular expression is found in the buffer starting at EXPBUF. `loc1' will return the first character matched and `loc2' points to the next unmatched @@ -215,6 +224,7 @@ extern int step (__const char *__restrict __string, position of the first unmatched character. */ extern int advance (__const char *__restrict __string, __const char *__restrict __expbuf) __THROW; +#endif __END_DECLS diff --git a/include/rpc/auth.h b/include/rpc/auth.h index e8390c885..ee5396fc5 100644 --- a/include/rpc/auth.h +++ b/include/rpc/auth.h @@ -176,11 +176,13 @@ extern AUTH *authunix_create_default (void); libc_hidden_proto(authunix_create_default) extern AUTH *authnone_create (void) __THROW; libc_hidden_proto(authnone_create) +#if 0 extern AUTH *authdes_create (const char *__servername, u_int __window, struct sockaddr *__syncaddr, des_block *__ckey) __THROW; extern AUTH *authdes_pk_create (const char *, netobj *, u_int, struct sockaddr *, des_block *) __THROW; +#endif #define AUTH_NONE 0 /* no authentication */ @@ -192,6 +194,7 @@ extern AUTH *authdes_pk_create (const char *, netobj *, u_int, #define AUTH_DH AUTH_DES /* Diffie-Hellman (this is DES) */ #define AUTH_KERB 4 /* kerberos style */ +#if 0 /* * Netname manipulating functions * @@ -216,6 +219,7 @@ extern int key_gendes (des_block *); extern int key_setsecret (char *); extern int key_secretkey_is_set (void); extern int key_get_conv (char *, des_block *); +#endif /* * XDR an opaque authentication struct. diff --git a/include/rpc/auth_des.h b/include/rpc/auth_des.h index 7a6b8be8d..d51b7ce7c 100644 --- a/include/rpc/auth_des.h +++ b/include/rpc/auth_des.h @@ -24,6 +24,7 @@ __BEGIN_DECLS +#if 0 /* There are two kinds of "names": fullnames and nicknames */ enum authdes_namekind { @@ -47,6 +48,7 @@ struct authdes_cred struct authdes_fullname adc_fullname; uint32_t adc_nickname; }; +#endif /* A timeval replacement for !32bit platforms */ struct rpc_timeval @@ -55,6 +57,7 @@ struct rpc_timeval uint32_t tv_usec; /* Microseconds. */ }; +#if 0 /* A des authentication verifier */ struct authdes_verf { @@ -102,6 +105,7 @@ extern int getpublickey (__const char *__name, char *__key) __THROW; the key. */ extern int getsecretkey (__const char *__name, char *__key, __const char *__passwd) __THROW; +#endif extern int rtime (struct sockaddr_in *__addrp, struct rpc_timeval *__timep, struct rpc_timeval *__timeout) __THROW; diff --git a/include/signal.h b/include/signal.h index 31ebc133c..0a09c7ad4 100644 --- a/include/signal.h +++ b/include/signal.h @@ -376,10 +376,12 @@ extern int sigreturn (struct sigcontext *__scp) __THROW; #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED +# ifdef __UCLIBC_SUSV4_LEGACY__ /* If INTERRUPT is nonzero, make signal SIG interrupt system calls (causing them to fail with EINTR); if INTERRUPT is zero, make system calls be restarted after signal SIG. */ extern int siginterrupt (int __sig, int __interrupt) __THROW; +# endif # include # ifdef __USE_XOPEN diff --git a/include/stdlib.h b/include/stdlib.h index 536f81a1e..155b8f1ea 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -90,7 +90,7 @@ typedef union # define WIFEXITED(status) __WIFEXITED (__WAIT_INT (status)) # define WIFSIGNALED(status) __WIFSIGNALED (__WAIT_INT (status)) # define WIFSTOPPED(status) __WIFSTOPPED (__WAIT_INT (status)) -# if 0 /* def __WIFCONTINUED */ +# ifdef __WIFCONTINUED # define WIFCONTINUED(status) __WIFCONTINUED (__WAIT_INT (status)) # endif #endif /* X/Open and not included. */ @@ -141,12 +141,13 @@ __END_NAMESPACE_C99 #if 0 #define MB_CUR_MAX (__ctype_get_mb_cur_max ()) extern size_t __ctype_get_mb_cur_max (void) __THROW __wur; -#endif +#else #ifdef __UCLIBC_HAS_WCHAR__ #define MB_CUR_MAX (_stdlib_mb_cur_max ()) extern size_t _stdlib_mb_cur_max (void) __THROW __wur; libc_hidden_proto(_stdlib_mb_cur_max) #endif +#endif __BEGIN_NAMESPACE_STD @@ -240,8 +241,7 @@ __END_NAMESPACE_C99 #endif /* ISO C99 or GCC and use MISC. */ -#ifdef __UCLIBC_HAS_XLOCALE__ -#ifdef __USE_GNU +#if defined __USE_GNU && defined __UCLIBC_HAS_XLOCALE__ /* The concept of one static locale per category is not very well thought out. Many applications will need to process its data using information from several different locales. Another application is @@ -296,9 +296,7 @@ extern long double strtold_l (__const char *__restrict __nptr, __locale_t __loc) __THROW __nonnull ((1, 3)) __wur; #endif /* __UCLIBC_HAS_FLOATS__ */ - #endif /* GNU */ -#endif /* __UCLIBC_HAS_XLOCALE__ */ #if defined __USE_SVID || defined __USE_XOPEN_EXTENDED @@ -494,13 +492,16 @@ __END_NAMESPACE_STD __BEGIN_NAMESPACE_STD /* Re-allocate the previously allocated block in PTR, making the new block SIZE bytes long. */ +/* __attribute_malloc__ is not used, because if realloc returns + the same pointer that was passed to it, aliasing needs to be allowed + between objects pointed by the old and new pointers. */ extern void *realloc (void *__ptr, size_t __size) - __THROW __attribute_malloc__ __attribute_warn_unused_result__; + __THROW __attribute_warn_unused_result__; /* Free a block allocated by `malloc', `realloc' or `calloc'. */ extern void free (void *__ptr) __THROW; __END_NAMESPACE_STD -#ifdef __USE_MISC +#if 0 /*def __USE_MISC*/ /* Free a block. An alias for `free'. (Sun Unices). */ extern void cfree (void *__ptr) __THROW; #endif /* Use misc. */ @@ -560,10 +561,12 @@ extern char *getenv (__const char *__name) __THROW __nonnull ((1)) __wur; libc_hidden_proto(getenv) __END_NAMESPACE_STD +#if 0 /* This function is similar to the above but returns NULL if the programs is running with SUID or SGID enabled. */ extern char *__secure_getenv (__const char *__name) __THROW __nonnull ((1)) __wur; +#endif #if defined __USE_SVID || defined __USE_XOPEN /* The SVID says this is in , but this seems a better place. */ @@ -723,12 +726,11 @@ __END_NAMESPACE_C99 #endif -#if defined __USE_SVID || defined __USE_XOPEN_EXTENDED || defined __USE_BSD +#if ( defined __USE_SVID || defined __USE_XOPEN_EXTENDED ) && defined __UCLIBC_HAS_FLOATS__ /* Convert floating point numbers to strings. The returned values are valid only until another call to the same function. */ # ifdef __UCLIBC_SUSV3_LEGACY__ - #if 0 /* Convert VALUE to a string with NDIGIT digits and return a pointer to this. Set *DECPT with the position of the decimal character and *SIGN @@ -750,6 +752,7 @@ extern char *gcvt (double __value, int __ndigit, char *__buf) __THROW __nonnull ((3)) __wur; # endif /* __UCLIBC_SUSV3_LEGACY__ */ + # if 0 /*def __USE_MISC*/ /* Long double versions of above functions. */ extern char *qecvt (long double __value, int __ndigit, @@ -782,6 +785,7 @@ extern int qfcvt_r (long double __value, int __ndigit, # endif /* misc */ #endif /* use MISC || use X/Open Unix */ + #ifdef __UCLIBC_HAS_WCHAR__ __BEGIN_NAMESPACE_STD /* Return the length of the multibyte character @@ -807,7 +811,7 @@ __END_NAMESPACE_STD #endif /* __UCLIBC_HAS_WCHAR__ */ -#ifdef __USE_SVID +#if 0 /*def __USE_SVID*/ /* Determine whether the string value of RESPONSE matches the affirmation or negative response expression as specified by the LC_MESSAGES category in the program's current locale. Returns 1 if affirmative, 0 if diff --git a/include/sys/mman.h b/include/sys/mman.h index 609f78a73..d46b92258 100644 --- a/include/sys/mman.h +++ b/include/sys/mman.h @@ -1,5 +1,5 @@ /* Definitions for BSD-style memory management. - Copyright (C) 1994-2000, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 1994-2000, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -59,8 +59,8 @@ extern void *mmap (void *__addr, size_t __len, int __prot, int __flags, int __fd, __off_t __offset) __THROW; libc_hidden_proto(mmap) #else -# ifdef __REDIRECT -extern void * __REDIRECT (mmap, +# ifdef __REDIRECT_NTH +extern void * __REDIRECT_NTH (mmap, (void *__addr, size_t __len, int __prot, int __flags, int __fd, __off64_t __offset), mmap64); diff --git a/include/sys/poll.h b/include/sys/poll.h index 13b913494..53ba6e2eb 100644 --- a/include/sys/poll.h +++ b/include/sys/poll.h @@ -30,8 +30,6 @@ /* Get the timespec definition. */ # define __need_timespec # include -/* get NULL definition. */ -# include #endif diff --git a/include/sys/shm.h b/include/sys/shm.h index 8ec30b486..786ce752b 100644 --- a/include/sys/shm.h +++ b/include/sys/shm.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-1999, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1995-1999, 2000, 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -41,6 +41,7 @@ typedef __pid_t pid_t; # endif #endif /* X/Open */ + __BEGIN_DECLS /* The following System V style IPC functions implement a shared memory diff --git a/include/sys/socket.h b/include/sys/socket.h index fb5135d3d..0824fc855 100644 --- a/include/sys/socket.h +++ b/include/sys/socket.h @@ -1,5 +1,6 @@ /* Declarations of socket constants, types, and functions. - Copyright (C) 1991,92,1994-2001,2003 Free Software Foundation, Inc. + Copyright (C) 1991,92,1994-2001,2003,2005,2007,2008 + Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -27,6 +28,10 @@ __BEGIN_DECLS #include #define __need_size_t #include +#ifdef __USE_GNU +/* Get the __sigset_t definition. */ +# include +#endif /* This operating system-specific header file defines the SOCK_*, PF_*, @@ -231,7 +236,7 @@ libc_hidden_proto(accept) extern int shutdown (int __fd, int __how) __THROW; -#ifdef __USE_XOPEN2K +#if 0 /*def __USE_XOPEN2K*/ /* Determine wheter socket is at a out-of-band mark. */ extern int sockatmark (int __fd) __THROW; #endif diff --git a/include/sys/statvfs.h b/include/sys/statvfs.h index e755bafc1..6199c5d02 100644 --- a/include/sys/statvfs.h +++ b/include/sys/statvfs.h @@ -54,8 +54,8 @@ extern int statvfs (__const char *__restrict __file, __THROW __nonnull ((1, 2)); libc_hidden_proto(statvfs) #else -# ifdef __REDIRECT -extern int __REDIRECT (statvfs, +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (statvfs, (__const char *__restrict __file, struct statvfs *__restrict __buf), statvfs64) __nonnull ((1, 2)); @@ -76,8 +76,8 @@ extern int fstatvfs (int __fildes, struct statvfs *__buf) __THROW __nonnull ((2)); libc_hidden_proto(fstatvfs) #else -# ifdef __REDIRECT -extern int __REDIRECT (fstatvfs, (int __fildes, struct statvfs *__buf), +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (fstatvfs, (int __fildes, struct statvfs *__buf), fstatvfs64) __nonnull ((2)); # else # define fstatvfs fstatvfs64 diff --git a/include/sys/timex.h b/include/sys/timex.h index b4998f5ab..5e82d464d 100644 --- a/include/sys/timex.h +++ b/include/sys/timex.h @@ -116,7 +116,9 @@ struct timex __BEGIN_DECLS +#if 0 extern int __adjtimex (struct timex *__ntx) __THROW; +#endif extern int adjtimex (struct timex *__ntx) __THROW; libc_hidden_proto(adjtimex) diff --git a/include/sys/utsname.h b/include/sys/utsname.h index 41534d553..7b57888ce 100644 --- a/include/sys/utsname.h +++ b/include/sys/utsname.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 92, 94, 96, 97, 99 Free Software Foundation, Inc. +/* Copyright (C) 1991,92,94,96,97,99,2002 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -29,26 +29,38 @@ __BEGIN_DECLS #include +#ifndef _UTSNAME_SYSNAME_LENGTH +# define _UTSNAME_SYSNAME_LENGTH _UTSNAME_LENGTH +#endif #ifndef _UTSNAME_NODENAME_LENGTH # define _UTSNAME_NODENAME_LENGTH _UTSNAME_LENGTH #endif +#ifndef _UTSNAME_RELEASE_LENGTH +# define _UTSNAME_RELEASE_LENGTH _UTSNAME_LENGTH +#endif +#ifndef _UTSNAME_VERSION_LENGTH +# define _UTSNAME_VERSION_LENGTH _UTSNAME_LENGTH +#endif +#ifndef _UTSNAME_MACHINE_LENGTH +# define _UTSNAME_MACHINE_LENGTH _UTSNAME_LENGTH +#endif /* Structure describing the system and machine. */ struct utsname { /* Name of the implementation of the operating system. */ - char sysname[_UTSNAME_LENGTH]; + char sysname[_UTSNAME_SYSNAME_LENGTH]; /* Name of this node on the network. */ char nodename[_UTSNAME_NODENAME_LENGTH]; /* Current release level of this implementation. */ - char release[_UTSNAME_LENGTH]; + char release[_UTSNAME_RELEASE_LENGTH]; /* Current version level of this release. */ - char version[_UTSNAME_LENGTH]; + char version[_UTSNAME_VERSION_LENGTH]; /* Name of the hardware type the system is running on. */ - char machine[_UTSNAME_LENGTH]; + char machine[_UTSNAME_MACHINE_LENGTH]; #if _UTSNAME_DOMAIN_LENGTH - 0 /* Name of the domain of this node on the network. */ @@ -61,6 +73,7 @@ struct utsname }; #ifdef __USE_SVID +/* Note that SVID assumes all members have the same size. */ # define SYS_NMLN _UTSNAME_LENGTH #endif diff --git a/include/sys/wait.h b/include/sys/wait.h index 59ccd9331..f283fe228 100644 --- a/include/sys/wait.h +++ b/include/sys/wait.h @@ -85,7 +85,7 @@ typedef union # define WIFEXITED(status) __WIFEXITED(__WAIT_INT(status)) # define WIFSIGNALED(status) __WIFSIGNALED(__WAIT_INT(status)) # define WIFSTOPPED(status) __WIFSTOPPED(__WAIT_INT(status)) -# if 0 /*def __WIFCONTINUED*/ +# ifdef __WIFCONTINUED # define WIFCONTINUED(status) __WIFCONTINUED(__WAIT_INT(status)) # endif #endif /* not included. */ diff --git a/libc/sysdeps/linux/mips/bits/termios.h b/libc/sysdeps/linux/mips/bits/termios.h index 546faa020..fb351995c 100644 --- a/libc/sysdeps/linux/mips/bits/termios.h +++ b/libc/sysdeps/linux/mips/bits/termios.h @@ -73,6 +73,7 @@ struct termios #define IXANY 0004000 /* Any character will restart after stop. */ #define IXOFF 0010000 /* Enable start/stop input control. */ #define IMAXBEL 0020000 /* Ring bell when input queue is full. */ +#define IUTF8 0040000 /* Input is UTF8. */ /* c_oflag bits */ #define OPOST 0000001 /* Perform output processing. */ -- cgit v1.2.3 From 42c91e83ce9ff723105d1c04f05dccf756c9452f Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Fri, 20 Nov 2009 09:37:56 +0100 Subject: __assert: include unistd.h for smallint Signed-off-by: Bernhard Reutner-Fischer --- libc/misc/assert/__assert.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'libc') diff --git a/libc/misc/assert/__assert.c b/libc/misc/assert/__assert.c index 18c6f5ecf..8afde52ff 100644 --- a/libc/misc/assert/__assert.c +++ b/libc/misc/assert/__assert.c @@ -29,7 +29,7 @@ #include #include - +#include /* Get the prototype from assert.h as a double-check. */ #undef NDEBUG @@ -63,5 +63,4 @@ void __assert(const char *assertion, const char * filename, /* shouldn't we? fflush(stderr); */ abort(); } - libc_hidden_def(__assert) -- 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') 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') 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