summaryrefslogtreecommitdiff
path: root/libc
AgeCommit message (Collapse)Author
2015-12-22Replace MIPS specific memcpy.S/memset.S with version from glibc/newlib.Steve Ellcey
These MIPS specific versions of memcpy.S and memset.S are faster than the current ones and match what is in newlib and glibc. They also have support for the mips32r6 and mips64r6 architectures. Signed-off-by: Steve Ellcey <sellcey@imgtec.com>
2015-12-22pselect: Use linux pselect syscall when availableNicolas S. Dade
Linux has a pselect syscall since 2.6.something. Using it rather than emulating it with sigprocmask+select+sigprocmask is smaller code, and works properly. (The emulation has race conditions when unblocked signals arrive before or after the select) The tv.nsec >= 1E9 handling comes from uclibc's linux select() implementation, which itself uses pselect() internally if the pselect syscall exists. I though it would be good to do the same here. Note that although the libc pselect() API has 6 arguments, the linux kernel syscall as 7 arguments. There is an extra, somewhat vestigial, sizeof the signal mask argument. Signed-off-by: Nicolas S. Dade <nic.dade@gmail.com>
2015-12-22libc/pwd_grp: Create template for non-reentrant functionsWaldemar Brodkorb
Avoid a lot of copy'n'paste code, no functionality change Signed-off-by: Leonid Lisovskiy <lly.dev@gmail.com>
2015-12-22Use gcc's __builtin_mempcpy() as __mempcpy(), if possibleWaldemar Brodkorb
Patch from OpenWrt. Reported-by: Leonid Lisovskiy <lly.dev@gmail.com>
2015-12-22Do define some IPv6 related symbols even with IPv6 disabledWaldemar Brodkorb
Fixes compilation of some faulty applictions. Patch from Freetz.org Reported-by: Leonid Lisovskiy <lly.dev@gmail.com>
2015-12-22resolv: fix gethostbyname2_r to match gethostbyname_r, fixing bugs with AAAA ↵Waldemar Brodkorb
lookups The latter half of gethostbyname2_r (doing AAAA queries) is rather dramatically different from the corresponding portion of gethostbyname_r (doing A queries). This leads to problems like calls to getaddrinfo only returning one IPv6 address, even when multiple exist. Seems to be entirely a case of divergent evolution -- a half-decade of fixes for the IPv4 code but no love for IPv6. Until now. ;) DNS behaviour for IPv6 is really no different than for IPv4 -- beyond the difference in address sizes, there's no need for the functions to be so different. Consequently, this patch really is almost just a cut-and-paste of gethostbyname_r, with the appropriate substitutions of in6_addr, AF_INET6, etc; while holding on to the few extra bits that actually belong in there (eg #ifdef __UCLIBC_HAS_IPV6__). Signed-off-by: Wes Campaigne <westacular@gmail.com>
2015-12-22inet/resolv: Fix broken h_aliases list terminator after 2dab3f5Waldemar Brodkorb
Commit 2dab3f5a "resolv: tiny shrinkage in /etc/hosts handling" leads to that read_etc_hosts_r() provide garbage pointer at the end of h_aliases list if more than four hostnames follow a dotted quad in /etc/hosts Test-case: Add following line to /etc/hosts 63.63.0.2 host1 alias2 alias3 alias4 alias5 #include <stdio.h> #include <errno.h> #include <netdb.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> int main (void) { int i; char *a; struct hostent *he; struct in_addr ipv4addr; inet_pton(AF_INET, "63.63.0.2", &ipv4addr); he = gethostbyaddr(&ipv4addr, sizeof ipv4addr, AF_INET); if (he == NULL) exit(1); printf("Host name: '%s'\n", he->h_name); i = 0; while ((a = he->h_aliases[i]) != NULL) { printf("Host alias: '%s'\n", a); ++i; } return 0; } Wrong output: Host name: 'host1' Host alias: 'alias2' Host alias: 'alias3' Host alias: 'alias4' Host alias: 'alias5' Host alias: '??' Signed-off-by: Leonid Lisovskiy <lly.dev@gmail.com> Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
2015-12-17Add implementation for copysignl for ppcKhem Raj
Signed-off-by: Khem Raj <raj.khem@gmail.com>
2015-12-17libc/stdlib: canonicalize_file_name() memory leakWojciech Nizinski
Uclibc's canonicalize_file_name() is allocating temprary buffer of 4kB (PATH_MAX), and passing it to realpath() as second argument. Function is not checking if realpath() fails and memory is lost.
2015-12-17Fix syslog messages lost if syslogd is temporary busyVladislav Grishenko
Commit 4139fe5aec935ba3f462dcaf6aafb6e5eadf1ab9 fixes SIGSTOPed syslogd issue. but introduced new one - messages will be lost when socket buffer gets full, not only if syslogd is stalled, but even if it accepts message slower than someone sends and possibly leads to security hole, when important messages get lost as result of attacker flooding. Patch adds 1 second waiting for socket buffer can accept the message, helps when syslogd is working hard. If it's stalled/SIGSTOPed, message will be sent to errout as before. After that, further non-blocking /dev/log connect attempts will fail immediately with EAGAIN error until syslogd reads some from it. function old new delta openlog_intern 259 355 +96 static.tv - 8 +8 .rodata 151 159 +8 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 2/0 up/down: 112/0) Total: 112 bytes Signed-off-by: Vladislav Grishenko <themiron@mail.ru>
2015-12-17Fix syslog messages lost after syslogd restartsVladislav Grishenko
If syslogd is stopped and restarted while a process has the log open, the next message that process produces will be logged to the console and not to the new instance of syslogd. Further messages will be routed correctly, but not the first one. Based on original patch Bug 3889 - syslog loses messages when syslogd restarted https://bugs.busybox.net/show_bug.cgi?id=3889 function old new delta openlog 33 68 +35 __vsyslog 851 848 -3 openlog_intern 318 259 -59 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/2 up/down: 35/-62) Total: -27 bytes Signed-off-by: Vladislav Grishenko <themiron@mail.ru>
2015-12-17resolv: __dns_lookup - immediately switch to next server in case of poll() ↵Waldemar Brodkorb
set error events https://bugs.busybox.net/show_bug.cgi?id=3211 Signed-off-by: Leonid Lisovskiy <lly.dev@gmail.com> Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
2015-12-17dynamically allocate ahostbuf bufferWaldemar Brodkorb
Free 1k of static data (.bss) Signed-off-by: Leonid Lisovskiy <lly.dev@gmail.com> Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
2015-12-17svc.c: svc_getreqset() buffer overflowWaldemar Brodkorb
http://bugs.busybox.net/show_bug.cgi?id=5588 Signed-off-by: Leonid Lisovskiy <lly.dev@gmail.com> Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
2015-12-17libc/stdio: Rework custom streams interface similar to glibc.Waldemar Brodkorb
Save 20 bytes per FILE structure, avoid indirect call for read/write/seek/close operations for normal streams. Additionally, custom streams has fileno = -2 now, like in glibc. bloat-o-meter report (UCLIBC_HAS_GLIBC_CUSTOM_STREAMS=y): function old new delta fopencookie 69 131 +62 ftello64 233 260 +27 fseeko64 298 319 +21 fclose 423 442 +19 .rodata 16696 16708 +12 fileno_unlocked 53 45 -8 __ns_name_pack 859 851 -8 vswscanf 184 144 -40 vdprintf 231 187 -44 vsscanf 210 151 -59 vswprintf 269 201 -68 vsnprintf 249 181 -68 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 5/7 up/down: 141/-295) Total: -154 bytes Signed-off-by: Leonid Lisovskiy <lly.dev@gmail.com> Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
2015-12-17fix readdir_r returns success code while it in fact failedWaldemar Brodkorb
Taken from Freetz.org. Signed-off-by: Leonid Lisovskiy <lly.dev@gmail.com> Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
2015-12-11Revert "fix tst-signal7 failure"Waldemar Brodkorb
This reverts commit ea21c7610aa1131b37a4533cf13dd89f727fb83f. This was accidently pushed, before first coffee. Sorry this is a bad commit.
2015-12-10fix tst-signal7 failureWaldemar Brodkorb
error out on internal NPTL used signals.
2015-12-09sh: add back sh2 specific assembly for clone()Waldemar Brodkorb
In gcc 5.x there is a compile failure, for sh2 builds as shad no longer is accepted. Strange that it is working for 4.9.x. Add back old assembly code.
2015-12-09Reduce the initial buffer size for open_memstreamWaldemar Brodkorb
Reduce the initial buffer size for open_memstream (used by vasprintf), as most strings are usually smaller than that. Realloc the buffer after finishing the string to further reduce size. Problem appears in case of UCLIBC_HAS_GLIBC_CUSTOM_STREAMS=y, see http://dev.openwrt.org/ticket/13024 Signed-off-by: Felix Fietkau <nbd@openwrt.org> Signed-off-by: Leonid Lisovskiy <lly.dev@gmail.com> Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
2015-12-09Make malloc_stats() GNU libc compatibleWaldemar Brodkorb
This fix commit 76dfc7ce8c "Some requested additional malloc entry points" from 2004's Signed-off-by: Leonid Lisovskiy <lly.dev@gmail.com> Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
2015-12-07add definitions for O_PATHWaldemar Brodkorb
Only alpha, hppa and sparc need non-default value.
2015-12-06mips: fix definition.Steve Ellcey
glibc [BZ# 16922] * sysdeps/mips/sys/asm.h (INT_SUB): Fix definition. (LONG_SUB): Ditto. (PTR_SUB): Ditto. glibc commit 5057ad3b50 Signed-off-by: Steve Ellcey <sellcey@mips.com> Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
2015-12-05good by niosWaldemar Brodkorb
Get rid of NIOS support. We try to support NIOSII.
2015-12-05good by e1Waldemar Brodkorb
It is marked as broken and it seems you can't get any hardware for that anymore.
2015-12-05good bye vaxWaldemar Brodkorb
I mailed with Jan-Benedict Glaw, it seems VAX on Linux is really a lot of work todo and uClibc support didn't work ever.
2015-12-05remove sh64 supportWaldemar Brodkorb
No real hardware available. The project for sh64 with sh5 seems dead since 10 years. Gcc will remove support for it soon.
2015-12-05remove __UCLIBC_ASM_GLOBAL_DIRECTIVE__Waldemar Brodkorb
.globl can be used for every architecture so remove the define. Sync with GNU C library.
2015-12-05remove __UCLIBC_HAVE_ASM_GLOBAL_DOT_NAME__Waldemar Brodkorb
It's even no longer required for non-ported ppc64 architecture. Sync with GNU C library. This simplify the macros in include/libc-symbols.h.
2015-11-30bfin: fix clashing with newer gccWaldemar Brodkorb
See here for a discussion about the problem: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47779 Latest gcc/binutils git can generate a working uClibc-ng toolchain. Binaries tested on Arcturus uCBF54x board via chroot from original firmware.
2015-11-30bfin: use vfork.S againWaldemar Brodkorb
Actually revert 711ad9f92c1cf992c4a3d9f4f709bd692be7789c, as it breaks vfork() on real hardware. So the common implementation no longer works for bfin.
2015-11-13metag: add missing header fileWaldemar Brodkorb
When installing header files a warning is generated, because the header is mandatory.
2015-11-13i386: use socketcall even if newer linux exposes direct syscallsWaldemar Brodkorb
The changeset 9dea5dc921b5f4045a18c63eb92e84dc274d17eb in the Linux kernel expose the direct syscalls for sockets. For example udhcpc then will use sendto syscall directly and get an EINVAL error. Disable direct syscalls as it was done for SPARC in the past. Musl and GNU libc are not affected, as they already disable direct socket syscalls on i386. Reported-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
2015-11-08fanotify: include needed Linux definitionsWaldemar Brodkorb
To support older Linux kernel f.e. 2.6.32.68 include all required definitions. Copied from musl libc fanotify.h. Reported by Thomas Petazzoni from Buildroot project.
2015-11-08add support for euidaccess/eaccess legacy functionsWaldemar Brodkorb
Implementation taken from musl libc project. Missing functions recognized by buildroot autobuilders with failing open-vm-tools.
2015-11-03h8300: fix compile with 4.2.x kernelWaldemar Brodkorb
2015-10-22NPTL/ARCv2: Implement full memory barrier for NPTLVineet Gupta
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
2015-10-22alpha: add special umount2 handlingWaldemar Brodkorb
Only on Linux alpha __NR_oldumount is defined and a umount not umount2 syscall, but with two parameter is used. Add special handling for it and an alias for umount2() users. There was a discussion about this special handling, but it seems it was never committed upstream: http://marc.info/?l=linux-alpha&m=137455037930738&w=2 Runtime tested with qemu-alpha and a statically linked busybox binary.
2015-10-22alpha: fix kernel_stat structWaldemar Brodkorb
2015-10-22alpha: fix header nameWaldemar Brodkorb
2015-10-19lm32: add new architectureWaldemar Brodkorb
Add support for FPGA systems from Lattice Semiconductor http://www.latticesemi.com Merge https://github.com/m-labs/uclibc-lm32.git
2015-10-19mips: sync header with glibcWaldemar Brodkorb
Fixes following compile error, when UCLIBC_HAS_CONTEXT_FUNCS is enabled on a mips64 build: CC libc/sysdeps/linux/common/_exit.os libc/sysdeps/linux/mips/swapcontext.S: Assembler messages: libc/sysdeps/linux/mips/swapcontext.S:110: Error: Illegal operands `s.d fs6,(30*8+296)($4)' libc/sysdeps/linux/mips/swapcontext.S:111: Error: Illegal operands `s.d fs7,(31*8+296)($4)' libc/sysdeps/linux/mips/swapcontext.S:149: Error: Illegal operands `l.d fs6,(30*8+296)($2)' libc/sysdeps/linux/mips/swapcontext.S:150: Error: Illegal operands `l.d fs7,(31*8+296)($2)' Reported-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2015-10-16ia64: enable and fix compile issuesWaldemar Brodkorb
Enable ia64 in the menu. Fix build for architectures withou ld.so support. Fix syntax error in bits/byteswap.h.
2015-10-14syncfs: add system call supportBartosz Golaszewski
Add support for the syncfs() system call. Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2015-10-14fanotify: add system call supportBartosz Golaszewski
Add support for fanotify_init() and fanotify_mark() syscalls. The header file is taken from glibc. Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2015-10-12fix static binaries linked with pthread and compiled with sspWaldemar Brodkorb
Move TLS initialization for static builds up to the calling function as suggested by Daniel Fahlgren. Reported-By: Daniel Fahlgren <daniel@fahlgren.se>
2015-10-09add new architecture support for or1kWaldemar Brodkorb
Information about Openrisc: http://opencores.org/or1k/Main_Page Integrated from: https://github.com/openrisc/uClibc-or1k
2015-10-08xtensa: support call0 ABIMax Filippov
Most changes are mechanical replacement of 'retw' instruction with 'abi_ret' macro, defined to 'retw' or 'ret' according to ABI. Assembly code that makes calls is duplicated for call0 ABI with changed register numbers for parameters/return value and call instruction. 'entry' instructions are replaced with 'abi_entry' macro. More interesting changes: - non-leaf assembly functions (e.g. _dl_tlsdesc_dynamic, _dl_linux_resolve, SYSCALL_ERROR_HANDLER, PSEUDO) now need to preserve registers around intermediate calls they make, use temporary stack frame for that; - setjmp/longjmp only need to save and restore return address, stack pointer and callee-saved registers in the jmpbuf; - __clone and syscall functions had hardcoded offsets to parameter passed on stack, on call0 ABI they don't need stack frame, so the offset is different. Replace these offsets with FRAMESIZE macro. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
2015-10-05libc: posix_fallocate must return an error number on failureYuriy Kolerov
posix_fallocate implementation in uClibc relies on fallocate system call - it just returns what fallocate returns. However fallocate returns -1 on failure and assigns an error number to errno variable. In the same time posix_fallocate must return an error number but not -1. What does this patch: if fallocate returns -1 then posix_fallocate returns errno. Otherwise posix_fallocate returns 0 on success. However there is a side effect - posix_fallocate sets errno on failure because fallocate does it. But POSIX does not forbid it thus it's not a problem. Signed-off-by: Yuriy Kolerov <yuriy.kolerov@synopsys.com>
2015-10-05libc: fix sign extension in fallocate()Yuriy Kolerov
For common generic syscall ABI fallocate syscall handler in kernel expects a 64-bit signed arguments for offset and len. However uClibc has 2 wrappers for this syscall: fallocate and fallocate64. On 32-bit machines fallocate (not fallocate64) expects 32-bit values of offset and len. Thus in this case uClibc's fallocate must pass to the syscall those values with sign extension. High word of 64-bit value must be 0 or 0xFFFFFFFF depending on sign of the original 32-bit value (offset or len). It is how sign extansion works - all high bits of the negative value must be 1. So on 32-bit machines uClibc's fallocate does sign extension incorrectly when 32-bit values are passed (offset or len). It just fills the second word of 64-bit value by zeros. E.g. fallocate works incorrectly when offset or length is negative value - in this case kernel thinks that positive values are passed. Solution is to call fallocate64 from fallocate and pass 32-bit values of offset and len to fallocate64. off_t type is automatically converted to off64_t with an appropriate sign extension. Then fallocate64 invokes kernel's system call properly. This error is detected in LTP's test kernel/syscalls/fallocate02: ----------->8---------- fallocate(..., 1, -1024, 1024) failed, expected errno:22: TEST_ERRNO=0 fallocate(..., 1, 1024, -1024) failed, expected errno:22: TEST_ERRNO=0 fallocate(..., 1, 12288, -1024) failed, expected errno:22: TEST_ERRNO=0 fallocate(..., 1, -24576, 1024) failed, expected errno:22: TEST_ERRNO=0 ----------->8---------- fallocate does not emit an error because negative values are passed to the kernel without sign extension and kernel thinks that it got valid positive values. Signed-off-by: Yuriy Kolerov <yuriy.kolerov@synopsys.com>