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 --- libc/stdlib/realpath.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'libc') 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 --- libc/sysdeps/linux/common/bits/mathcalls.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'libc') 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 -- 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 --- libc/misc/assert/__assert.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'libc') 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 --- libc/sysdeps/linux/common/bits/uClibc_ctype.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'libc') 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 -- 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 --- libc/misc/sysvipc/msgq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libc') 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 --- libc/sysdeps/linux/mips/bits/termios.h | 1 + 1 file changed, 1 insertion(+) (limited to 'libc') 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 --- libc/sysdeps/linux/common/futimens.c | 23 +++++++++++++++++++++++ libc/sysdeps/linux/common/utimensat.c | 2 ++ 2 files changed, 25 insertions(+) create mode 100644 libc/sysdeps/linux/common/futimens.c (limited to 'libc') 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 + -- cgit v1.2.3