summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarmelo Amoroso <carmelo.amoroso@st.com>2011-04-06 15:13:59 +0200
committerCarmelo Amoroso <carmelo.amoroso@st.com>2011-04-06 15:13:59 +0200
commit3b3285b1b7c02d36c74a6ae265fdb02ca991c96b (patch)
tree0f3bf060794323ff690f6f4a86dc903c4570f540
parent289d19f45d7f8af9a4079938a3426aafdd2674ba (diff)
parent85f4b028d767fc390a7b866d2f58d58be489242d (diff)
Merge remote-tracking branch 'origin/master' into prelink
* origin/master: (137 commits) utils/ldd: Check for returned pointer from strrchr not the value it holds cris: add provide arch-specific vfork implementation lutimes.c, stubs.c: fix compiling lutimes, if __NR_utimensat is not defined bump version to 0.9.32-rc3-git release 0.9.32-rc3 memalign: include sys/param.h for MAX arm/bits/atomic.h: Include common/bit/atomic.h for thumb1 wctype.h: fix libc_hidden_proto for iswupper and add it for iswspace add libc_hidden_proto for wcs[n]casecmp_l really fix missing __libc_drand48_data Revert "missing prototype of __libc_drand48_data fixed" missing prototype of __libc_drand48_data fixed time.c, time.h: remove unused hidden strftime/strptime nanosleep.c: remove duplicated libc_hidden_proto ctype.c, ctype.h: remove commented parts that were banned for removal after 0.9.31 _wctype.c, wctype.h: remove unused isw* and wctype_l hidden functions time.c, wchar.h: remove unused hidden wcsftime str[n]casecmp.c: fix hidden usage remove unused hidden functions frv/memset.S: add missing libc_hidden_def ... Conflicts: ldso/ldso/ldso.c Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
-rw-r--r--Makefile.in16
-rw-r--r--Makerules9
-rw-r--r--Rules.mak14
-rw-r--r--TODO69
-rw-r--r--extra/Configs/Config.arm2
-rw-r--r--extra/Configs/Config.c6x29
-rw-r--r--extra/Configs/Config.in28
-rw-r--r--extra/Configs/Config.in.arch6
-rw-r--r--extra/Configs/Config.sh1
-rw-r--r--include/alloca.h2
-rw-r--r--include/ctype.h7
-rw-r--r--include/elf.h45
-rw-r--r--include/errno.h12
-rw-r--r--include/fcntl.h3
-rw-r--r--include/features.h7
-rw-r--r--include/ftw.h4
-rw-r--r--include/langinfo.h7
-rw-r--r--include/libc-internal.h5
-rw-r--r--include/libintl.h5
-rw-r--r--include/link.h13
-rw-r--r--include/locale.h9
-rw-r--r--include/net/if_arp.h4
-rw-r--r--include/net/route.h4
-rw-r--r--include/netinet/ether.h1
-rw-r--r--include/netinet/icmp6.h4
-rw-r--r--include/netinet/in.h31
-rw-r--r--include/netinet/ip.h38
-rw-r--r--include/netinet/udp.h12
-rw-r--r--include/nl_types.h4
-rw-r--r--include/paths.h1
-rw-r--r--include/protocols/timed.h1
-rw-r--r--include/resolv.h20
-rw-r--r--include/sgtty.h6
-rw-r--r--include/signal.h11
-rw-r--r--include/stdint.h1
-rw-r--r--include/stdio.h1
-rw-r--r--include/stdlib.h55
-rw-r--r--include/string.h5
-rw-r--r--include/sys/wait.h30
-rw-r--r--include/time.h2
-rw-r--r--include/unistd.h2
-rw-r--r--include/wchar-stub.h1
-rw-r--r--include/wchar.h12
-rw-r--r--include/wctype.h4
-rw-r--r--include/xlocale.h31
-rw-r--r--ldso/include/dl-defs.h2
-rw-r--r--ldso/include/dl-elf.h18
-rw-r--r--ldso/include/dl-syscall.h2
-rw-r--r--ldso/ldso/Makefile.in1
-rw-r--r--ldso/ldso/bfin/dl-syscalls.h12
-rw-r--r--ldso/ldso/c6x/dl-debug.h49
-rw-r--r--ldso/ldso/c6x/dl-inlines.h91
-rw-r--r--ldso/ldso/c6x/dl-startup.h122
-rw-r--r--ldso/ldso/c6x/dl-syscalls.h25
-rw-r--r--ldso/ldso/c6x/dl-sysdep.h209
-rw-r--r--ldso/ldso/c6x/elfinterp.c296
-rw-r--r--ldso/ldso/c6x/resolve.S68
-rw-r--r--ldso/ldso/dl-elf.c50
-rw-r--r--ldso/ldso/i386/elfinterp.c2
-rw-r--r--ldso/ldso/ldso.c14
-rw-r--r--ldso/ldso/sparc/elfinterp.c2
-rw-r--r--ldso/ldso/x86_64/elfinterp.c2
-rw-r--r--ldso/libdl/Makefile.in1
-rw-r--r--ldso/libdl/libdl.c5
-rw-r--r--libc/Makefile.in1
-rw-r--r--libc/inet/getaddrinfo.c4
-rw-r--r--libc/inet/ifaddrs.c10
-rw-r--r--libc/inet/rpc/clnt_tcp.c1
-rw-r--r--libc/inet/rpc/clnt_udp.c1
-rw-r--r--libc/inet/rpc/clnt_unix.c1
-rw-r--r--libc/inet/rpc/sa_len.c4
-rw-r--r--libc/inet/rpc/svc.c1
-rw-r--r--libc/misc/ctype/ctype.c5
-rw-r--r--libc/misc/elf/dl-iterate-phdr.c4
-rw-r--r--libc/misc/fnmatch/fnmatch.c5
-rw-r--r--libc/misc/ftw/ftw.c4
-rw-r--r--libc/misc/internals/__uClibc_main.c32
-rw-r--r--libc/misc/internals/tempname.c5
-rw-r--r--libc/misc/locale/locale.c4
-rw-r--r--libc/misc/pthread/tsd.c1
-rw-r--r--libc/misc/regex/regcomp.c4
-rw-r--r--libc/misc/regex/regex_internal.c4
-rw-r--r--libc/misc/sysvipc/msgq.c2
-rw-r--r--libc/misc/sysvipc/sem.c2
-rw-r--r--libc/misc/sysvipc/shm.c2
-rw-r--r--libc/misc/time/time.c20
-rw-r--r--libc/misc/utmp/utent.c2
-rw-r--r--libc/misc/wctype/_wctype.c23
-rw-r--r--libc/stdio/_scanf.c1
-rw-r--r--libc/stdio/_vfprintf.c10
-rw-r--r--libc/stdio/fwprintf.c1
-rw-r--r--libc/stdlib/_strtod.c7
-rw-r--r--libc/stdlib/arc4random.c27
-rw-r--r--libc/stdlib/drand48-iter.c4
-rw-r--r--libc/stdlib/drand48.c4
-rw-r--r--libc/stdlib/erand48.c4
-rw-r--r--libc/stdlib/erand48_r.c3
-rw-r--r--libc/stdlib/jrand48.c4
-rw-r--r--libc/stdlib/jrand48_r.c3
-rw-r--r--libc/stdlib/lrand48.c4
-rw-r--r--libc/stdlib/malloc/memalign.c3
-rw-r--r--libc/stdlib/mrand48.c4
-rw-r--r--libc/stdlib/nrand48.c4
-rw-r--r--libc/stdlib/nrand48_r.c3
-rw-r--r--libc/stdlib/seed48.c4
-rw-r--r--libc/stdlib/srand48.c4
-rw-r--r--libc/stdlib/stdlib.c28
-rw-r--r--libc/string/_collate.c11
-rw-r--r--libc/string/ffs.c11
-rw-r--r--libc/string/ffsll.c36
-rw-r--r--libc/string/frv/memset.S1
-rw-r--r--libc/string/generic/memmem.c1
-rw-r--r--libc/string/generic/strcpy.c3
-rw-r--r--libc/string/memmem.c1
-rw-r--r--libc/string/stpncpy.c4
-rw-r--r--libc/string/strcasecmp.c4
-rw-r--r--libc/string/strchr.c7
-rw-r--r--libc/string/strchrnul.c2
-rw-r--r--libc/string/strcpy.c4
-rw-r--r--libc/string/strlcpy.c22
-rw-r--r--libc/string/strncasecmp.c4
-rw-r--r--libc/string/x86_64/memcpy.S4
-rw-r--r--libc/string/x86_64/memset.S6
-rw-r--r--libc/sysdeps/linux/alpha/bits/kernel_stat.h4
-rw-r--r--libc/sysdeps/linux/alpha/bits/sigstack.h2
-rw-r--r--libc/sysdeps/linux/alpha/bits/statvfs.h96
-rw-r--r--libc/sysdeps/linux/arm/aeabi_mb_cur_max.c4
-rw-r--r--libc/sysdeps/linux/arm/bits/atomic.h (renamed from libpthread/nptl/sysdeps/unix/sysv/linux/arm/bits/atomic.h)30
-rw-r--r--libc/sysdeps/linux/arm/bits/kernel_stat.h4
-rw-r--r--libc/sysdeps/linux/arm/posix_fadvise.c2
-rw-r--r--libc/sysdeps/linux/arm/posix_fadvise64.c2
-rw-r--r--libc/sysdeps/linux/avr32/bits/kernel_stat.h4
-rw-r--r--libc/sysdeps/linux/bfin/Makefile.arch2
-rw-r--r--libc/sysdeps/linux/bfin/__longjmp.S2
-rw-r--r--libc/sysdeps/linux/bfin/bits/kernel_stat.h4
-rw-r--r--libc/sysdeps/linux/bfin/bits/setjmp.h2
-rw-r--r--libc/sysdeps/linux/bfin/cacheflush.c14
-rw-r--r--libc/sysdeps/linux/bfin/dma-memcpy.c4
-rw-r--r--libc/sysdeps/linux/bfin/sram-alloc.c2
-rw-r--r--libc/sysdeps/linux/bfin/sram-free.c4
-rw-r--r--libc/sysdeps/linux/bfin/sys/cachectl.h25
-rw-r--r--libc/sysdeps/linux/c6x/Makefile13
-rw-r--r--libc/sysdeps/linux/c6x/Makefile.arch15
-rw-r--r--libc/sysdeps/linux/c6x/__longjmp.S47
-rw-r--r--libc/sysdeps/linux/c6x/_vfork.S66
-rw-r--r--libc/sysdeps/linux/c6x/bits/byteswap.h35
-rw-r--r--libc/sysdeps/linux/c6x/bits/elf-dsbt.h123
-rw-r--r--libc/sysdeps/linux/c6x/bits/endian.h11
-rw-r--r--libc/sysdeps/linux/c6x/bits/fcntl.h235
-rw-r--r--libc/sysdeps/linux/c6x/bits/kernel_stat.h49
-rw-r--r--libc/sysdeps/linux/c6x/bits/kernel_types.h46
-rw-r--r--libc/sysdeps/linux/c6x/bits/mathdef.h39
-rw-r--r--libc/sysdeps/linux/c6x/bits/nan.h57
-rw-r--r--libc/sysdeps/linux/c6x/bits/poll.h43
-rw-r--r--libc/sysdeps/linux/c6x/bits/resource.h209
-rw-r--r--libc/sysdeps/linux/c6x/bits/setjmp.h39
-rw-r--r--libc/sysdeps/linux/c6x/bits/sigcontextinfo.h26
-rw-r--r--libc/sysdeps/linux/c6x/bits/stackinfo.h28
-rw-r--r--libc/sysdeps/linux/c6x/bits/syscalls.h183
-rw-r--r--libc/sysdeps/linux/c6x/bits/uClibc_arch_features.h48
-rw-r--r--libc/sysdeps/linux/c6x/bits/wordsize.h19
-rw-r--r--libc/sysdeps/linux/c6x/brk.c54
-rw-r--r--libc/sysdeps/linux/c6x/bsd-_setjmp.s48
-rw-r--r--libc/sysdeps/linux/c6x/bsd-setjmp.S67
-rw-r--r--libc/sysdeps/linux/c6x/clone.S98
-rw-r--r--libc/sysdeps/linux/c6x/crt1.S67
-rw-r--r--libc/sysdeps/linux/c6x/crti.S17
-rw-r--r--libc/sysdeps/linux/c6x/crtn.S19
-rw-r--r--libc/sysdeps/linux/c6x/prctl.c43
-rw-r--r--libc/sysdeps/linux/c6x/pread_write.c103
-rw-r--r--libc/sysdeps/linux/c6x/setjmp.s43
-rw-r--r--libc/sysdeps/linux/c6x/sigaction.c115
-rw-r--r--libc/sysdeps/linux/c6x/sys/procfs.h122
-rw-r--r--libc/sysdeps/linux/c6x/sys/ptrace.h176
-rw-r--r--libc/sysdeps/linux/c6x/sys/reg.h26
-rw-r--r--libc/sysdeps/linux/c6x/sys/ucontext.h39
-rw-r--r--libc/sysdeps/linux/c6x/sys/user.h28
-rw-r--r--libc/sysdeps/linux/c6x/syscall.c49
-rw-r--r--libc/sysdeps/linux/common/Makefile.in130
-rw-r--r--libc/sysdeps/linux/common/__rt_sigtimedwait.c12
-rw-r--r--libc/sysdeps/linux/common/__rt_sigwaitinfo.c11
-rw-r--r--libc/sysdeps/linux/common/__syscall_fcntl.c1
-rw-r--r--libc/sysdeps/linux/common/bdflush.c6
-rw-r--r--libc/sysdeps/linux/common/bits/sigstack.h2
-rw-r--r--libc/sysdeps/linux/common/bits/sigthread.h8
-rw-r--r--libc/sysdeps/linux/common/bits/socket.h22
-rw-r--r--libc/sysdeps/linux/common/bits/statvfs.h6
-rw-r--r--libc/sysdeps/linux/common/bits/syscalls-common.h1
-rw-r--r--libc/sysdeps/linux/common/bits/types.h5
-rw-r--r--libc/sysdeps/linux/common/bits/uClibc_ctype.h2
-rw-r--r--libc/sysdeps/linux/common/bits/uClibc_errno.h43
-rw-r--r--libc/sysdeps/linux/common/capget.c6
-rw-r--r--libc/sysdeps/linux/common/capset.c7
-rw-r--r--libc/sysdeps/linux/common/create_module.c7
-rw-r--r--libc/sysdeps/linux/common/delete_module.c6
-rw-r--r--libc/sysdeps/linux/common/epoll.c18
-rw-r--r--libc/sysdeps/linux/common/fdatasync.c7
-rw-r--r--libc/sysdeps/linux/common/fork.c12
-rw-r--r--libc/sysdeps/linux/common/get_kernel_syms.c6
-rw-r--r--libc/sysdeps/linux/common/getegid.c22
-rw-r--r--libc/sysdeps/linux/common/geteuid.c21
-rw-r--r--libc/sysdeps/linux/common/getgid.c8
-rw-r--r--libc/sysdeps/linux/common/getpgrp.c8
-rw-r--r--libc/sysdeps/linux/common/getpid.c12
-rw-r--r--libc/sysdeps/linux/common/getppid.c8
-rw-r--r--libc/sysdeps/linux/common/getuid.c8
-rw-r--r--libc/sysdeps/linux/common/init_module.c6
-rw-r--r--libc/sysdeps/linux/common/longjmp.c4
-rw-r--r--libc/sysdeps/linux/common/lutimes.c2
-rw-r--r--libc/sysdeps/linux/common/nanosleep.c1
-rw-r--r--libc/sysdeps/linux/common/pivot_root.c6
-rw-r--r--libc/sysdeps/linux/common/posix_fadvise.c3
-rw-r--r--libc/sysdeps/linux/common/posix_fadvise64.c3
-rw-r--r--libc/sysdeps/linux/common/query_module.c7
-rw-r--r--libc/sysdeps/linux/common/sched_getaffinity.c6
-rw-r--r--libc/sysdeps/linux/common/sched_setaffinity.c11
-rw-r--r--libc/sysdeps/linux/common/signalfd.c6
-rw-r--r--libc/sysdeps/linux/common/sigsuspend.c2
-rw-r--r--libc/sysdeps/linux/common/splice.c7
-rw-r--r--libc/sysdeps/linux/common/ssp.c9
-rw-r--r--libc/sysdeps/linux/common/stubs.c187
-rw-r--r--libc/sysdeps/linux/common/sync_file_range.c6
-rw-r--r--libc/sysdeps/linux/common/sysdep.h5
-rw-r--r--libc/sysdeps/linux/common/umask.c2
-rw-r--r--libc/sysdeps/linux/common/umount.c9
-rw-r--r--libc/sysdeps/linux/common/umount2.c6
-rw-r--r--libc/sysdeps/linux/common/vmsplice.c7
-rw-r--r--libc/sysdeps/linux/common/xattr.c78
-rw-r--r--libc/sysdeps/linux/cris/Makefile.arch2
-rw-r--r--libc/sysdeps/linux/cris/bits/kernel_stat.h8
-rw-r--r--libc/sysdeps/linux/cris/vfork.S30
-rw-r--r--libc/sysdeps/linux/e1/bits/kernel_stat.h4
-rw-r--r--libc/sysdeps/linux/frv/bits/kernel_stat.h4
-rw-r--r--libc/sysdeps/linux/h8300/bits/kernel_stat.h4
-rw-r--r--libc/sysdeps/linux/hppa/bits/atomic.h103
-rw-r--r--libc/sysdeps/linux/hppa/bits/kernel_stat.h8
-rw-r--r--libc/sysdeps/linux/i386/bits/kernel_stat.h4
-rw-r--r--libc/sysdeps/linux/i386/bits/syscalls.h7
-rw-r--r--libc/sysdeps/linux/i386/posix_fadvise64.S9
-rw-r--r--libc/sysdeps/linux/ia64/bits/kernel_stat.h10
-rw-r--r--libc/sysdeps/linux/ia64/bits/sigstack.h2
-rw-r--r--libc/sysdeps/linux/m68k/bits/kernel_stat.h4
-rw-r--r--libc/sysdeps/linux/microblaze/bits/kernel_stat.h4
-rw-r--r--libc/sysdeps/linux/mips/bits/kernel_stat.h4
-rw-r--r--libc/sysdeps/linux/mips/bits/sigstack.h2
-rw-r--r--libc/sysdeps/linux/mips/bits/socket.h22
-rw-r--r--libc/sysdeps/linux/nios2/bits/kernel_stat.h4
-rw-r--r--libc/sysdeps/linux/nios2/bits/kernel_types.h6
-rw-r--r--libc/sysdeps/linux/powerpc/bits/kernel_stat.h4
-rw-r--r--libc/sysdeps/linux/powerpc/bits/termios.h2
-rw-r--r--libc/sysdeps/linux/sh/bits/kernel_stat.h4
-rw-r--r--libc/sysdeps/linux/sh64/bits/kernel_stat.h4
-rw-r--r--libc/sysdeps/linux/sparc/bits/kernel_stat.h4
-rw-r--r--libc/sysdeps/linux/sparc/bits/sigstack.h2
-rw-r--r--libc/sysdeps/linux/sparc/bits/socket.h22
-rw-r--r--libc/sysdeps/linux/sparc/bits/statvfs.h106
-rw-r--r--libc/sysdeps/linux/sparc/sigaction.c2
-rw-r--r--libc/sysdeps/linux/v850/bits/kernel_stat.h4
-rw-r--r--libc/sysdeps/linux/vax/bits/kernel_stat.h4
-rw-r--r--libc/sysdeps/linux/vax/bits/shm.h12
-rw-r--r--libc/sysdeps/linux/x86_64/bits/kernel_stat.h8
-rw-r--r--libc/sysdeps/linux/xtensa/bits/kernel_stat.h4
-rw-r--r--libcrypt/Makefile.in1
-rw-r--r--libm/Makefile.in1
-rw-r--r--libnsl/Makefile.in1
-rw-r--r--libpthread/linuxthreads.old/Makefile.in1
-rw-r--r--libpthread/linuxthreads.old/internals.h24
-rw-r--r--libpthread/linuxthreads.old/manager.c18
-rw-r--r--libpthread/linuxthreads.old/pthread.c23
-rw-r--r--libpthread/linuxthreads.old/signals.c1
-rw-r--r--libpthread/linuxthreads.old/sysdeps/c6x/pt-machine.h64
-rw-r--r--libpthread/linuxthreads/cancel.c2
-rw-r--r--libpthread/linuxthreads/manager.c10
-rw-r--r--libpthread/linuxthreads/ptcleanup.c4
-rw-r--r--libpthread/linuxthreads/pthread.c4
-rw-r--r--libpthread/linuxthreads/signals.c1
-rw-r--r--libpthread/nptl/allocatestack.c24
-rw-r--r--libpthread/nptl/init.c1
-rw-r--r--libpthread/nptl/pt-cleanup.c4
-rw-r--r--libpthread/nptl/pthreadP.h16
-rw-r--r--libpthread/nptl/sysdeps/generic/dl-tls.c2
-rw-r--r--libpthread/nptl/sysdeps/generic/libc-tls.c2
-rw-r--r--libpthread/nptl/sysdeps/pthread/bits/sigthread.h44
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arm/pt-gettimeofday.c2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-resume.c2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/jmp-unwind.c1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S10
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S2
-rw-r--r--libpthread/nptl/unwind.c5
-rw-r--r--libresolv/Makefile.in1
-rw-r--r--librt/Makefile.in1
-rw-r--r--librt/mq_receive.c34
-rw-r--r--librt/mq_send.c35
-rw-r--r--librt/rt_stubs.c39
-rw-r--r--libutil/Makefile.in1
-rw-r--r--utils/getconf.c1
-rw-r--r--utils/ldconfig.c2
-rw-r--r--utils/ldd.c2
303 files changed, 4825 insertions, 1354 deletions
diff --git a/Makefile.in b/Makefile.in
index 2cd226d96..0c1f414ec 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -206,8 +206,8 @@ $(top_builddir)extra/scripts/unifdef: $(top_srcdir)extra/scripts/unifdef.c
# a "y" here means the feature is enabled and so we should *not* rm it.
# if the option expands to nothing though, we can punt the headers.
HEADERS_RM- := \
- internal \
dl-osinfo.h \
+ hp-timing.h \
_lfs_64.h \
bits/uClibc_arch_features.h \
bits/kernel_sigaction.h \
@@ -215,14 +215,19 @@ HEADERS_RM- := \
bits/kernel_types.h \
bits/syscalls.h \
bits/syscalls-common.h \
- bits/uClibc_errno.h \
+ bits/uClibc_fpmax.h \
bits/uClibc_uintmaxtostr.h \
+ bits/uClibc_uwchar.h \
+ bits/uClibc_va_copy.h \
bits/sigcontextinfo.h \
bits/stackinfo.h \
tls.h \
rpc/des_crypt.h \
rpc/key_prot.h \
rpc/rpc_des.h
+ifeq ($(UCLIBC_STRICT_HEADERS),y)
+HEADERS_RM- += sgtty.h
+endif
HEADERS_RM-$(HAVE_SHARED) += dlfcn.h bits/dlfcn.h
HEADERS_RM-$(PTHREADS_DEBUG_SUPPORT) += thread_db.h
HEADERS_RM-$(UCLIBC_HAS_BSD_ERR) += err.h
@@ -232,7 +237,6 @@ HEADERS_RM-$(UCLIBC_HAS_FENV) += fenv.h bits/fenv.h bits/fenvinli
HEADERS_RM-$(UCLIBC_HAS_FLOATS) += complex.h fpu_control.h ieee754.h \
math.h \
tgmath.h \
- bits/uClibc_fpmax.h \
bits/math*.h
HEADERS_RM-$(findstring y,$(UCLIBC_HAS_FTW)$(UCLIBC_HAS_NFTW)) += ftw.h
HEADERS_RM-$(UCLIBC_HAS_GETTEXT_AWARENESS) += libintl.h
@@ -276,9 +280,7 @@ HEADERS_RM-$(UCLIBC_LINUX_SPECIFIC) += sys/fsuid.h sys/inotify.h sys/pe
HEADERS_RM-$(UCLIBC_SUPPORT_AI_ADDRCONFIG) += ifaddrs.h
HEADERS_RM-$(UCLIBC_SV4_DEPRECATED) += ustat.h sys/ustat.h bits/ustat.h
HEADERS_RM-$(UCLIBC_SUSV3_LEGACY) += sys/timeb.h regexp.h
-HEADERS_RM-$(UCLIBC_SUSV4_LEGACY) += utime.h
- # BREAKAGE: include/signal.h uses it, this rm broke bbox compile:
- ### ucontext.h
+HEADERS_RM-$(UCLIBC_SUSV4_LEGACY) += utime.h ucontext.h
ifneq ($(findstring install,$(MAKECMDGOALS)),)
$(addprefix $(PREFIX)$(DEVEL_PREFIX),include $(MULTILIB_DIR)):
@@ -327,6 +329,7 @@ ifeq ($(HARDWIRED_ABSPATH),y)
-e 's:$(SHARED_LIBNAME):$(RUNTIME_PREFIX)$(MULTILIB_DIR)/$(SHARED_LIBNAME):' \
-e 's:$(UCLIBC_LDSO):$(RUNTIME_PREFIX)$(MULTILIB_DIR)/$(UCLIBC_LDSO):' \
$(top_builddir)lib/libc.so > $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/libc.so; \
+ $(SED) -i -e 's://:/:g' $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/libc.so; \
fi
else
-$(INSTALL) -m 755 $(top_builddir)lib/libc.so $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/
@@ -345,6 +348,7 @@ ifeq ($(HARDWIRED_ABSPATH),y)
cp $(top_srcdir)extra/scripts/format.lds $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/libpthread.so; \
echo "GROUP ( $(RUNTIME_PREFIX)$(MULTILIB_DIR)/libpthread.so.$(ABI_VERSION) $(DEVEL_PREFIX)$(MULTILIB_DIR)/libpthread_nonshared.a )" \
>> $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/libpthread.so; \
+ $(SED) -i -e 's://:/:g' $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/libpthread.so; \
fi
else
-$(INSTALL) -m 755 $(top_builddir)lib/libpthread.so $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/
diff --git a/Makerules b/Makerules
index 6ef916c34..8d60a6201 100644
--- a/Makerules
+++ b/Makerules
@@ -306,7 +306,8 @@ endef
define link.so
$(Q)$(RM) $@ $@.$(2) $(dir $@)$(1)
@$(disp_ld)
- $(Q)$(CC) $(LDFLAGS-$(notdir $@)) -Wl,-soname=$(notdir $@).$(2) \
+ $(Q)$(CC) $(LDFLAGS-$(notdir $@)) $(LDFLAGS-y-$(@F)) \
+ -Wl,-soname=$(notdir $@).$(2) \
$(NOSTDLIB_CFLAGS) -o $(dir $@)$(1) $(START_FILE-$(notdir $@)) \
-Wl,--whole-archive $(firstword $^) -Wl,--no-whole-archive \
$(LIBS-$(notdir $@)) $(LIBGCC) $(END_FILE-$(notdir $@))
@@ -372,8 +373,14 @@ $(top_builddir)%.dep:
$(top_builddir)lib/interp.c: | $(top_builddir)lib
$(Q)echo "/* Force shared libraries to know about the correct library loader */" > $@.tmp
$(Q)echo "#include <features.h>" >> $@.tmp
+ifeq ($(HARDWIRED_ABSPATH),y)
$(Q)echo "const char __dl_ldso__[] attribute_hidden __attribute__ ((weak)) __attribute__ ((section " \
"(\".interp\"))) =\""$(RUNTIME_PREFIX)$(MULTILIB_DIR)/$(UCLIBC_LDSO)"\";" >> $@.tmp
+ $(Q)$(SED) -i -e 's://:/:g' $@.tmp
+else
+ $(Q)echo "const char __dl_ldso__[] attribute_hidden __attribute__ ((weak)) __attribute__ ((section " \
+ "(\".interp\"))) =\""$(UCLIBC_LDSO)"\";" >> $@.tmp
+endif
$(Q)mv $@.tmp $@
$(interp): $(top_builddir)lib/interp.c | $(sub_headers)
diff --git a/Rules.mak b/Rules.mak
index 8165ccabe..0aa684342 100644
--- a/Rules.mak
+++ b/Rules.mak
@@ -106,7 +106,7 @@ export RUNTIME_PREFIX DEVEL_PREFIX KERNEL_HEADERS MULTILIB_DIR
MAJOR_VERSION := 0
MINOR_VERSION := 9
SUBLEVEL := 32
-EXTRAVERSION :=-rc2-git
+EXTRAVERSION :=-rc3-git
VERSION := $(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL)
ABI_VERSION := $(MAJOR_VERSION)
ifneq ($(EXTRAVERSION),)
@@ -218,10 +218,12 @@ ifeq ($(UCLIBC_HAS_SOFT_FLOAT),y)
ifneq ($(TARGET_ARCH),nios)
ifneq ($(TARGET_ARCH),nios2)
ifneq ($(TARGET_ARCH),sh)
+ifneq ($(TARGET_ARCH),c6x)
CPU_CFLAGS-y += -msoft-float
endif
endif
endif
+endif
ifeq ($(TARGET_ARCH),arm)
# No longer needed with current toolchains, but leave it here for now.
# If anyone is actually still using gcc 2.95 (say), they can uncomment it.
@@ -239,6 +241,7 @@ CPU_LDFLAGS-$(ARCH_BIG_ENDIAN) += -Wl,-EB
PICFLAG-y := -fPIC
PICFLAG-$(UCLIBC_FORMAT_FDPIC_ELF) := -mfdpic
+PICFLAG-$(UCLIBC_FORMAT_DSBT_ELF) := -mdsbt -fpic
PICFLAG := $(PICFLAG-y)
PIEFLAG_NAME:=-fPIE
@@ -485,6 +488,15 @@ ifeq ($(TARGET_ARCH),v850)
SYMBOL_PREFIX=_
endif
+ifeq ($(TARGET_ARCH),c6x)
+ PIEFLAG:=
+ CPU_CFLAGS-$(CONFIG_TMS320C64X) += -march=c64x
+ CPU_CFLAGS-$(CONFIG_TMS320C64XPLUS) += -march=c64x+
+ CPU_CFLAGS-$(ARCH_LITTLE_ENDIAN)+=-mlittle-endian
+ CPU_CFLAGS-$(ARCH_BIG_ENDIAN)+=-mbig-endian
+ CPU_LDFLAGS-y += $(CPU_CFLAGS)
+endif
+
# Keep the check_gcc from being needlessly executed
ifndef PIEFLAG
export PIEFLAG:=$(call check_gcc,$(PIEFLAG_NAME),$(PICFLAG))
diff --git a/TODO b/TODO
index b94d5415f..ae305a550 100644
--- a/TODO
+++ b/TODO
@@ -9,49 +9,42 @@ TODO list for every uClibc release:
them in the include files as well by checking for the proper
define from include/bits/uClibc_config.h (pulled in from features.h)
-TODO list for the uClibc 0.9.31 release:
+TODO list for the uClibc 1.0.0 release:
-------------------------------------------------
- *) merge NPTL
- Settle cancellation
- support arches: (- todo; + done)
- + arm
- + sh
- + mips
- - i386
- - x86_64
- - ...
+ *) NPTL
+ support arches: (o todo; + done)
+ o alpha
+ + arm
+ o avr32
+ o bfin
+ o cris
+ o e1
+ o frv
+ o h8300
+ o hppa
+ + i386
+ o i960
+ o ia64
+ o m68k
+ o microblaze
+ + mips
+ o nios
+ o nios2
+ + powerpc
+ + sh
+ + sh64
+ o sparc
+ o v850
+ o vax
+ o x86_64
+ o xtensa
+ o ...
*) Go through SUSv4
TOC: http://www.opengroup.org/onlinepubs/9699919799/xrat/contents.html
shell (busybox): http://www.opengroup.org/onlinepubs/9699919799/xrat/V4_xcu_chap01.html#tag_22_01_01
interface:
http://www.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap13.html#tag_21_13_02
http://www.opengroup.org/onlinepubs/9699919799/xrat/V4_xsh_chap01.html#tag_23_01_01
-
-
-TODO list for the uClibc 0.9.29 release:
--------------------------------------------------
- *) as many of the arch-specific issues as possible
- *) Remove N instances of libc_hidden_proto() from uClibc internals.
- Instead add internal only header(s) defining all hidden prototypes.
- This will avoid clutter and guarantee prototype consistancy.
- *) The __is*_l() functions were all removed, such that we now only export
- the is*_l() functions (no prefix). Before, we had the prefixed versions
- for use by libstdc++ and weak versions without prefixes exported because
- those functions belong to no std (unless you call glibc a std). This should
- be fixed. Similar problems likely were created elsewhere.
- *) misc stdio bugs:
- http://bugs.uclibc.org/view.php?id=420
- http://bugs.uclibc.org/view.php?id=539
- *) bug in getopt handling:
- http://bugs.uclibc.org/view.php?id=61
- http://www.uclibc.org/lists/uclibc/2006-January/013851.html
- *) Should integrate test subdir better ... need to propagate CPU
- CFLAGS/LDFLAGS to the build/link for target binaries so that when we have
- a multilib toolchain, the proper ABI is selected.
-
-
-TODO list for the uClibc 1.0.0 release:
--------------------------------------------------
*) glob / fnmatch tests fail
*) regex should pass AT&T conformance tests
*) Finish hiding uClibc internal symbols from our exported namespace
@@ -80,8 +73,8 @@ TODO list for the uClibc 1.0.0 release:
and perhaps others (finalize list) produce a lib with a differing
ABI. Make it so apps cannot use an ABI mis-matched uClibc.
This is most easily done using symbol versioning...
- *) Implement the long double versions of math funcs
- using wrappers on top of the double versions (size / precision
+ *) Implement the long double versions of math funcs on interrested
+ arches using wrappers on top of the double versions (size / precision
trade off where size clearly wins).
*) Make all small objects (>~50 bytes) into either inlines or
into a static library
diff --git a/extra/Configs/Config.arm b/extra/Configs/Config.arm
index b060ace96..eb27a3391 100644
--- a/extra/Configs/Config.arm
+++ b/extra/Configs/Config.arm
@@ -14,7 +14,7 @@ config FORCE_OPTIONS_FOR_ARCH
choice
prompt "Target ABI"
- default CONFIG_ARM_OABI
+ default CONFIG_ARM_EABI
help
If you choose "EABI" here, functions and constants required by the
ARM EABI will be built into the library. You should choose "EABI"
diff --git a/extra/Configs/Config.c6x b/extra/Configs/Config.c6x
new file mode 100644
index 000000000..96adfb398
--- /dev/null
+++ b/extra/Configs/Config.c6x
@@ -0,0 +1,29 @@
+#
+# For a description of the syntax of this configuration file,
+# see extra/config/Kconfig-language.txt
+#
+
+config TARGET_ARCH
+ default "c6x"
+
+config FORCE_OPTIONS_FOR_ARCH
+ bool
+ default y
+ select ARCH_ANY_ENDIAN
+ select ARCH_HAS_NO_MMU
+
+choice
+ prompt "Target Processor Type"
+ default CONFIG_GENERIC_C6X
+
+config CONFIG_GENERIC_C6X
+ bool "Generic C6X DSP"
+
+config CONFIG_TMS320C64X
+ bool "TMS320C64X"
+
+config CONFIG_TMS320C64XPLUS
+ bool "TMS320C64X+"
+
+endchoice
+
diff --git a/extra/Configs/Config.in b/extra/Configs/Config.in
index 35ce854dd..8cbe31847 100644
--- a/extra/Configs/Config.in
+++ b/extra/Configs/Config.in
@@ -114,6 +114,9 @@ config TARGET_x86_64
config TARGET_xtensa
bool "xtensa"
+config TARGET_c6x
+ bool "c6x"
+
endchoice
@@ -219,6 +222,10 @@ if TARGET_xtensa
source "extra/Configs/Config.xtensa"
endif
+if TARGET_c6x
+source "extra/Configs/Config.c6x"
+endif
+
config TARGET_SUBARCH
string
default "e500" if CONFIG_E500
@@ -685,6 +692,17 @@ config UCLIBC_SUSV4_LEGACY
WARNING! ABI incompatibility.
+config UCLIBC_STRICT_HEADERS
+ bool "Enable structures and constants for unsupported features"
+ default n
+ help
+ Enable structures and constants in headers that should not be used,
+ because the respective feature is disabled.
+
+ WARNING! enabling this option requires to patch many faulty apps,
+ since they make (wrongly) use of these structures/constants,
+ although the feature was disabled.
+
config UCLIBC_HAS_STUBS
bool "Provide stubs for unavailable functionality"
default n
@@ -693,15 +711,6 @@ config UCLIBC_HAS_STUBS
functions which are impossible to implement on the target
architecture. Otherwise, such functions are simply omitted.
- As of 2008-07, this option makes uClibc provide fork() stub
- on NOMMU targets. It always sets errno to ENOSYS and returns -1.
-
- This may be useful if you port a lot of software and cannot
- audit all of it and replace or disable fork() usage.
- With this option, a program which uses fork() will build
- successfully. Of course, it may be useless if fork()
- is essential for its operation.
-
config UCLIBC_HAS_SHADOW
bool "Shadow Password Support"
default y
@@ -1525,6 +1534,7 @@ config UCLIBC_HAS_GLIBC_CUSTOM_PRINTF
help
Answer Y to support glibc's register_printf_function() to allow an
application to add its own printf conversion specifiers.
+ parse_printf_format() is also enabled.
NOTE: Limits the number or registered specifiers to 10.
NOTE: Requires new conversion specifiers to be ASCII
diff --git a/extra/Configs/Config.in.arch b/extra/Configs/Config.in.arch
index 8a02cb1a2..5f7a2b0c6 100644
--- a/extra/Configs/Config.in.arch
+++ b/extra/Configs/Config.in.arch
@@ -15,7 +15,11 @@ config UCLIBC_FORMAT_ELF
depends on ARCH_USE_MMU
config UCLIBC_FORMAT_FDPIC_ELF
bool "FDPIC ELF"
- depends on !ARCH_USE_MMU
+ depends on !ARCH_USE_MMU && (TARGET_bfin || TARGET_frv)
+ select DOPIC
+config UCLIBC_FORMAT_DSBT_ELF
+ bool "DBST ELF"
+ depends on !ARCH_USE_MMU && TARGET_c6x
select DOPIC
config UCLIBC_FORMAT_FLAT
bool "STATIC FLAT"
diff --git a/extra/Configs/Config.sh b/extra/Configs/Config.sh
index 10e9d8b0c..6ce54c265 100644
--- a/extra/Configs/Config.sh
+++ b/extra/Configs/Config.sh
@@ -41,7 +41,6 @@ config CONFIG_SH3
bool "SH3"
config CONFIG_SH4
- select FORCE_SHAREABLE_TEXT_SEGMENTS
bool "SH4"
endchoice
diff --git a/include/alloca.h b/include/alloca.h
index 2565b4835..4790b300b 100644
--- a/include/alloca.h
+++ b/include/alloca.h
@@ -67,6 +67,8 @@ extern void *alloca (size_t __size) __THROW;
# define extend_alloca(buf, len, newlen) \
alloca (((len) = (newlen)))
# endif
+
+extern int __libc_alloca_cutoff (size_t size);
#endif
__END_DECLS
diff --git a/include/ctype.h b/include/ctype.h
index dcfeb1b3e..d09f0526b 100644
--- a/include/ctype.h
+++ b/include/ctype.h
@@ -345,22 +345,15 @@ libc_hidden_proto(isascii_l)
# endif
/* Return the lowercase version of C in locale L. */
-/* "ordinary" ctype.h has no __tolower, why we try to have it?
- * remove after 0.9.31
- *extern int __tolower_l (int __c, __locale_t __l) __THROW; */
extern int tolower_l (int __c, __locale_t __l) __THROW;
libc_hidden_proto(tolower_l)
/* Return the uppercase version of C. */
-/*extern int __toupper_l (int __c, __locale_t __l) __THROW; */
extern int toupper_l (int __c, __locale_t __l) __THROW;
-libc_hidden_proto(toupper_l)
# if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus
# define tolower_l(c, locale) __tobody(c, tolower_l, (locale)->__ctype_tolower, (c, locale))
# define toupper_l(c, locale) __tobody(c, toupper_l, (locale)->__ctype_toupper, (c, locale))
-/*# define __tolower_l(c, locale) tolower_l((c), (locale)) */
-/*# define __toupper_l(c, locale) toupper_l((c), (locale)) */
# endif /* Optimizing gcc */
diff --git a/include/elf.h b/include/elf.h
index b86aa52be..d71691eb3 100644
--- a/include/elf.h
+++ b/include/elf.h
@@ -268,6 +268,7 @@ typedef struct
#define EM_ALTERA_NIOS2 113 /* Altera Nios II soft-core processor */
#define EM_CRX 114 /* National Semiconductor CRX */
#define EM_NUM 95
+#define EM_TI_C6000 140
/* If it is necessary to assign new unofficial EM_* values, please pick large
random numbers (0x8523, 0xa7f2, etc.) to minimize the chances of collision
@@ -3063,6 +3064,50 @@ typedef Elf32_Addr Elf32_Conflict;
/* Keep this the last entry. */
#define R_XTENSA_NUM 50
+/* C6X specific relocs */
+#define R_C6000_NONE 0
+#define R_C6000_ABS32 1
+#define R_C6000_ABS16 2
+#define R_C6000_ABS8 3
+#define R_C6000_PCR_S21 4
+#define R_C6000_PCR_S12 5
+#define R_C6000_PCR_S10 6
+#define R_C6000_PCR_S7 7
+#define R_C6000_ABS_S16 8
+#define R_C6000_ABS_L16 9
+#define R_C6000_ABS_H16 10
+#define R_C6000_SBR_U15_B 11
+#define R_C6000_SBR_U15_H 12
+#define R_C6000_SBR_U15_W 13
+#define R_C6000_SBR_S16 14
+#define R_C6000_SBR_L16_B 15
+#define R_C6000_SBR_L16_H 16
+#define R_C6000_SBR_L16_W 17
+#define R_C6000_SBR_H16_B 18
+#define R_C6000_SBR_H16_H 19
+#define R_C6000_SBR_H16_W 20
+#define R_C6000_SBR_GOT_U15_W 21
+#define R_C6000_SBR_GOT_L16_W 22
+#define R_C6000_SBR_GOT_H16_W 23
+#define R_C6000_DSBT_INDEX 24
+#define R_C6000_PREL31 25
+#define R_C6000_COPY 26
+#define R_C6000_JUMP_SLOT 27
+#define R_C6000_SBR_GOT32 28
+#define R_C6000_PCR_H16 29
+#define R_C6000_PCR_L16 30
+#define R_C6000_ALIGN 253
+#define R_C6000_FPHEAD 254
+#define R_C6000_NOCMP 255
+
+/* C6x specific values for the Dyn d_tag field. */
+#define DT_C6000_DSBT_BASE (DT_LOPROC + 0)
+#define DT_C6000_DSBT_SIZE (DT_LOPROC + 1)
+#define DT_C6000_PREEMPTMAP (DT_LOPROC + 2)
+#define DT_C6000_DSBT_INDEX (DT_LOPROC + 3)
+
+#define DT_C6000_NUM 4
+
#ifdef __cplusplus
}
#endif
diff --git a/include/errno.h b/include/errno.h
index 85268f053..7e1f583a8 100644
--- a/include/errno.h
+++ b/include/errno.h
@@ -58,7 +58,12 @@ extern const char *program_invocation_name, *program_invocation_short_name;
__END_DECLS
-#if defined _LIBC && defined __UCLIBC_HAS_TLS__
+#ifdef _LIBC
+#ifdef IS_IN_rtld
+# undef errno
+# define errno _dl_errno
+extern int _dl_errno; /* attribute_hidden */
+#elif defined __UCLIBC_HAS_TLS__
# if !defined NOT_IN_libc || defined IS_IN_libpthread
# undef errno
# ifndef NOT_IN_libc
@@ -73,10 +78,7 @@ extern __thread int errno attribute_tls_model_ie;
#ifndef __set_errno
#define __set_errno(val) (errno = (val))
#endif
-
-#ifndef __ASSEMBLER__
-extern int *__errno_location (void) __THROW __attribute__ ((__const__));
-#endif
+#endif /* _LIBC */
#endif /* _ERRNO_H */
diff --git a/include/fcntl.h b/include/fcntl.h
index 3a9873461..26ad1fe6d 100644
--- a/include/fcntl.h
+++ b/include/fcntl.h
@@ -234,7 +234,10 @@ extern int posix_fallocate64 (int __fd, __off64_t __offset, __off64_t __len);
# endif
#endif
+#ifdef _LIBC
extern int __fcntl_nocancel (int fd, int cmd, ...);
+libc_hidden_proto(__fcntl_nocancel)
+#endif
__END_DECLS
diff --git a/include/features.h b/include/features.h
index 1d47b5660..41e83a93f 100644
--- a/include/features.h
+++ b/include/features.h
@@ -198,9 +198,12 @@
# define __OPTIMIZE_SIZE__ 1
/* disable unsupported features */
-# undef _FORTIFY_SOURCE
# undef __LDBL_COMPAT
+# ifndef __UCLIBC_HAS_FORTIFY__
+# undef _FORTIFY_SOURCE
+# endif
+
# ifndef __UCLIBC_HAS_THREADS__
# if defined _REENTRANT || defined _THREAD_SAFE
# warning requested reentrant code, but thread support was disabled
@@ -433,7 +436,7 @@ uClibc was built without large file support enabled.
*/
#if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__ \
- && (defined __extern_inline || defined __GNUC_GNU_INLINE__)
+ && (defined __extern_inline || defined __GNUC_GNU_INLINE__ || defined __GNUC_STDC_INLINE__)
# define __USE_EXTERN_INLINES 1
#endif
diff --git a/include/ftw.h b/include/ftw.h
index 84f3e14a8..c79924dc8 100644
--- a/include/ftw.h
+++ b/include/ftw.h
@@ -129,7 +129,7 @@ typedef int (*__nftw64_func_t) (__const char *__filename,
# endif
#endif
-#if __UCLIBC_HAS_FTW__
+#ifdef __UCLIBC_HAS_FTW__
/* Call a function on every element in a directory tree.
This function is a possible cancellation point and therefore not
@@ -151,7 +151,7 @@ extern int ftw64 (__const char *__dir, __ftw64_func_t __func,
# endif
#endif
-#if __UCLIBC_HAS_NFTW__ && defined __USE_XOPEN_EXTENDED
+#if defined __UCLIBC_HAS_NFTW__ && defined __USE_XOPEN_EXTENDED
/* Call a function on every element in a directory tree. FLAG allows
to specify the behaviour more detailed.
diff --git a/include/langinfo.h b/include/langinfo.h
index 2e2ee4ec8..c7cddc0fc 100644
--- a/include/langinfo.h
+++ b/include/langinfo.h
@@ -1,5 +1,5 @@
/* Access to locale-dependent parameters.
- Copyright (C) 1995-2002,2003,2004,2005 Free Software Foundation, Inc.
+ Copyright (C) 1995-2002,2003,2004,2005,2009 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
@@ -352,6 +352,7 @@ enum
_NL_CTYPE_TRANSLIT_IGNORE_LEN,
_NL_CTYPE_TRANSLIT_IGNORE,
_NL_CTYPE_MAP_TO_NONASCII,
+ _NL_CTYPE_NONASCII_CASE,
_NL_CTYPE_EXTRA_MAP_1,
_NL_CTYPE_EXTRA_MAP_2,
_NL_CTYPE_EXTRA_MAP_3,
@@ -620,7 +621,7 @@ extern char *nl_langinfo (nl_item __item) __THROW;
libc_hidden_proto(nl_langinfo)
-#if defined __USE_GNU && defined __UCLIBC_HAS_XLOCALE__
+#if defined __USE_XOPEN2K && defined __UCLIBC_HAS_XLOCALE__
/* This interface is for the extended locale model. See <locale.h> for
more information. */
@@ -628,7 +629,7 @@ libc_hidden_proto(nl_langinfo)
# include <xlocale.h>
/* Just like nl_langinfo but get the information from the locale object L. */
-extern char *nl_langinfo_l (nl_item __item, __locale_t l);
+extern char *nl_langinfo_l (nl_item __item, __locale_t __l);
libc_hidden_proto(nl_langinfo_l)
#endif
diff --git a/include/libc-internal.h b/include/libc-internal.h
index 443b1fc50..3ac0b0509 100644
--- a/include/libc-internal.h
+++ b/include/libc-internal.h
@@ -65,6 +65,11 @@ libc_hidden_proto(__glibc_strerror_r)
/* internal access to program name */
extern const char *__uclibc_progname attribute_hidden;
+# ifdef __UCLIBC_HAS_FORTIFY__
+extern void __chk_fail(void) attribute_noreturn;
+libc_hidden_proto(__chk_fail)
+# endif
+
# endif /* IS_IN_libc */
#endif /* __ASSEMBLER__ */
diff --git a/include/libintl.h b/include/libintl.h
index ba57f1698..be3969fff 100644
--- a/include/libintl.h
+++ b/include/libintl.h
@@ -34,11 +34,6 @@
__BEGIN_DECLS
-#ifdef __UCLIBC_MJN3_ONLY__
-#warning "mjn3 FIXME: gettext has a prototype but isn't defined."
-#warning "mjn3 FIXME: __OPTIMIZE__ is never defined."
-#endif
-
/* Look up MSGID in the current default message catalog for the current
LC_MESSAGES locale. If not found, returns MSGID itself (the default
text). */
diff --git a/include/link.h b/include/link.h
index cbef6165a..185ee701e 100644
--- a/include/link.h
+++ b/include/link.h
@@ -1,6 +1,6 @@
/* Data structure for communication from the run-time dynamic linker for
loaded ELF shared objects.
- Copyright (C) 1995-2001, 2004, 2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1995-2001, 2004, 2005, 2006, 2010 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
@@ -83,6 +83,9 @@ extern ElfW(Dyn) _DYNAMIC[];
#ifdef __FDPIC__
# include <bits/elf-fdpic.h>
#endif
+#ifdef __DSBT__
+# include <bits/elf-dsbt.h>
+#endif
/* Structure describing a loaded shared object. The `l_next' and `l_prev'
members form a chain of all the shared objects loaded at startup.
@@ -98,8 +101,12 @@ struct link_map
#ifdef __FDPIC__
struct elf32_fdpic_loadaddr l_addr;
#else
+#ifdef __DSBT__
+ struct elf32_dsbt_loadaddr l_addr;
+#else
ElfW(Addr) l_addr; /* Base address shared object is loaded at. */
#endif
+#endif
char *l_name; /* Absolute file name object was found in. */
ElfW(Dyn) *l_ld; /* Dynamic section of the shared object. */
struct link_map *l_next, *l_prev; /* Chain of loaded objects. */
@@ -178,8 +185,12 @@ struct dl_phdr_info
#ifdef __FDPIC__
struct elf32_fdpic_loadaddr dlpi_addr;
#else
+#ifdef __DSBT__
+ struct elf32_dsbt_loadaddr dlpi_addr;
+#else
ElfW(Addr) dlpi_addr;
#endif
+#endif
const char *dlpi_name;
const ElfW(Phdr) *dlpi_phdr;
ElfW(Half) dlpi_phnum;
diff --git a/include/locale.h b/include/locale.h
index b740908f0..b79626a46 100644
--- a/include/locale.h
+++ b/include/locale.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,92,95-99,2000,01,02 Free Software Foundation, Inc.
+/* Copyright (C) 1991,1992,1995-2002,2007,2009 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
@@ -133,7 +133,7 @@ libc_hidden_proto(localeconv)
__END_NAMESPACE_STD
-#if defined __USE_GNU && defined __UCLIBC_HAS_LOCALE__
+#if defined __USE_XOPEN2K8 && 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
@@ -150,6 +150,7 @@ __END_NAMESPACE_STD
# include <xlocale.h>
#endif
+/* POSIX 2008 makes locale_t official. */
typedef __locale_t locale_t;
/* Return a reference to a data structure representing a set of locale
@@ -170,9 +171,6 @@ libc_hidden_proto(newlocale)
# define LC_COLLATE_MASK (1 << __LC_COLLATE)
# define LC_MONETARY_MASK (1 << __LC_MONETARY)
# define LC_MESSAGES_MASK (1 << __LC_MESSAGES)
-#ifdef L_newlocale
-#warning mask defines for extra locale categories
-#endif /* L_newlocale - uClibc note */
#ifdef LC_PAPER
# define LC_PAPER_MASK (1 << __LC_PAPER)
# define LC_NAME_MASK (1 << __LC_NAME)
@@ -206,7 +204,6 @@ libc_hidden_proto(newlocale)
/* Return a duplicate of the set of locale in DATASET. All usage
counters are increased if necessary. */
extern __locale_t duplocale (__locale_t __dataset) __THROW;
-libc_hidden_proto(duplocale)
/* Free the data associated with a locale dataset previously returned
by a call to `setlocale_r'. */
diff --git a/include/net/if_arp.h b/include/net/if_arp.h
index 9608652ee..97cb61f62 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,2006 Free Software Foundation, Inc.
+ Copyright (C) 1997,1999,2001,2006,2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -128,6 +128,8 @@ struct arphdr
#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_IEEE802154 804 /* IEEE 802.15.4 header. */
+#define ARPHRD_IEEE802154_PHY 805 /* IEEE 802.15.4 PHY header. */
#define ARPHRD_VOID 0xFFFF /* Void type, nothing is known. */
#define ARPHRD_NONE 0xFFFE /* Zero header length. */
diff --git a/include/net/route.h b/include/net/route.h
index da5c810c7..ea6c9b941 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -55,6 +55,7 @@ struct rtentry
#define rt_mss rt_mtu
+#if defined __UCLIBC_HAS_IPV6__ || !defined __UCLIBC_STRICT_HEADERS__
struct in6_rtmsg
{
struct in6_addr rtmsg_dst;
@@ -68,6 +69,7 @@ struct in6_rtmsg
u_int32_t rtmsg_flags;
int rtmsg_ifindex;
};
+#endif
#define RTF_UP 0x0001 /* Route usable. */
@@ -129,6 +131,7 @@ struct in6_rtmsg
#define RT_CLASS_MAX 255
+#if defined __UCLIBC_HAS_IPV6__ || !defined __UCLIBC_STRICT_HEADERS__
#define RTMSG_ACK NLMSG_ACK
#define RTMSG_OVERRUN NLMSG_OVERRUN
@@ -141,5 +144,6 @@ struct in6_rtmsg
#define RTMSG_CONTROL 0x40
#define RTMSG_AR_FAILED 0x51 /* Address Resolution failed. */
+#endif
#endif /* net/route.h */
diff --git a/include/netinet/ether.h b/include/netinet/ether.h
index 2e52679fa..bd9aa982b 100644
--- a/include/netinet/ether.h
+++ b/include/netinet/ether.h
@@ -45,7 +45,6 @@ extern struct ether_addr *ether_aton_r (__const char *__asc,
struct ether_addr *__addr) __THROW;
libc_hidden_proto(ether_aton_r)
-
/* Map 48 bit Ethernet number ADDR to HOSTNAME. */
extern int ether_ntohost (char *__hostname, __const struct ether_addr *__addr)
__THROW;
diff --git a/include/netinet/icmp6.h b/include/netinet/icmp6.h
index 225e49e07..8662cca8a 100644
--- a/include/netinet/icmp6.h
+++ b/include/netinet/icmp6.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-1997,2000,2006 Free Software Foundation, Inc.
+/* Copyright (C) 1991-1997,2000,2006,2009 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
@@ -339,7 +339,7 @@ struct nd_opt_home_agent_info
uint8_t nd_opt_home_agent_info_type;
uint8_t nd_opt_home_agent_info_len;
uint16_t nd_opt_home_agent_info_reserved;
- int16_t nd_opt_home_agent_info_preference;
+ uint16_t nd_opt_home_agent_info_preference;
uint16_t nd_opt_home_agent_info_lifetime;
};
diff --git a/include/netinet/in.h b/include/netinet/in.h
index 6327001ee..b42121ae3 100644
--- a/include/netinet/in.h
+++ b/include/netinet/in.h
@@ -194,6 +194,7 @@ struct in_addr
#define INADDR_MAX_LOCAL_GROUP ((in_addr_t) 0xe00000ff) /* 224.0.0.255 */
+#if defined __UCLIBC_HAS_IPV6__ || !defined __UCLIBC_STRICT_HEADERS__
/* IPv6 address */
struct in6_addr
{
@@ -212,14 +213,19 @@ struct in6_addr
#endif
};
+#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
+#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
+
+#define INET6_ADDRSTRLEN 46
+#endif
+
+#ifdef __UCLIBC_HAS_IPV6__
extern const struct in6_addr in6addr_any; /* :: */
extern const struct in6_addr in6addr_loopback; /* ::1 */
libc_hidden_proto(in6addr_loopback)
-#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
-#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
+#endif
#define INET_ADDRSTRLEN 16
-#define INET6_ADDRSTRLEN 46
#if 1 /*def __UCLIBC_HAS_IPV4__*/
@@ -238,6 +244,7 @@ struct sockaddr_in
};
#endif
+#if defined __UCLIBC_HAS_IPV6__ || !defined __UCLIBC_STRICT_HEADERS__
/* Ditto, for IPv6. */
struct sockaddr_in6
{
@@ -247,6 +254,7 @@ struct sockaddr_in6
struct in6_addr sin6_addr; /* IPv6 address */
uint32_t sin6_scope_id; /* IPv6 scope-id */
};
+#endif
#if defined __USE_MISC || defined __USE_GNU
@@ -274,6 +282,7 @@ struct ip_mreq_source
#endif
+#if defined __UCLIBC_HAS_IPV6__ || !defined __UCLIBC_STRICT_HEADERS__
/* Likewise, for IPv6. */
struct ipv6_mreq
{
@@ -283,6 +292,7 @@ struct ipv6_mreq
/* local interface */
unsigned int ipv6mr_interface;
};
+#endif
#if defined __USE_MISC || defined __USE_GNU
@@ -403,6 +413,7 @@ libc_hidden_proto(htons)
# endif
#endif
+#if defined __UCLIBC_HAS_IPV6__ || !defined __UCLIBC_STRICT_HEADERS__
#define IN6_IS_ADDR_UNSPECIFIED(a) \
(((__const uint32_t *) (a))[0] == 0 \
&& ((__const uint32_t *) (a))[1] == 0 \
@@ -441,6 +452,7 @@ libc_hidden_proto(htons)
&& (((__const uint32_t *) (a))[1] == ((__const uint32_t *) (b))[1]) \
&& (((__const uint32_t *) (a))[2] == ((__const uint32_t *) (b))[2]) \
&& (((__const uint32_t *) (a))[3] == ((__const uint32_t *) (b))[3]))
+#endif
#if defined __USE_MISC || defined __USE_GNU
/* Bind socket to a privileged IP port. */
@@ -455,6 +467,7 @@ extern int bindresvport6 (int __sockfd, struct sockaddr_in6 *__sock_in)
#endif
+#if defined __UCLIBC_HAS_IPV6__ || !defined __UCLIBC_STRICT_HEADERS__
#define IN6_IS_ADDR_MC_NODELOCAL(a) \
(IN6_IS_ADDR_MULTICAST(a) \
&& ((((__const uint8_t *) (a))[1] & 0xf) == 0x1))
@@ -474,9 +487,11 @@ extern int bindresvport6 (int __sockfd, struct sockaddr_in6 *__sock_in)
#define IN6_IS_ADDR_MC_GLOBAL(a) \
(IN6_IS_ADDR_MULTICAST(a) \
&& ((((__const uint8_t *) (a))[1] & 0xf) == 0xe))
+#endif
-#if defined __USE_GNU && defined __UCLIBC_HAS_IPV6__
+#ifdef __USE_GNU
+# if defined __UCLIBC_HAS_IPV6__ || !defined __UCLIBC_STRICT_HEADERS__
/* IPv6 packet information. */
struct in6_pktinfo
{
@@ -490,9 +505,9 @@ struct ip6_mtuinfo
struct sockaddr_in6 ip6m_addr; /* dst address including zone ID */
uint32_t ip6m_mtu; /* path MTU in host byte order */
};
-#endif
-#if 0 /*def __USE_GNU*/
+
+# if 0
/* Obsolete hop-by-hop and Destination Options Processing (RFC 2292). */
extern int inet6_option_space (int __nbytes)
__THROW __attribute_deprecated__;
@@ -540,8 +555,11 @@ extern int inet6_rth_reverse (__const void *__in, void *__out) __THROW;
extern int inet6_rth_segments (__const void *__bp) __THROW;
extern struct in6_addr *inet6_rth_getaddr (__const void *__bp, int __index)
__THROW;
+# endif
+# endif
+# if 0
/* Multicast source filter support. */
/* Get IPv4 source filter. */
@@ -571,6 +589,7 @@ extern int setsourcefilter (int __s, uint32_t __interface_addr,
socklen_t __grouplen, uint32_t __fmode,
uint32_t __numsrc,
__const struct sockaddr_storage *__slist) __THROW;
+# endif
#endif /* use GNU */
__END_DECLS
diff --git a/include/netinet/ip.h b/include/netinet/ip.h
index fc9144052..38bd7556d 100644
--- a/include/netinet/ip.h
+++ b/include/netinet/ip.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1991,92,93,95,96,97,98,99,2000 Free Software Foundation, Inc.
+/* Copyright (C) 1991,92,93,95,96,97,98,99,2000,2009 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
@@ -153,6 +154,41 @@ struct ip_timestamp
#define IP_MAXPACKET 65535 /* maximum packet size */
/*
+ * Definitions for Explicit Congestion Notification (ECN)
+ *
+ * Taken from RFC-3168, Section 5.
+ */
+
+#define IPTOS_ECN_MASK 0x03
+#define IPTOS_ECN(x) ((x) & IPTOS_ECN_MASK)
+#define IPTOS_ECN_NOT_ECT 0x00
+#define IPTOS_ECN_ECT1 0x01
+#define IPTOS_ECN_ECT0 0x02
+#define IPTOS_ECN_CE 0x03
+
+/*
+ * Definitions for IP differentiated services code points (DSCP)
+ *
+ * Taken from RFC-2597, Section 6 and RFC-2598, Section 2.3.
+ */
+
+#define IPTOS_DSCP_MASK 0xfc
+#define IPTOS_DSCP(x) ((x) & IPTOS_DSCP_MASK)
+#define IPTOS_DSCP_AF11 0x28
+#define IPTOS_DSCP_AF12 0x30
+#define IPTOS_DSCP_AF13 0x38
+#define IPTOS_DSCP_AF21 0x48
+#define IPTOS_DSCP_AF22 0x50
+#define IPTOS_DSCP_AF23 0x58
+#define IPTOS_DSCP_AF31 0x68
+#define IPTOS_DSCP_AF32 0x70
+#define IPTOS_DSCP_AF33 0x78
+#define IPTOS_DSCP_AF41 0x88
+#define IPTOS_DSCP_AF42 0x90
+#define IPTOS_DSCP_AF43 0x98
+#define IPTOS_DSCP_EF 0xb8
+
+/*
* Definitions for IP type of service (ip_tos)
*/
#define IPTOS_TOS_MASK 0x1E
diff --git a/include/netinet/udp.h b/include/netinet/udp.h
index 45b69f749..ae1beb9e1 100644
--- a/include/netinet/udp.h
+++ b/include/netinet/udp.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 92, 93, 95, 96, 97, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 1991-1993,1995-1997,2004,2009 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
@@ -74,6 +74,16 @@ struct udphdr
};
#endif
+/* UDP socket options */
+#define UDP_CORK 1 /* Never send partially complete segments. */
+#define UDP_ENCAP 100 /* Set the socket to accept
+ encapsulated packets. */
+
+/* UDP encapsulation types */
+#define UDP_ENCAP_ESPINUDP_NON_IKE 1 /* draft-ietf-ipsec-nat-t-ike-00/01 */
+#define UDP_ENCAP_ESPINUDP 2 /* draft-ietf-ipsec-udp-encaps-06 */
+#define UDP_ENCAP_L2TPINUDP 3 /* rfc2661 */
+
#define SOL_UDP 17 /* sockopt level for UDP */
#endif /* netinet/udp.h */
diff --git a/include/nl_types.h b/include/nl_types.h
index d6d48ecd9..e54612af7 100644
--- a/include/nl_types.h
+++ b/include/nl_types.h
@@ -21,11 +21,13 @@
#include <features.h>
+#ifndef __UCLIBC_STRICT_HEADERS__
/* The default message set used by the gencat program. */
#define NL_SETD 1
/* Value for FLAG parameter of `catgets' to say we want XPG4 compliance. */
#define NL_CAT_LOCALE 1
+#endif
__BEGIN_DECLS
@@ -34,8 +36,10 @@ __BEGIN_DECLS
#warning "mjn3 FIXME: None of these prototypes have implementations."
#endif
+#ifndef __UCLIBC_STRICT_HEADERS__
/* Message catalog descriptor type. */
typedef void *nl_catd;
+#endif
/* Type used by `nl_langinfo'. */
typedef int nl_item;
diff --git a/include/paths.h b/include/paths.h
index 305937fc5..0b4035d22 100644
--- a/include/paths.h
+++ b/include/paths.h
@@ -44,6 +44,7 @@
#define _PATH_DEVDB "/var/run/dev.db"
#define _PATH_DEVNULL "/dev/null"
#define _PATH_DRUM "/dev/drum"
+#define _PATH_GSHADOW "/etc/gshadow"
#define _PATH_KLOG "/proc/kmsg"
#define _PATH_KMEM "/dev/kmem"
#define _PATH_LASTLOG "/var/log/lastlog"
diff --git a/include/protocols/timed.h b/include/protocols/timed.h
index 8101e9924..f50061cc1 100644
--- a/include/protocols/timed.h
+++ b/include/protocols/timed.h
@@ -32,6 +32,7 @@
#ifndef _PROTOCOLS_TIMED_H
#define _PROTOCOLS_TIMED_H 1
+#include <features.h>
#ifdef __UCLIBC_HAS_RPC__
#include <rpc/types.h>
#endif
diff --git a/include/resolv.h b/include/resolv.h
index b9ce1e2a2..cba26f004 100644
--- a/include/resolv.h
+++ b/include/resolv.h
@@ -282,46 +282,61 @@ extern struct __res_state *__res_state(void) __attribute__ ((__const__));
__END_DECLS
#define _res (*__res_state())
+#if 0
#define fp_nquery __fp_nquery
#define fp_query __fp_query
#define hostalias __hostalias
#define p_query __p_query
+#endif
#define res_close __res_close
#define res_init __res_init
+#if 0
#define res_isourserver __res_isourserver
#define res_mkquery __res_mkquery
+#endif
#define res_query __res_query
#define res_querydomain __res_querydomain
#define res_search __res_search
+#if 0
#define res_send __res_send
+#endif
__BEGIN_DECLS
+#if 0
void fp_nquery (const u_char *, int, FILE *) __THROW;
void fp_query (const u_char *, FILE *) __THROW;
const char * hostalias (const char *) __THROW;
void p_query (const u_char *) __THROW;
+#endif
#ifdef __UCLIBC_HAS_BSD_RES_CLOSE__
void res_close (void) __THROW;
#endif
int res_init (void) __THROW;
libc_hidden_proto(res_init)
+#if 0
int res_isourserver (const struct sockaddr_in *) __THROW;
int res_mkquery (int, const char *, int, int, const u_char *,
int, const u_char *, u_char *, int) __THROW;
+#endif
int res_query (const char *, int, int, u_char *, int) __THROW;
libc_hidden_proto(res_query)
int res_querydomain (const char *, const char *, int, int,
u_char *, int) __THROW;
libc_hidden_proto(res_querydomain)
int res_search (const char *, int, int, u_char *, int) __THROW;
+#if 0
int res_send (const u_char *, int, u_char *, int) __THROW;
+#endif
__END_DECLS
+#if 0
#define b64_ntop __b64_ntop
#define b64_pton __b64_pton
#define dn_comp __dn_comp
#define dn_count_labels __dn_count_labels
+#endif
#define dn_expand __dn_expand
+#if 0
#define dn_skipname __dn_skipname
#define fp_resstat __fp_resstat
#define loc_aton __loc_aton
@@ -359,7 +374,9 @@ __END_DECLS
#define sym_ntop __sym_ntop
#define sym_ntos __sym_ntos
#define sym_ston __sym_ston
+#endif
__BEGIN_DECLS
+#if 0
int res_hnok (const char *) __THROW;
int res_ownok (const char *) __THROW;
int res_mailok (const char *) __THROW;
@@ -389,8 +406,10 @@ char * p_secstodate (u_long) __THROW;
int dn_count_labels (const char *) __THROW;
int dn_comp (const char *, u_char *, int, u_char **, u_char **)
__THROW;
+#endif
int dn_expand (const u_char *, const u_char *, const u_char *,
char *, int) __THROW;
+#if 0
u_int res_randomid (void) __THROW;
int res_nameinquery (const char *, int, int,
const u_char *, const u_char *) __THROW;
@@ -418,6 +437,7 @@ int res_nmkquery (res_state, int, const char *, int, int,
int res_nsend (res_state, const u_char *, int, u_char *, int)
__THROW;
void res_nclose (res_state) __THROW;
+#endif
__END_DECLS
# if _LIBC
diff --git a/include/sgtty.h b/include/sgtty.h
index 5b2bc4184..f773c3123 100644
--- a/include/sgtty.h
+++ b/include/sgtty.h
@@ -19,21 +19,27 @@
#ifndef _SGTTY_H
#define _SGTTY_H 1
+#warning useless header on uClibc
+
#include <features.h>
#include <sys/ioctl.h>
+#ifndef __UCLIBC_STRICT_HEADERS__
/* On some systems this type is not defined by <bits/ioctl-types.h>;
in that case, the functions are just stubs that return ENOSYS. */
struct sgttyb;
+#endif
__BEGIN_DECLS
+#if 0
/* Fill in *PARAMS with terminal parameters associated with FD. */
extern int gtty (int __fd, struct sgttyb *__params) __THROW;
/* Set the terminal parameters associated with FD to *PARAMS. */
extern int stty (int __fd, __const struct sgttyb *__params) __THROW;
+#endif
__END_DECLS
diff --git a/include/signal.h b/include/signal.h
index 0a09c7ad4..37ed29780 100644
--- a/include/signal.h
+++ b/include/signal.h
@@ -310,6 +310,9 @@ extern int sigwait (__const sigset_t *__restrict __set, int *__restrict __sig)
__THROW. */
extern int sigwaitinfo (__const sigset_t *__restrict __set,
siginfo_t *__restrict __info) __nonnull ((1));
+#ifdef _LIBC
+extern __typeof(sigwaitinfo) __sigwaitinfo attribute_hidden;
+#endif
libc_hidden_proto(sigwaitinfo)
/* Select any of pending signals from SET and place information in INFO.
@@ -321,6 +324,9 @@ extern int sigtimedwait (__const sigset_t *__restrict __set,
siginfo_t *__restrict __info,
__const struct timespec *__restrict __timeout)
__nonnull ((1));
+#ifdef _LIBC
+extern __typeof(sigtimedwait) __sigtimedwait attribute_hidden;
+#endif
libc_hidden_proto(sigtimedwait)
/* Send signal SIG to the process PID. Associate data in VAL with the
@@ -386,14 +392,17 @@ extern int siginterrupt (int __sig, int __interrupt) __THROW;
# include <bits/sigstack.h>
# ifdef __USE_XOPEN
/* This will define `ucontext_t' and `mcontext_t'. */
-# include <ucontext.h>
+/* SuSv4 obsoleted include/ucontext.h */
+# include <sys/ucontext.h>
# endif
+# if 0
/* Run signals handlers on the stack specified by SS (if not NULL).
If OSS is not NULL, it is filled in with the old signal stack status.
This interface is obsolete and on many platform not implemented. */
extern int sigstack (struct sigstack *__ss, struct sigstack *__oss)
__THROW __attribute_deprecated__;
+# endif
/* Alternate signal handler stack interface.
This interface should always be preferred over `sigstack'. */
diff --git a/include/stdint.h b/include/stdint.h
index 465a1b5bc..a0d7da947 100644
--- a/include/stdint.h
+++ b/include/stdint.h
@@ -238,6 +238,7 @@ typedef unsigned long long int uintmax_t;
# define UINTPTR_MAX (4294967295U)
# endif
+
#if !defined(__H8300H__) && !defined(__H8300S__)
/* Minimum for largest signed integral type. */
# define INTMAX_MIN (-__INT64_C(9223372036854775807)-1)
diff --git a/include/stdio.h b/include/stdio.h
index 3c86f256b..45d3e4991 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -450,7 +450,6 @@ libc_hidden_proto(vfscanf)
marked with __THROW. */
extern int vscanf (__const char *__restrict __format, __gnuc_va_list __arg)
__attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
-libc_hidden_proto(vscanf)
/* Read formatted input from S into argument list ARG. */
extern int vsscanf (__const char *__restrict __s,
diff --git a/include/stdlib.h b/include/stdlib.h
index 300edf04a..e9a8b84c2 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -50,9 +50,9 @@ __BEGIN_DECLS
as well as POSIX.1 use of `int' for the status word. */
# if defined __GNUC__ && !defined __cplusplus
-# define __WAIT_INT(status) \
- (__extension__ ({ union { __typeof(status) __in; int __i; } __u; \
- __u.__in = (status); __u.__i; }))
+# define __WAIT_INT(status) \
+ (__extension__ (((union { __typeof(status) __in; int __i; }) \
+ { .__in = (status) }).__i))
# else
# define __WAIT_INT(status) (*(int *) &(status))
# endif
@@ -143,9 +143,11 @@ __END_NAMESPACE_C99
extern size_t __ctype_get_mb_cur_max (void) __THROW __wur;
#else
#ifdef __UCLIBC_HAS_WCHAR__
-#define MB_CUR_MAX (_stdlib_mb_cur_max ())
+# 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)
+#else
+# define MB_CUR_MAX 1
#endif
#endif
@@ -163,7 +165,6 @@ libc_hidden_proto(atoi)
/* Convert a string to a long integer. */
extern long int atol (__const char *__nptr)
__THROW __attribute_pure__ __nonnull ((1)) __wur;
-libc_hidden_proto(atol)
__END_NAMESPACE_STD
#if defined __USE_ISOC99 || defined __USE_MISC
@@ -244,14 +245,14 @@ __END_NAMESPACE_C99
#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
+ information from several different locales. Another problem is
the implementation of the internationalization handling in the
- upcoming ISO C++ standard library. To support this another set of
- the functions using locale data exist which have an additional
+ ISO C++ standard library. To support this another set of
+ the functions using locale data exist which take an additional
argument.
- Attention: all these functions are *not* standardized in any form.
- This is a proof-of-concept implementation. */
+ Attention: even though several *_l interfaces are part of POSIX:2008,
+ these are not. */
/* Structure for reentrant locale using functions. This is an
(almost) opaque type for the user level programs. */
@@ -347,10 +348,16 @@ struct random_data
int32_t *fptr; /* Front pointer. */
int32_t *rptr; /* Rear pointer. */
int32_t *state; /* Array of state values. */
+#if 0
+ int rand_type; /* Type of random number generator. */
+ int rand_deg; /* Degree of random number generator. */
+ int rand_sep; /* Distance between front and rear. */
+#else
/* random_r.c, TYPE_x, DEG_x, SEP_x - small enough for int8_t */
int8_t rand_type; /* Type of random number generator. */
int8_t rand_deg; /* Degree of random number generator. */
int8_t rand_sep; /* Distance between front and rear. */
+#endif
int32_t *end_ptr; /* Pointer behind state table. */
};
@@ -540,7 +547,7 @@ extern int on_exit (void (*__func) (int __status, void *__arg), void *__arg)
__BEGIN_NAMESPACE_STD
/* Call all functions registered with `atexit' and `on_exit',
- in the reverse of the order in which they were registered
+ in the reverse of the order in which they were registered,
perform stdio cleanup, and terminate program execution with STATUS. */
extern void exit (int __status) __THROW __attribute__ ((__noreturn__));
libc_hidden_proto(exit)
@@ -619,7 +626,7 @@ extern char *mktemp (char *__template) __THROW __nonnull ((1)) __wur;
Returns a file descriptor open on the file for reading and writing,
or -1 if it cannot create a uniquely-named file.
- This function is a possible cancellation points and therefore not
+ This function is a possible cancellation point and therefore not
marked with __THROW. */
# ifndef __USE_FILE_OFFSET64
extern int mkstemp (char *__template) __nonnull ((1)) __wur;
@@ -636,7 +643,7 @@ extern int mkstemp64 (char *__template) __nonnull ((1)) __wur;
# endif
#endif
-#ifdef __USE_BSD
+#if defined __USE_BSD || defined __USE_XOPEN2K8
/* Create a unique temporary directory from TEMPLATE.
The last six characters of TEMPLATE must be "XXXXXX";
they are replaced with a string that makes the directory name unique.
@@ -662,14 +669,17 @@ extern char *canonicalize_file_name (__const char *__name)
__THROW __nonnull ((1)) __wur;
#endif
-/* Return the canonical absolute name of file NAME. If the
- canonical name is PATH_MAX chars or more, returns null
- with `errno' set to ENAMETOOLONG; if the name fits in
- fewer than PATH_MAX chars, returns the name in RESOLVED. */
-/* we choose to handle __resolved==NULL as crash :) */
+#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
+ ENAMETOOLONG; if the name fits in fewer than PATH_MAX chars,
+ returns the name in RESOLVED. */
extern char *realpath (__const char *__restrict __name,
char *__restrict __resolved) __THROW __wur;
libc_hidden_proto(realpath)
+#endif
+
/* Shorthand for type of comparison functions. */
#ifndef __COMPAR_FN_T
@@ -852,6 +862,7 @@ libc_hidden_proto(posix_openpt)
#ifdef __USE_XOPEN
/* The next four functions all take a master pseudo-tty fd and
perform an operation on the associated slave: */
+
#ifdef __UCLIBC_HAS_PTY__
/* Chown the slave to the calling user. */
extern int grantpt (int __fd) __THROW;
@@ -894,10 +905,16 @@ extern int getloadavg (double __loadavg[], int __nelem)
#include <stdint.h>
extern uint32_t arc4random(void);
extern void arc4random_stir(void);
-libc_hidden_proto(arc4random_stir)
extern void arc4random_addrandom(unsigned char *, int);
#endif
+#ifdef _LIBC
+extern int __drand48_iterate (unsigned short int xsubi[3], struct drand48_data *buffer) attribute_hidden;
+
+/* Global state for non-reentrant functions. */
+extern struct drand48_data __libc_drand48_data attribute_hidden;
+#endif
+
#endif /* don't just need malloc and calloc */
#undef __need_malloc_and_calloc
diff --git a/include/string.h b/include/string.h
index ca22055ed..f11a7269c 100644
--- a/include/string.h
+++ b/include/string.h
@@ -124,7 +124,6 @@ libc_hidden_proto(strcoll)
extern size_t strxfrm (char *__restrict __dest,
__const char *__restrict __src, size_t __n)
__THROW __nonnull ((2));
-libc_hidden_proto(strxfrm)
__END_NAMESPACE_STD
#if defined __USE_GNU && defined __UCLIBC_HAS_XLOCALE__
@@ -257,7 +256,6 @@ libc_hidden_proto(strcasestr)
extern void *memmem (__const void *__haystack, size_t __haystacklen,
__const void *__needle, size_t __needlelen)
__THROW __attribute_pure__ __nonnull ((1, 3));
-libc_hidden_proto(memmem)
/* Copy N bytes of SRC to DEST, return pointer to bytes after the
last written byte. */
@@ -378,7 +376,7 @@ libc_hidden_proto(ffs)
/* The following two functions are non-standard but necessary for non-32 bit
platforms. */
-# if 0 /*#ifdef __USE_GNU*/
+#ifdef __USE_GNU
extern int ffsl (long int __l) __THROW __attribute__ ((__const__));
# ifdef __GNUC__
__extension__ extern int ffsll (long long int __ll)
@@ -449,7 +447,6 @@ extern char *__stpncpy (char *__restrict __dest,
extern char *stpncpy (char *__restrict __dest,
__const char *__restrict __src, size_t __n)
__THROW __nonnull ((1, 2));
-libc_hidden_proto(stpncpy)
# if 0 /* uClibc does not support strfry or memfrob. */
/* Sautee STRING briskly. */
diff --git a/include/sys/wait.h b/include/sys/wait.h
index f283fe228..16893c0b9 100644
--- a/include/sys/wait.h
+++ b/include/sys/wait.h
@@ -1,5 +1,5 @@
-/* Copyright (C) 1991-1994,1996-2001,2003,2004,2005
- Free Software Foundation, Inc.
+/* Copyright (C) 1991-1994,1996-2001,2003,2004,2005,2007,2009
+ 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
@@ -51,7 +51,7 @@ __BEGIN_DECLS
# endif
/* This is the type of the argument to `wait'. The funky union
- causes redeclarations with ether `int *' or `union wait *' to be
+ causes redeclarations with either `int *' or `union wait *' to be
allowed without complaint. __WAIT_STATUS_DEFN is the type used in
the actual function definitions. */
@@ -79,22 +79,22 @@ typedef union
/* This will define all the `__W*' macros. */
# include <bits/waitstatus.h>
-# define WEXITSTATUS(status) __WEXITSTATUS(__WAIT_INT(status))
-# define WTERMSIG(status) __WTERMSIG(__WAIT_INT(status))
-# define WSTOPSIG(status) __WSTOPSIG(__WAIT_INT(status))
-# define WIFEXITED(status) __WIFEXITED(__WAIT_INT(status))
-# define WIFSIGNALED(status) __WIFSIGNALED(__WAIT_INT(status))
-# define WIFSTOPPED(status) __WIFSTOPPED(__WAIT_INT(status))
+# define WEXITSTATUS(status) __WEXITSTATUS (__WAIT_INT (status))
+# define WTERMSIG(status) __WTERMSIG (__WAIT_INT (status))
+# define WSTOPSIG(status) __WSTOPSIG (__WAIT_INT (status))
+# define WIFEXITED(status) __WIFEXITED (__WAIT_INT (status))
+# define WIFSIGNALED(status) __WIFSIGNALED (__WAIT_INT (status))
+# define WIFSTOPPED(status) __WIFSTOPPED (__WAIT_INT (status))
# ifdef __WIFCONTINUED
-# define WIFCONTINUED(status) __WIFCONTINUED(__WAIT_INT(status))
+# define WIFCONTINUED(status) __WIFCONTINUED (__WAIT_INT (status))
# endif
#endif /* <stdlib.h> not included. */
#ifdef __USE_BSD
# define WCOREFLAG __WCOREFLAG
-# define WCOREDUMP(status) __WCOREDUMP(__WAIT_INT(status))
-# define W_EXITCODE(ret, sig) __W_EXITCODE(ret, sig)
-# define W_STOPCODE(sig) __W_STOPCODE(sig)
+# define WCOREDUMP(status) __WCOREDUMP (__WAIT_INT (status))
+# define W_EXITCODE(ret, sig) __W_EXITCODE (ret, sig)
+# define W_STOPCODE(sig) __W_STOPCODE (sig)
#endif
/* The following values are used by the `waitid' function. */
@@ -172,10 +172,6 @@ extern __pid_t wait3 (__WAIT_STATUS __stat_loc, int __options,
#endif
#ifdef __USE_BSD
-/* This being here makes the prototypes valid whether or not
- we have already included <sys/resource.h> to define `struct rusage'. */
-struct rusage;
-
/* PID is like waitpid. Other args are like wait3. */
extern __pid_t wait4 (__pid_t __pid, __WAIT_STATUS __stat_loc, int __options,
struct rusage *__usage) __THROW;
diff --git a/include/time.h b/include/time.h
index 7fcdf68e6..65071a908 100644
--- a/include/time.h
+++ b/include/time.h
@@ -207,7 +207,6 @@ extern time_t mktime (struct tm *__tp) __THROW;
extern size_t strftime (char *__restrict __s, size_t __maxsize,
__const char *__restrict __format,
__const struct tm *__restrict __tp) __THROW;
-libc_hidden_proto(strftime)
__END_NAMESPACE_STD
# ifdef __USE_XOPEN
@@ -216,7 +215,6 @@ __END_NAMESPACE_STD
extern char *strptime (__const char *__restrict __s,
__const char *__restrict __fmt, struct tm *__tp)
__THROW;
-libc_hidden_proto(strptime)
# endif
#ifdef __UCLIBC_HAS_XLOCALE__
diff --git a/include/unistd.h b/include/unistd.h
index 5d3a4cb8f..c421cb308 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -51,9 +51,11 @@ __BEGIN_DECLS
Software Development Utilities Option. */
#define _POSIX2_SW_DEV 200112L
+#if 0 /* uClibc does not provide the utility */
/* If defined, the implementation supports the
creation of locales with the localedef utility. */
#define _POSIX2_LOCALEDEF 200112L
+#endif
/* X/Open version number to which the library conforms. It is selectable. */
#ifdef __USE_UNIX98
diff --git a/include/wchar-stub.h b/include/wchar-stub.h
index 0b0aa29aa..918c78dd4 100644
--- a/include/wchar-stub.h
+++ b/include/wchar-stub.h
@@ -7,7 +7,6 @@
#ifndef _WCHAR_H
#define _WCHAR_H
-#define MB_CUR_MAX 1
typedef unsigned int wint_t;
#define WEOF (0xffffffffu)
diff --git a/include/wchar.h b/include/wchar.h
index 3795998a5..3d477ba23 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -170,12 +170,10 @@ __END_NAMESPACE_C99
#ifdef __USE_GNU
/* Compare S1 and S2, ignoring case. */
extern int wcscasecmp (__const wchar_t *__s1, __const wchar_t *__s2) __THROW;
-libc_hidden_proto(wcscasecmp)
/* Compare no more than N chars of S1 and S2, ignoring case. */
extern int wcsncasecmp (__const wchar_t *__s1, __const wchar_t *__s2,
size_t __n) __THROW;
-libc_hidden_proto(wcsncasecmp)
#ifdef __UCLIBC_HAS_XLOCALE__
/* Similar to the two functions above but take the information from
@@ -202,7 +200,6 @@ libc_hidden_proto(wcscoll)
`wcscoll' to the original strings. */
extern size_t wcsxfrm (wchar_t *__restrict __s1,
__const wchar_t *__restrict __s2, size_t __n) __THROW;
-libc_hidden_proto(wcsxfrm)
__END_NAMESPACE_C99
#ifdef __USE_GNU
@@ -233,7 +230,6 @@ __BEGIN_NAMESPACE_C99
/* Find the first occurrence of WC in WCS. */
extern wchar_t *wcschr (__const wchar_t *__wcs, wchar_t __wc)
__THROW __attribute_pure__;
-libc_hidden_proto(wcschr)
/* Find the last occurrence of WC in WCS. */
extern wchar_t *wcsrchr (__const wchar_t *__wcs, wchar_t __wc)
__THROW __attribute_pure__;
@@ -244,7 +240,6 @@ __END_NAMESPACE_C99
the closing NUL wide character in case C is not found in S. */
extern wchar_t *wcschrnul (__const wchar_t *__s, wchar_t __wc)
__THROW __attribute_pure__;
-libc_hidden_proto(wcschrnul)
#endif
__BEGIN_NAMESPACE_C99
@@ -549,7 +544,6 @@ extern int fwide (__FILE *__fp, int __mode) __THROW;
extern int fwprintf (__FILE *__restrict __stream,
__const wchar_t *__restrict __format, ...)
/* __attribute__ ((__format__ (__wprintf__, 2, 3))) */;
-libc_hidden_proto(fwprintf)
/* Write formatted output to stdout.
This function is a possible cancellation point and therefore not
@@ -762,7 +756,6 @@ __BEGIN_NAMESPACE_C99
extern size_t wcsftime (wchar_t *__restrict __s, size_t __maxsize,
__const wchar_t *__restrict __format,
__const struct tm *__restrict __tp) __THROW;
-libc_hidden_proto(wcsftime)
__END_NAMESPACE_C99
# if defined __USE_GNU && defined __UCLIBC_HAS_XLOCALE__
@@ -788,6 +781,11 @@ libc_hidden_proto(wcsftime_l)
# include <wctype.h>
#endif
+#ifdef _LIBC
+extern size_t __wcslcpy(wchar_t *__restrict dst,
+ const wchar_t *__restrict src, size_t n) attribute_hidden;
+#endif
+
__END_DECLS
#endif /* _WCHAR_H defined */
diff --git a/include/wctype.h b/include/wctype.h
index 7b697d2b0..3ae682191 100644
--- a/include/wctype.h
+++ b/include/wctype.h
@@ -157,12 +157,13 @@ extern int iswpunct (wint_t __wc) __THROW;
set of wide characters for which none of `iswalnum', `iswgraph', or
`iswpunct' is true. */
extern int iswspace (wint_t __wc) __THROW;
+libc_hidden_proto(iswspace)
/* Test for any wide character that corresponds to an uppercase letter
or is one of a locale-specific set of wide character for which none
of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
extern int iswupper (wint_t __wc) __THROW;
-libc_hidden_proto(iswspace)
+libc_hidden_proto(iswupper)
/* Test for any wide character that corresponds to a hexadecimal-digit
character equivalent to that performed be the functions described
@@ -305,7 +306,6 @@ extern int iswblank_l (wint_t __wc, __locale_t __locale) __THROW;
by the string argument PROPERTY. */
extern wctype_t wctype_l (__const char *__property, __locale_t __locale)
__THROW;
-libc_hidden_proto(wctype_l)
/* Determine whether the wide-character WC has the property described by
DESC. */
diff --git a/include/xlocale.h b/include/xlocale.h
index 51a787f14..82dabdfda 100644
--- a/include/xlocale.h
+++ b/include/xlocale.h
@@ -1,5 +1,5 @@
/* Definition of locale datatype.
- Copyright (C) 1997,2000,02 Free Software Foundation, Inc.
+ Copyright (C) 1997,2000,2002,2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -21,15 +21,6 @@
#ifndef _XLOCALE_H
#define _XLOCALE_H 1
-#include <features.h>
-
-#ifndef __UCLIBC_HAS_XLOCALE__
-#error Attempted to include xlocale.h when uClibc built without extended locale support.
-#endif
-
-#include <bits/uClibc_locale.h>
-/* #include <bits/uClibc_touplow.h> */
-
#if 0
/* Structure for reentrant locale using functions. This is an
(almost) opaque type for the user level programs. The file and
@@ -37,26 +28,22 @@
go away without warning. */
typedef struct __locale_struct
{
-#if 0
/* Note: LC_ALL is not a valid index into this array. */
struct locale_data *__locales[13]; /* 13 = __LC_LAST. */
-#endif
/* To increase the speed of this solution we add some special members. */
-/* const unsigned short int *__ctype_b; */
-/* const int *__ctype_tolower; */
-/* const int *__ctype_toupper; */
- const __uint16_t *__ctype_b;
- const __ctype_touplow_t *__ctype_tolower;
- const __ctype_touplow_t *__ctype_toupper;
-
- struct __uclibc_locale_struct *__locale_ptr;
+ const unsigned short int *__ctype_b;
+ const int *__ctype_tolower;
+ const int *__ctype_toupper;
-#if 0
/* Note: LC_ALL is not a valid index into this array. */
const char *__names[13];
-#endif
} *__locale_t;
+
+/* POSIX 2008 makes locale_t official. */
+typedef __locale_t locale_t;
+#else
+# include <locale.h>
#endif
#endif /* xlocale.h */
diff --git a/ldso/include/dl-defs.h b/ldso/include/dl-defs.h
index cbbaa3cea..d387c0bb9 100644
--- a/ldso/include/dl-defs.h
+++ b/ldso/include/dl-defs.h
@@ -212,7 +212,7 @@ typedef struct {
_dl_find_hash for this reloc TYPE. TPNT is the module in which the
matching SYM was found. */
#ifndef DL_FIND_HASH_VALUE
-# define DL_FIND_HASH_VALUE(TPNT, TYPE, SYM) (DL_RELOC_ADDR ((SYM)->st_value, (TPNT)->loadaddr))
+# define DL_FIND_HASH_VALUE(TPNT, TYPE, SYM) (DL_RELOC_ADDR ((TPNT)->loadaddr, (SYM)->st_value))
#endif
/* Unmap all previously-mapped segments accumulated in LOADADDR.
diff --git a/ldso/include/dl-elf.h b/ldso/include/dl-elf.h
index 40c88b9da..908cb63ce 100644
--- a/ldso/include/dl-elf.h
+++ b/ldso/include/dl-elf.h
@@ -200,8 +200,13 @@ unsigned int __dl_parse_dynamic_info(ElfW(Dyn) *dpnt, unsigned long dynamic_info
if (dynamic_info[tag]) \
dynamic_info[tag] = (unsigned long) DL_RELOC_ADDR(load_off, dynamic_info[tag]); \
} while (0)
- /* Don't adjust .dynamic unnecessarily. */
- if (load_off != 0) {
+ /* Don't adjust .dynamic unnecessarily. For FDPIC targets,
+ we'd have to walk all the loadsegs to find out if it was
+ actually unnecessary, so skip this optimization. */
+#if !defined __FDPIC__ && !defined __DSBT__
+ if (load_off != 0)
+#endif
+ {
ADJUST_DYN_INFO(DT_HASH, load_off);
ADJUST_DYN_INFO(DT_PLTGOT, load_off);
ADJUST_DYN_INFO(DT_STRTAB, load_off);
@@ -212,6 +217,15 @@ unsigned int __dl_parse_dynamic_info(ElfW(Dyn) *dpnt, unsigned long dynamic_info
ADJUST_DYN_INFO(DT_GNU_HASH_IDX, load_off);
#endif
}
+#ifdef __DSBT__
+ /* Get the mapped address of the DSBT base. */
+ ADJUST_DYN_INFO(DT_DSBT_BASE_IDX, load_off);
+
+ /* Initialize loadmap dsbt info. */
+ load_off.map->dsbt_table = dynamic_info[DT_DSBT_BASE_IDX];
+ load_off.map->dsbt_size = dynamic_info[DT_DSBT_SIZE_IDX];
+ load_off.map->dsbt_index = dynamic_info[DT_DSBT_INDEX_IDX];
+#endif
#undef ADJUST_DYN_INFO
return rtld_flags;
}
diff --git a/ldso/include/dl-syscall.h b/ldso/include/dl-syscall.h
index 982bc9bf6..da3ac7f6f 100644
--- a/ldso/include/dl-syscall.h
+++ b/ldso/include/dl-syscall.h
@@ -95,7 +95,7 @@ static __always_inline _syscall0(gid_t, _dl_getegid)
# define __NR_getpid __NR_getxpid
#endif
#define __NR__dl_getpid __NR_getpid
-static __always_inline _syscall0(gid_t, _dl_getpid);
+static __always_inline _syscall0(gid_t, _dl_getpid)
#define __NR__dl_readlink __NR_readlink
static __always_inline _syscall3(int, _dl_readlink, const char *, path, char *, buf,
diff --git a/ldso/ldso/Makefile.in b/ldso/ldso/Makefile.in
index c9dcebd60..ad8edbb65 100644
--- a/ldso/ldso/Makefile.in
+++ b/ldso/ldso/Makefile.in
@@ -30,6 +30,7 @@ CFLAGS-ldso/ldso/$(TARGET_ARCH)/ := $(CFLAGS-ldso)
CFLAGS-ldso.c := -DLDSO_ELFINTERP=\"$(TARGET_ARCH)/elfinterp.c\" $(CFLAGS-ldso)
+LDFLAGS-$(UCLIBC_FORMAT_DSBT_ELF)-$(UCLIBC_LDSO_NAME).so := -Wl,--dsbt-index=1
ifneq ($(SUPPORT_LD_DEBUG),y)
LDFLAGS-$(UCLIBC_LDSO_NAME).so := $(LDFLAGS)
else
diff --git a/ldso/ldso/bfin/dl-syscalls.h b/ldso/ldso/bfin/dl-syscalls.h
index 916d0f84e..f74cf1ad3 100644
--- a/ldso/ldso/bfin/dl-syscalls.h
+++ b/ldso/ldso/bfin/dl-syscalls.h
@@ -31,7 +31,7 @@ extern int _dl_errno;
#if DYNAMIC_LOADER_IN_SIMULATOR
#define __NR___syscall_mmap2 __NR_mmap2
static __inline__ _syscall6(__ptr_t, __syscall_mmap2, __ptr_t, addr,
- size_t, len, int, prot, int, flags, int, fd, off_t, offset);
+ size_t, len, int, prot, int, flags, int, fd, off_t, offset)
/* Make sure we don't get another definition of _dl_mmap from the
machine-independent code. */
@@ -155,7 +155,7 @@ _dl_mmap(__ptr_t addr, size_t len, int prot, int flags, int fd, __off_t offset)
static __always_inline unsigned long _dl_read(int fd, const void *buf, unsigned long count);
static __always_inline _syscall3(__off_t, __syscall_lseek, int, fd, __off_t, offset,
- int, whence);
+ int, whence)
static __always_inline ssize_t
_dl_pread(int fd, void *buf, size_t count, off_t offset)
{
@@ -178,7 +178,7 @@ _dl_pread(int fd, void *buf, size_t count, off_t offset)
#else
#define __NR___syscall_pread __NR_pread
static __always_inline _syscall5(ssize_t, __syscall_pread, int, fd, void *, buf,
- size_t, count, off_t, offset_hi, off_t, offset_lo);
+ size_t, count, off_t, offset_hi, off_t, offset_lo)
static __always_inline ssize_t
_dl_pread(int fd, void *buf, size_t count, off_t offset)
@@ -191,18 +191,18 @@ _dl_pread(int fd, void *buf, size_t count, off_t offset)
#ifdef __NR_sram_alloc
#define __NR__dl_sram_alloc __NR_sram_alloc
static __always_inline _syscall2(__ptr_t, _dl_sram_alloc,
- size_t, len, unsigned long, flags);
+ size_t, len, unsigned long, flags)
#endif
#ifdef __NR_sram_free
#define __NR__dl_sram_free __NR_sram_free
-static __always_inline _syscall1(int, _dl_sram_free, __ptr_t, addr);
+static __always_inline _syscall1(int, _dl_sram_free, __ptr_t, addr)
#endif
#ifdef __NR_dma_memcpy
#define __NR__dl_dma_memcpy __NR_dma_memcpy
static __always_inline _syscall3(__ptr_t, _dl_dma_memcpy,
- __ptr_t, dest, __ptr_t, src, size_t, len);
+ __ptr_t, dest, __ptr_t, src, size_t, len)
#endif
#define __UCLIBC_MMAP_HAS_6_ARGS__
diff --git a/ldso/ldso/c6x/dl-debug.h b/ldso/ldso/c6x/dl-debug.h
new file mode 100644
index 000000000..9c6edab0a
--- /dev/null
+++ b/ldso/ldso/c6x/dl-debug.h
@@ -0,0 +1,49 @@
+/* C6X DSBT ELF shared library loader suppport.
+ *
+ * Copyright (C) 2010 Texas Instruments Incorporated
+ * Contributed by Mark Salter <msalter@redhat.com>
+ *
+ * All rights reserved.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+static const char *_dl_reltypes_tab[] =
+{
+ "R_C6000_NONE", /* 0 */
+ "R_C6000_ABS32",
+ "R_C6000_ABS16",
+ "R_C6000_ABS8",
+ "R_C6000_PCR_S21",
+ "R_C6000_PCR_S12", /* 5 */
+ "R_C6000_PCR_S10",
+ "R_C6000_PCR_S7",
+ "R_C6000_ABS_S16",
+ "R_C6000_ABS_L16",
+ "R_C6000_ABS_H16", /* 10 */
+ "R_C6000_SBR_U15_B",
+ "R_C6000_SBR_U15_H",
+ "R_C6000_SBR_U15_W",
+ "R_C6000_SBR_S16",
+ "R_C6000_SBR_L16_B", /* 15 */
+ "R_C6000_SBR_L16_H",
+ "R_C6000_SBR_L16_W",
+ "R_C6000_SBR_H16_B",
+ "R_C6000_SBR_H16_H",
+ "R_C6000_SBR_H16_W", /* 20 */
+ "R_C6000_SBR_GOT_U15_W",
+ "R_C6000_SBR_GOT_L16_W",
+ "R_C6000_SBR_GOT_H16_W",
+ "R_C6000_DSBT_INDEX",
+ "R_C6000_PREL31", /* 25 */
+ "R_C6000_COPY",
+ "R_C6000_JUMP_SLOT",
+ "R_C6000_SBR_GOT32",
+ "R_C6000_PCR_H16",
+ "R_C6000_PCR_L16", /* 30 */
+#if 0
+ "R_C6000_ALIGN", /* 253 */
+ "R_C6000_FPHEAD", /* 254 */
+ "R_C6000_NOCMP", /* 255 */
+#endif
+};
diff --git a/ldso/ldso/c6x/dl-inlines.h b/ldso/ldso/c6x/dl-inlines.h
new file mode 100644
index 000000000..d8fb42c55
--- /dev/null
+++ b/ldso/ldso/c6x/dl-inlines.h
@@ -0,0 +1,91 @@
+/* Copyright (C) 2010 Texas Instruments Incorporated
+ * Contributed by Mark Salter <msalter@redhat.com>
+ *
+ * Borrowed heavily from frv arch:
+ * Copyright (C) 2003, 2004 Red Hat, Inc.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+/* Figure out whether the given address is in one of the mapped
+ segments. */
+static __always_inline int
+__dl_addr_in_loadaddr (void *p, struct elf32_dsbt_loadaddr loadaddr)
+{
+ struct elf32_dsbt_loadmap *map = loadaddr.map;
+ int c;
+
+ for (c = 0; c < map->nsegs; c++)
+ if ((void*)map->segs[c].addr <= p
+ && (char*)p < (char*)map->segs[c].addr + map->segs[c].p_memsz)
+ return 1;
+
+ return 0;
+}
+
+/* Figure out how many LOAD segments there are in the given headers,
+ and allocate a block for the load map big enough for them.
+ got_value will be properly initialized later on, with INIT_GOT. */
+static __always_inline int
+__dl_init_loadaddr (struct elf32_dsbt_loadaddr *loadaddr, Elf32_Phdr *ppnt,
+ int pcnt)
+{
+ int count = 0, i;
+ size_t size;
+
+ for (i = 0; i < pcnt; i++)
+ if (ppnt[i].p_type == PT_LOAD)
+ count++;
+
+ size = sizeof (struct elf32_dsbt_loadmap)
+ + sizeof (struct elf32_dsbt_loadseg) * count;
+ loadaddr->map = _dl_malloc (size);
+ if (! loadaddr->map)
+ _dl_exit (-1);
+
+ loadaddr->map->version = 0;
+ loadaddr->map->nsegs = 0;
+
+ return count;
+}
+
+/* Incrementally initialize a load map. */
+static __always_inline void
+__dl_init_loadaddr_hdr (struct elf32_dsbt_loadaddr loadaddr, void *addr,
+ Elf32_Phdr *phdr, int maxsegs)
+{
+ struct elf32_dsbt_loadseg *segdata;
+
+ if (loadaddr.map->nsegs == maxsegs)
+ _dl_exit (-1);
+
+ segdata = &loadaddr.map->segs[loadaddr.map->nsegs++];
+ segdata->addr = (Elf32_Addr) addr;
+ segdata->p_vaddr = phdr->p_vaddr;
+ segdata->p_memsz = phdr->p_memsz;
+
+#if defined (__SUPPORT_LD_DEBUG__)
+ {
+ if (_dl_debug)
+ _dl_dprintf(_dl_debug_file, "%i: mapped %x at %x, size %x\n",
+ loadaddr.map->nsegs-1,
+ segdata->p_vaddr, segdata->addr, segdata->p_memsz);
+ }
+#endif
+}
+
+static __always_inline void
+__dl_loadaddr_unmap (struct elf32_dsbt_loadaddr loadaddr)
+{
+ int i;
+
+ for (i = 0; i < loadaddr.map->nsegs; i++)
+ _dl_munmap ((void*)loadaddr.map->segs[i].addr,
+ loadaddr.map->segs[i].p_memsz);
+
+ /* _dl_unmap is only called for dlopen()ed libraries, for which
+ calling free() is safe, or before we've completed the initial
+ relocation, in which case calling free() is probably pointless,
+ but still safe. */
+ _dl_free (loadaddr.map);
+}
diff --git a/ldso/ldso/c6x/dl-startup.h b/ldso/ldso/c6x/dl-startup.h
new file mode 100644
index 000000000..b9ea30409
--- /dev/null
+++ b/ldso/ldso/c6x/dl-startup.h
@@ -0,0 +1,122 @@
+/* Copyright (C) 2010 Texas Instruments Incorporated
+ * Contributed by Mark Salter <msalter@redhat.com>
+ *
+ * Borrowed heavily from frv arch:
+ * Copyright (C) 2003 Red Hat, Inc.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#undef DL_START
+#define DL_START(X) \
+int \
+_dl_start (unsigned placeholder, \
+ struct elf32_dsbt_loadmap *dl_boot_progmap, \
+ struct elf32_dsbt_loadmap *dl_boot_ldsomap, \
+ Elf32_Dyn *dl_boot_ldso_dyn_pointer, \
+ X)
+
+/*
+ * On entry, the kernel has set up the stack thusly:
+ *
+ * 0(sp) pad0
+ * 4(sp) pad1
+ * 8(sp) argc
+ * 12(sp) argv[0]
+ * ...
+ * (4*(argc+3))(sp) NULL
+ * (4*(argc+4))(sp) envp[0]
+ * ...
+ * NULL
+ *
+ * Register values are unspecified, except:
+ *
+ * B4 --> executable loadmap address
+ * A6 --> interpreter loadmap address
+ * B6 --> dynamic section address
+ * B14 --> our DP setup by kernel
+ *
+ * NB: DSBT index is always 0 for the executable
+ * and 1 for the interpreter
+ */
+
+__asm__(" .text\n"
+ ".globl _start\n"
+ "_start:\n"
+ " B .S2 _dl_start\n"
+ " STW .D2T2 B14, *+B14[1]\n"
+ " ADD .D1X B15,8,A8\n"
+ " ADDKPC .S2 ret_from_dl,B3,2\n"
+ "ret_from_dl:\n"
+ " B .S2X A4\n"
+ " || LDW .D2T2 *+B14[0],B14\n"
+ " ADDKPC .S2 __dl_fini,B0,0\n"
+ " MV .S1X B0,A4\n"
+ " NOP\n"
+ " NOP\n"
+ " NOP\n"
+ "__dl_fini:\n"
+ " LDW .D2T2 *+B14[1],B14\n"
+ " NOP 4\n"
+ " LDW .D2T1 *+B14($GOT(_dl_fini)), A0\n"
+ " NOP 4\n"
+ " BNOP .S2X A0, 5\n");
+
+__asm__(" .text\n"
+ "__c6x_cache_sync:\n"
+ " MVK .S2 330,B0\n"
+ " SWE\n"
+ " NOP\n"
+ " BNOP .S2 B3,5\n"
+ " NOP\n"
+ " NOP\n"
+ " NOP\n"
+ " NOP\n"
+ "\n"
+);
+
+/*
+ * Get a pointer to the argv array. On many platforms this can be just
+ * the address of the first argument, on other platforms we need to
+ * do something a little more subtle here.
+ */
+#define GET_ARGV(ARGVP, ARGS) ARGVP = (((unsigned long*) ARGS) + 1)
+
+struct elf32_dsbt_loadmap;
+
+/*
+ * Here is a macro to perform a relocation. This is only used when
+ * bootstrapping the dynamic loader. RELP is the relocation that we
+ * are performing, REL is the pointer to the address we are relocating.
+ * SYMBOL is the symbol involved in the relocation, and LOAD is the
+ * load address.
+ */
+#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB) \
+ switch(ELF32_R_TYPE((RELP)->r_info)){ \
+ case R_C6000_ABS_L16: \
+ { \
+ unsigned int opcode = *(REL); \
+ unsigned int v = (SYMBOL) + (RELP)->r_addend; \
+ opcode &= ~0x7fff80; \
+ opcode |= ((v & 0xffff) << 7); \
+ *(REL) = opcode; \
+ } \
+ break; \
+ case R_C6000_ABS_H16: \
+ { \
+ unsigned int opcode = *(REL); \
+ unsigned int v = (SYMBOL) + (RELP)->r_addend; \
+ opcode &= ~0x7fff80; \
+ opcode |= ((v >> 9) & 0x7fff80); \
+ *(REL) = opcode; \
+ } \
+ break; \
+ case R_C6000_ABS32: \
+ *(REL) = (SYMBOL) + (RELP)->r_addend; \
+ break; \
+ default: \
+ _dl_exit(1); \
+ }
+
+extern void __c6x_cache_sync(unsigned long start, unsigned long end)
+ attribute_hidden;
diff --git a/ldso/ldso/c6x/dl-syscalls.h b/ldso/ldso/c6x/dl-syscalls.h
new file mode 100644
index 000000000..9ff3358b0
--- /dev/null
+++ b/ldso/ldso/c6x/dl-syscalls.h
@@ -0,0 +1,25 @@
+/* Copyright (C) 2010 Texas Instruments Incorporated
+ * Contributed by Mark Salter <msalter@redhat.com>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+/* We can't use the real errno in ldso, since it has not yet
+ * been dynamicly linked in yet. */
+#include "sys/syscall.h"
+extern int _dl_errno;
+#undef __set_errno
+#define __set_errno(X) {(_dl_errno) = (X);}
+#include <sys/mman.h>
+
+#ifdef __NR_pread64
+#define __NR___syscall_pread __NR_pread64
+static __always_inline _syscall5(ssize_t, __syscall_pread, int, fd, void *, buf,
+ size_t, count, off_t, offset_hi, off_t, offset_lo);
+
+static __always_inline ssize_t
+_dl_pread(int fd, void *buf, size_t count, off_t offset)
+{
+ return(__syscall_pread(fd,buf,count, offset, offset >> 31));
+}
+#endif
diff --git a/ldso/ldso/c6x/dl-sysdep.h b/ldso/ldso/c6x/dl-sysdep.h
new file mode 100644
index 000000000..8f1b122d3
--- /dev/null
+++ b/ldso/ldso/c6x/dl-sysdep.h
@@ -0,0 +1,209 @@
+/* Copyright (C) 2010 Texas Instruments Incorporated
+ * Contributed by Mark Salter <msalter@redhat.com>
+ *
+ * Borrowed heavily from frv arch:
+ * Copyright (C) 2003, 2004 Red Hat, Inc.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <bits/elf-dsbt.h>
+
+/*
+ * Define this if the system uses RELOCA.
+ */
+#define ELF_USES_RELOCA 1
+
+/* JMPREL relocs are inside the DT_RELA table. */
+/* Actually looks like a linker bug sets DT_JMPREL anyway */
+#define ELF_MACHINE_PLTREL_OVERLAP 1
+
+#undef DL_NO_COPY_RELOCS
+
+#define HAVE_DL_INLINES_H
+
+
+/*
+ * Various assembly language/system dependent hacks that are required
+ * so that we can minimize the amount of platform specific code.
+ */
+
+/* Initialization sequence for the GOT. */
+#define INIT_GOT(GOT_BASE,MODULE) \
+{ \
+ GOT_BASE[0] = (unsigned long) _dl_linux_resolve; \
+ GOT_BASE[1] = (unsigned long) MODULE; \
+}
+
+/* Here we define the magic numbers that this dynamic loader should accept */
+#define MAGIC1 EM_TI_C6000
+#undef MAGIC2
+
+/* Used for error messages */
+#define ELF_TARGET "C6000"
+
+/* Need bootstrap relocations */
+#define ARCH_NEEDS_BOOTSTRAP_RELOCS
+
+struct elf_resolve;
+
+extern int _dl_linux_resolve(void) attribute_hidden;
+
+struct funcdesc_ht;
+struct elf32_dsbt_loadaddr;
+
+/* We must force strings used early in the bootstrap into the text
+ segment (const data), such that they are referenced relative to
+ the DP register rather than through the GOT which will not have
+ been relocated when these are used. */
+#undef SEND_EARLY_STDERR
+#define SEND_EARLY_STDERR(S) \
+ do { static char __s[] = (S); SEND_STDERR (__s); } while (0)
+
+#define DL_LOADADDR_TYPE struct elf32_dsbt_loadaddr
+
+#define DL_RELOC_ADDR(LOADADDR, ADDR) \
+ ((ElfW(Addr))__reloc_pointer ((void*)(ADDR), (LOADADDR).map))
+
+#define DL_INIT_LOADADDR_BOOT(LOADADDR, BASEADDR) \
+ do { \
+ struct elf32_dsbt_loadmap *map; \
+ map = dl_boot_ldsomap ?: dl_boot_progmap; \
+ if (map->version != 0) { \
+ SEND_EARLY_STDERR ("Invalid loadmap version number\n"); \
+ _dl_exit(-1); \
+ } \
+ if (map->nsegs < 2) { \
+ SEND_EARLY_STDERR ("Invalid segment count in loadmap\n"); \
+ _dl_exit(-1); \
+ } \
+ (LOADADDR).map = map; \
+ } while(0)
+
+#define DL_INIT_LOADADDR_PROG(LOADADDR, BASEADDR) \
+ do { \
+ if (dl_boot_progmap->version != 0) { \
+ SEND_EARLY_STDERR ("Invalid loadmap version number\n"); \
+ _dl_exit(-1); \
+ } \
+ if (dl_boot_progmap->nsegs < 2) { \
+ SEND_EARLY_STDERR ("Invalid segment count in loadmap\n"); \
+ _dl_exit(-1); \
+ } \
+ (LOADADDR).map = dl_boot_progmap; \
+ } while(0)
+
+#define DL_INIT_LOADADDR_EXTRA_DECLS \
+ int dl_init_loadaddr_load_count;
+
+#define DL_INIT_LOADADDR(LOADADDR, BASEADDR, PHDR, PHDRCNT) \
+ (dl_init_loadaddr_load_count = \
+ __dl_init_loadaddr (&(LOADADDR), (PHDR), (PHDRCNT)))
+
+#define DL_INIT_LOADADDR_HDR(LOADADDR, ADDR, PHDR) \
+ (__dl_init_loadaddr_hdr ((LOADADDR), (ADDR), (PHDR), \
+ dl_init_loadaddr_load_count))
+
+#define DL_LOADADDR_UNMAP(LOADADDR, LEN) \
+ (__dl_loadaddr_unmap ((LOADADDR)))
+
+#define DL_LIB_UNMAP(LIB, LEN) \
+ (__dl_loadaddr_unmap ((LIB)->loadaddr))
+
+#define DL_LOADADDR_BASE(LOADADDR) \
+ ((LOADADDR).map->dsbt_table)
+
+#define DL_ADDR_IN_LOADADDR(ADDR, TPNT, TFROM) \
+ (! (TFROM) && __dl_addr_in_loadaddr ((void*)(ADDR), (TPNT)->loadaddr))
+
+
+/* We only support loading DSBT relocatable shared libraries.
+ It probably wouldn't be too hard to support loading statically
+ linked executables that require relocation.*/
+#define DL_CHECK_LIB_TYPE(epnt, piclib, _dl_progname, libname) \
+do \
+{ \
+ (piclib) = 2; \
+} \
+while (0)
+
+/* We want want to apply all relocations in the interpreter during
+ bootstrap. Because of this, we have to skip the interpreter
+ relocations in _dl_parse_relocation_information(), see
+ elfinterp.c. */
+#define DL_SKIP_BOOTSTRAP_RELOC(SYMTAB, INDEX, STRTAB) 0
+
+#ifdef __NR_pread64
+#define _DL_PREAD(FD, BUF, SIZE, OFFSET) \
+ (_dl_pread((FD), (BUF), (SIZE), (OFFSET)))
+#endif
+
+#define DL_GET_READY_TO_RUN_EXTRA_PARMS \
+ , struct elf32_dsbt_loadmap *dl_boot_progmap \
+ , struct elf32_dsbt_loadmap *dl_boot_ldsomap
+#define DL_GET_READY_TO_RUN_EXTRA_ARGS \
+ , dl_boot_progmap \
+ , dl_boot_ldsomap
+
+
+/*
+ * Compute the GOT address.
+ * Also setup program and interpreter DSBT table entries.
+ */
+#define DL_BOOT_COMPUTE_GOT(GOT) \
+ do { \
+ unsigned long *ldso_dsbt, *prog_dsbt; \
+ ldso_dsbt = dl_boot_ldsomap->dsbt_table; \
+ prog_dsbt = dl_boot_progmap->dsbt_table; \
+ ldso_dsbt[0] = prog_dsbt[0] = (unsigned long)prog_dsbt; \
+ ldso_dsbt[1] = prog_dsbt[1] = (unsigned long)ldso_dsbt; \
+ (GOT) = ldso_dsbt + dl_boot_ldsomap->dsbt_size; \
+ } while(0)
+
+#define DL_BOOT_COMPUTE_DYN(dpnt, got, load_addr) \
+ ((dpnt) = dl_boot_ldso_dyn_pointer)
+
+
+#ifdef __USE_GNU
+# include <link.h>
+#else
+# define __USE_GNU
+# include <link.h>
+# undef __USE_GNU
+#endif
+
+static __always_inline Elf32_Addr
+elf_machine_load_address (void)
+{
+ /* this is never an issue on DSBT systems */
+ return 0;
+}
+
+static __always_inline void
+elf_machine_relative (DL_LOADADDR_TYPE load_off, const Elf32_Addr rel_addr,
+ Elf32_Word relative_count)
+{
+}
+
+/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry, so
+ PLT entries should not be allowed to define the value.
+ ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
+ of the main executable's symbols, as for a COPY reloc. */
+#define elf_machine_type_class(type) \
+ ((((type) == R_C6000_JUMP_SLOT) * ELF_RTYPE_CLASS_PLT) \
+ | (((type) == R_C6000_COPY) * ELF_RTYPE_CLASS_COPY))
+
+#define ARCH_NUM 3
+#define DT_DSBT_BASE_IDX (DT_NUM + OS_NUM)
+#define DT_DSBT_SIZE_IDX (DT_NUM + OS_NUM + 1)
+#define DT_DSBT_INDEX_IDX (DT_NUM + OS_NUM + 2)
+
+#define ARCH_DYNAMIC_INFO(dpnt, dynamic, debug_addr) \
+do { \
+if (dpnt->d_tag == DT_C6000_DSBT_BASE) \
+ dynamic[DT_DSBT_BASE_IDX] = dpnt->d_un.d_val; \
+else if (dpnt->d_tag == DT_C6000_DSBT_SIZE) \
+ dynamic[DT_DSBT_SIZE_IDX] = dpnt->d_un.d_val; \
+else if (dpnt->d_tag == DT_C6000_DSBT_INDEX) \
+ dynamic[DT_DSBT_INDEX_IDX] = dpnt->d_un.d_val; \
+} while (0)
diff --git a/ldso/ldso/c6x/elfinterp.c b/ldso/ldso/c6x/elfinterp.c
new file mode 100644
index 000000000..7c79171ce
--- /dev/null
+++ b/ldso/ldso/c6x/elfinterp.c
@@ -0,0 +1,296 @@
+/* TI C64X DSBT ELF shared library loader suppport
+ * Copyright (C) 2010 Texas Instruments Incorporated
+ * Contributed by Mark Salter <msalter@redhat.com>
+ *
+ * Borrowed heavily from frv arch:
+ * Copyright (C) 2003, 2004 Red Hat, Inc.
+ * Contributed by Alexandre Oliva <aoliva@redhat.com>
+ * Lots of code copied from ../i386/elfinterp.c, so:
+ * Copyright (c) 1994-2000 Eric Youngdale, Peter MacDonald,
+ * David Engel, Hongjiu Lu and Mitch D'Souza
+ * Copyright (C) 2001-2002, Erik Andersen
+ * All rights reserved.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <features.h>
+
+/* Program to load an ELF binary on a linux system, and run it.
+ References to symbols in sharable libraries can be resolved by either
+ an ELF sharable library or a linux style of shared library. */
+
+/* Disclaimer: I have never seen any AT&T source code for SVr4, nor have
+ I ever taken any courses on internals. This program was developed using
+ information available through the book "UNIX SYSTEM V RELEASE 4,
+ Programmers guide: Ansi C and Programming Support Tools", which did
+ a more than adequate job of explaining everything required to get this
+ working. */
+
+extern void __c6x_cache_sync(unsigned long start, unsigned long end)
+ attribute_hidden;
+
+static void
+_dl_c6x_flush_relocs(struct elf32_dsbt_loadmap *map)
+{
+ unsigned long s, e;
+ s = map->segs[0].addr;
+ e = s + map->segs[0].p_memsz;
+ __c6x_cache_sync(s, e);
+ s = map->segs[1].addr;
+ e = s + map->segs[1].p_memsz;
+ __c6x_cache_sync(s, e);
+}
+
+
+attribute_hidden
+char *
+_dl_linux_resolver (struct elf_resolve *tpnt, int reloc_entry)
+{
+ ELF_RELOC *this_reloc;
+ char *strtab;
+ ElfW(Sym) *symtab;
+ int symtab_index;
+ char *rel_addr;
+ char *new_addr;
+ char **got_addr;
+ char *symname;
+
+ rel_addr = (char *)tpnt->dynamic_info[DT_JMPREL];
+
+ this_reloc = (ELF_RELOC *)(intptr_t)(rel_addr + reloc_entry);
+ symtab_index = ELF_R_SYM(this_reloc->r_info);
+
+ symtab = (Elf32_Sym *) tpnt->dynamic_info[DT_SYMTAB];
+ strtab = (char *) tpnt->dynamic_info[DT_STRTAB];
+ symname = strtab + symtab[symtab_index].st_name;
+
+ /* Address of GOT entry fix up */
+ got_addr = (char **) DL_RELOC_ADDR(tpnt->loadaddr, this_reloc->r_offset);
+
+ /* Get the address to be used to fill in the GOT entry. */
+ new_addr = _dl_find_hash(symname, tpnt->symbol_scope, tpnt,
+ ELF_RTYPE_CLASS_PLT, NULL);
+ if (unlikely(!new_addr)) {
+ _dl_dprintf(2, "%s: can't resolve symbol '%s' in lib '%s'.\n", _dl_progname, symname, tpnt->libname);
+ _dl_exit(1);
+ }
+
+
+#if defined (__SUPPORT_LD_DEBUG__)
+ if (_dl_debug_bindings) {
+ _dl_dprintf(_dl_debug_file, "\nresolve function: %s", symname);
+ if (_dl_debug_detail)
+ _dl_dprintf(_dl_debug_file,
+ "\n\tpatched %x ==> %x @ %x\n",
+ *got_addr, new_addr, got_addr);
+ }
+ if (!_dl_debug_nofixups) {
+ *got_addr = new_addr;
+ }
+#else
+ *got_addr = new_addr;
+#endif
+
+ return new_addr;
+}
+
+static int
+_dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
+ unsigned long rel_addr, unsigned long rel_size,
+ int (*reloc_fnc) (struct elf_resolve *tpnt, struct dyn_elf *scope,
+ ELF_RELOC *rpnt, Elf32_Sym *symtab, char *strtab))
+{
+ unsigned int i;
+ char *strtab;
+ Elf32_Sym *symtab;
+ ELF_RELOC *rpnt;
+ int symtab_index;
+
+ /* Now parse the relocation information */
+ rpnt = (ELF_RELOC *)rel_addr;
+ rel_size = rel_size / sizeof(ELF_RELOC);
+
+ symtab = (Elf32_Sym *)tpnt->dynamic_info[DT_SYMTAB];
+ strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
+
+ for (i = 0; i < rel_size; i++, rpnt++) {
+ int res;
+
+ symtab_index = ELF32_R_SYM(rpnt->r_info);
+ debug_sym(symtab,strtab,symtab_index);
+ debug_reloc(symtab,strtab,rpnt);
+
+ res = reloc_fnc (tpnt, scope, rpnt, symtab, strtab);
+
+ if (res==0) continue;
+
+ _dl_dprintf(2, "\n%s: ",_dl_progname);
+
+ if (symtab_index)
+ _dl_dprintf(2, "symbol '%s': ", strtab + symtab[symtab_index].st_name);
+
+ if (res <0) {
+ int reloc_type = ELF32_R_TYPE(rpnt->r_info);
+#if defined (__SUPPORT_LD_DEBUG__)
+ _dl_dprintf(2, "can't handle reloc type %s\n ", _dl_reltypes(reloc_type));
+#else
+ _dl_dprintf(2, "can't handle reloc type %x\n", reloc_type);
+#endif
+ _dl_exit(-res);
+ } else if (res >0) {
+ _dl_dprintf(2, "can't resolve symbol\n");
+ return res;
+ }
+ }
+ _dl_c6x_flush_relocs(tpnt->loadaddr.map);
+ return 0;
+}
+
+static int
+_dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
+ ELF_RELOC *rpnt, Elf32_Sym *symtab, char *strtab)
+{
+ int reloc_type;
+ int symtab_index;
+ char *symname;
+ unsigned long *reloc_addr;
+ unsigned long symbol_addr, sym_val;
+ long reloc_addend;
+ unsigned long old_val, new_val;
+
+ reloc_addr = (unsigned long *)(intptr_t)
+ DL_RELOC_ADDR (tpnt->loadaddr, rpnt->r_offset);
+
+ reloc_type = ELF32_R_TYPE(rpnt->r_info);
+ reloc_addend = rpnt->r_addend;
+ symtab_index = ELF32_R_SYM(rpnt->r_info);
+ symbol_addr = 0;
+ symname = strtab + symtab[symtab_index].st_name;
+
+ if (ELF32_ST_BIND (symtab[symtab_index].st_info) == STB_LOCAL) {
+ symbol_addr = (unsigned long)
+ DL_RELOC_ADDR (tpnt->loadaddr, symtab[symtab_index].st_value);
+ } else {
+ symbol_addr = (unsigned long) _dl_find_hash(strtab + symtab[symtab_index].st_name,
+ scope, tpnt, elf_machine_type_class(reloc_type),
+ NULL);
+ /*
+ * We want to allow undefined references to weak symbols - this might
+ * have been intentional. We should not be linking local symbols
+ * here, so all bases should be covered.
+ */
+
+ if (!symbol_addr && ELF32_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK) {
+ _dl_dprintf (2, "%s: can't resolve symbol '%s'\n",
+ _dl_progname, strtab + symtab[symtab_index].st_name);
+ _dl_exit (1);
+ }
+ }
+ old_val = *reloc_addr;
+ sym_val = symbol_addr + reloc_addend;
+
+ switch (reloc_type) {
+ case R_C6000_NONE:
+ break;
+ case R_C6000_ABS32:
+ case R_C6000_JUMP_SLOT:
+ new_val = sym_val;
+ *reloc_addr = sym_val;
+ break;
+ case R_C6000_ABS_L16:
+ new_val = (old_val & ~0x007fff80) | ((sym_val & 0xffff) << 7);
+ *reloc_addr = new_val;
+ break;
+ case R_C6000_ABS_H16:
+ new_val = (old_val & ~0x007fff80) | ((sym_val >> 9) & 0x007fff80);
+ *reloc_addr = new_val;
+ break;
+ case R_C6000_PCR_S21:
+ new_val = sym_val - (((unsigned long)reloc_addr) & ~31);
+ *reloc_addr = (old_val & ~0x0fffff80) | (((new_val >> 2) & 0x1fffff) << 7);
+ break;
+ case R_C6000_COPY:
+ if (symbol_addr) {
+#if defined (__SUPPORT_LD_DEBUG__)
+ if (_dl_debug_move)
+ _dl_dprintf(_dl_debug_file,
+ "\n%s move %d bytes from %x to %x",
+ symname, symtab[symtab_index].st_size,
+ symbol_addr, reloc_addr);
+#endif
+
+ _dl_memcpy((char *)reloc_addr,
+ (char *)symbol_addr,
+ symtab[symtab_index].st_size);
+ }
+ break;
+ default:
+ return -1; /*call _dl_exit(1) */
+ }
+#if defined (__SUPPORT_LD_DEBUG__)
+ if (_dl_debug_reloc && _dl_debug_detail && reloc_type != R_C6000_NONE) {
+ _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x\n", old_val, new_val, reloc_addr);
+ }
+#endif
+ return 0;
+}
+
+static int
+_dl_do_lazy_reloc (struct elf_resolve *tpnt,
+ struct dyn_elf *scope attribute_unused,
+ ELF_RELOC *rpnt, ElfW(Sym) *symtab attribute_unused,
+ char *strtab attribute_unused)
+{
+ int reloc_type;
+ unsigned long *reloc_addr;
+ unsigned long old_val;
+
+ reloc_addr = (unsigned long *) DL_RELOC_ADDR(tpnt->loadaddr, rpnt->r_offset);
+ reloc_type = ELF_R_TYPE(rpnt->r_info);
+
+ old_val = *reloc_addr;
+
+ switch (reloc_type) {
+ case R_C6000_NONE:
+ break;
+ case R_C6000_JUMP_SLOT:
+ *reloc_addr = DL_RELOC_ADDR(tpnt->loadaddr, old_val);
+ break;
+ default:
+ return -1;
+ }
+
+#if defined (__SUPPORT_LD_DEBUG__)
+ if (_dl_debug_reloc && _dl_debug_detail)
+ _dl_dprintf(_dl_debug_file, "\n\tpatched: %x ==> %x @ %x\n",
+ old_val, *reloc_addr, reloc_addr);
+#endif
+
+ return 0;
+}
+
+void
+_dl_parse_lazy_relocation_information
+(struct dyn_elf *rpnt, unsigned long rel_addr, unsigned long rel_size)
+{
+ _dl_parse(rpnt->dyn, NULL, rel_addr, rel_size, _dl_do_lazy_reloc);
+}
+
+int
+_dl_parse_relocation_information
+(struct dyn_elf *rpnt, unsigned long rel_addr, unsigned long rel_size)
+{
+ return _dl_parse(rpnt->dyn, rpnt->dyn->symbol_scope, rel_addr, rel_size, _dl_do_reloc);
+}
+
+/* We don't have copy relocs. */
+int
+_dl_parse_copy_information
+(struct dyn_elf *rpnt,
+ unsigned long rel_addr,
+ unsigned long rel_size)
+{
+ return 0;
+}
+
diff --git a/ldso/ldso/c6x/resolve.S b/ldso/ldso/c6x/resolve.S
new file mode 100644
index 000000000..ce3cbe793
--- /dev/null
+++ b/ldso/ldso/c6x/resolve.S
@@ -0,0 +1,68 @@
+;;
+;; Copyright (C) 2010 Texas Instruments Incorporated
+;; Mark Salter <msalter@redhat.com>
+;;
+;; Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+;;
+
+;; The function below is tail-called by resolver stubs when a
+;; lazily-bound function is called. It must preserve all
+;; registers that could be used to pass arguments to the actual
+;; function.
+
+;; _dl_linux_resolver() figures out where the jump symbol is
+;; _really_ supposed to have jumped to and returns that to us.
+;; Once we have that, we prepare to tail-call the actual
+;; function, clean up after ourselves, restoring the original
+;; arguments, then jump to the fixed up address. */
+
+; resolver stub - called from PLT to resolve target address and update GOT
+;
+; B0 : reloc offset (bytes from DT_RELPLT)
+; B1 : module pointer, loaded from GOT[1]
+; DP : caller's DP
+; A4,B4, etc: callee's arguments
+; B3 : return address
+
+ .text
+ .align 5
+ .global _dl_linux_resolve
+_dl_linux_resolve:
+ stw .d2t2 B14, *B15--[2]
+ stdw .d2t1 A15:A14, *B15--
+ stdw .d2t2 B13:B12, *B15--
+ stdw .d2t1 A13:A12, *B15--
+ stdw .d2t2 B11:B10, *B15--
+ stdw .d2t1 A11:A10, *B15--
+ stdw .d2t2 B9:B8, *B15--
+ stdw .d2t1 A9:A8, *B15--
+ stdw .d2t2 B7:B6, *B15--
+ stdw .d2t1 A7:A6, *B15--
+ stdw .d2t2 B5:B4, *B15--
+ stdw .d2t1 A5:A4, *B15--
+ stdw .d2t2 B3:B2, *B15--
+ stdw .d2t1 A3:A2, *B15--
+
+ ; call lookup routine
+ MV .S1X B1, A4 ; arg 1: module id
+|| MV .S2 B0,B4 ; arg 2: reloc offset
+ CALLP .S2 _dl_linux_resolver, B3 ; returns &f in A4
+ MV .S2X A4,B0 ; &f
+
+ lddw .d2t1 *++B15, A3:A2
+ lddw .d2t2 *++B15, B3:B2
+ lddw .d2t1 *++B15, A5:A4
+ lddw .d2t2 *++B15, B5:B4
+ lddw .d2t1 *++B15, A7:A6
+ lddw .d2t2 *++B15, B7:B6
+ lddw .d2t1 *++B15, A9:A8
+ lddw .d2t2 *++B15, B9:B8
+ lddw .d2t1 *++B15, A11:A10
+ lddw .d2t2 *++B15, B11:B10
+ lddw .d2t1 *++B15, A13:A12
+ lddw .d2t2 *++B15, B13:B12
+ lddw .d2t1 *++B15, A15:A14
+ ldw .d2t2 *++B15[2], B14
+
+ B .S2 B0 ; tail-call f
+ NOP 5
diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c
index 5d49e073b..a881b7df7 100644
--- a/ldso/ldso/dl-elf.c
+++ b/ldso/ldso/dl-elf.c
@@ -188,7 +188,7 @@ unsigned long _dl_error_number;
unsigned long _dl_internal_error_number;
struct elf_resolve *_dl_load_shared_library(int secure, struct dyn_elf **rpnt,
- struct elf_resolve *tpnt, char *full_libname, int __attribute__((unused)) trace_loaded_objects)
+ struct elf_resolve *tpnt, char *full_libname, int attribute_unused trace_loaded_objects)
{
char *pnt;
struct elf_resolve *tpnt1;
@@ -826,6 +826,54 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
INIT_GOT(lpnt, tpnt);
}
+#ifdef __DSBT__
+ /* Handle DSBT initialization */
+ {
+ struct elf_resolve *t, *ref = NULL;
+ int idx = tpnt->loadaddr.map->dsbt_index;
+ unsigned *dsbt = tpnt->loadaddr.map->dsbt_table;
+
+ if (idx == 0) {
+ /* This DSO has not been assigned an index */
+ _dl_dprintf(2, "%s: '%s' is missing a dsbt index assignment!\n",
+ _dl_progname, libname);
+ _dl_exit(1);
+ }
+
+ /*
+ * Setup dsbt slot for this module in dsbt of all modules.
+ */
+ for (t = _dl_loaded_modules; t; t = t->next) {
+ /* find a dsbt table from another module */
+ if (ref == NULL && t != tpnt) {
+ ref = t;
+
+ /* make sure index is not already used */
+ if (t->loadaddr.map->dsbt_table[idx]) {
+ struct elf_resolve *dup;
+ char *dup_name;
+
+ for (dup = _dl_loaded_modules; dup; dup = dup->next)
+ if (dup != tpnt && dup->loadaddr.map->dsbt_index == idx)
+ break;
+ if (dup)
+ dup_name = dup->libname;
+ else if (idx == 1)
+ dup_name = "runtime linker";
+ else
+ dup_name = "unknown library";
+ _dl_dprintf(2, "%s: '%s' dsbt index %d already used by %s!\n",
+ _dl_progname, libname, idx, dup_name);
+ _dl_exit(1);
+ }
+ }
+ t->loadaddr.map->dsbt_table[idx] = (unsigned)dsbt;
+ }
+ if (ref)
+ _dl_memcpy(dsbt, ref->loadaddr.map->dsbt_table,
+ tpnt->loadaddr.map->dsbt_size * sizeof(unsigned *));
+ }
+#endif
_dl_if_debug_dprint("\n\tfile='%s'; generating link map\n", libname);
_dl_if_debug_dprint("\t\tdynamic: %x base: %x\n", dynamic_addr, DL_LOADADDR_BASE(lib_loadaddr));
_dl_if_debug_dprint("\t\t entry: %x phdr: %x phnum: %x\n\n",
diff --git a/ldso/ldso/i386/elfinterp.c b/ldso/ldso/i386/elfinterp.c
index 33c14402a..39c4e1d06 100644
--- a/ldso/ldso/i386/elfinterp.c
+++ b/ldso/ldso/i386/elfinterp.c
@@ -162,7 +162,7 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
int reloc_type;
int symtab_index;
char *symname;
- struct elf_resolve *tls_tpnt = 0;
+ struct elf_resolve *tls_tpnt = NULL;
unsigned long *reloc_addr;
unsigned long symbol_addr;
#if defined (__SUPPORT_LD_DEBUG__)
diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c
index 2ff441194..775acdd15 100644
--- a/ldso/ldso/ldso.c
+++ b/ldso/ldso/ldso.c
@@ -119,15 +119,13 @@ extern void _start(void);
#ifdef __UCLIBC_HAS_SSP__
# include <dl-osinfo.h>
-uintptr_t stack_chk_guard;
+static uintptr_t stack_chk_guard;
# ifndef THREAD_SET_STACK_GUARD
/* Only exported for architectures that don't store the stack guard canary
* in local thread area. */
uintptr_t __stack_chk_guard attribute_relro;
-# ifdef __UCLIBC_HAS_SSP_COMPAT__
-strong_alias(__stack_chk_guard,__guard)
-# endif
-# elif __UCLIBC_HAS_SSP_COMPAT__
+# endif
+# ifdef __UCLIBC_HAS_SSP_COMPAT__
uintptr_t __guard attribute_relro;
# endif
#endif
@@ -1165,12 +1163,12 @@ of this helper program; chances are you did not intend to run this program.\n\
stack_chk_guard = _dl_setup_stack_chk_guard ();
# ifdef THREAD_SET_STACK_GUARD
THREAD_SET_STACK_GUARD (stack_chk_guard);
-# ifdef __UCLIBC_HAS_SSP_COMPAT__
- __guard = stack_chk_guard;
-# endif
# else
__stack_chk_guard = stack_chk_guard;
# endif
+# ifdef __UCLIBC_HAS_SSP_COMPAT__
+ __guard = stack_chk_guard;
+# endif
#endif
#ifdef __LDSO_PRELINK_SUPPORT__
diff --git a/ldso/ldso/sparc/elfinterp.c b/ldso/ldso/sparc/elfinterp.c
index 3c928073b..60a0161be 100644
--- a/ldso/ldso/sparc/elfinterp.c
+++ b/ldso/ldso/sparc/elfinterp.c
@@ -170,7 +170,7 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
int reloc_type;
int symtab_index;
char *symname;
- struct elf_resolve *tls_tpnt = 0;
+ struct elf_resolve *tls_tpnt = NULL;
struct symbol_ref sym_ref;
ElfW(Addr) *reloc_addr;
ElfW(Addr) symbol_addr;
diff --git a/ldso/ldso/x86_64/elfinterp.c b/ldso/ldso/x86_64/elfinterp.c
index a36b1154c..44e2c66d8 100644
--- a/ldso/ldso/x86_64/elfinterp.c
+++ b/ldso/ldso/x86_64/elfinterp.c
@@ -157,7 +157,7 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
int reloc_type;
int symtab_index;
char *symname;
- struct elf_resolve *tls_tpnt = 0;
+ struct elf_resolve *tls_tpnt = NULL;
struct symbol_ref sym_ref;
ElfW(Addr) *reloc_addr;
ElfW(Addr) symbol_addr;
diff --git a/ldso/libdl/Makefile.in b/ldso/libdl/Makefile.in
index 39db7a876..152185e37 100644
--- a/ldso/libdl/Makefile.in
+++ b/ldso/libdl/Makefile.in
@@ -19,6 +19,7 @@ endif
CFLAGS-libdl.c := -DLDSO_ELFINTERP=\"$(TARGET_ARCH)/elfinterp.c\"
+LDFLAGS-$(UCLIBC_FORMAT_DSBT_ELF)-libdl.so := -Wl,--dsbt-index=3
LDFLAGS-libdl.so := $(LDFLAGS) -Wl,-fini,dl_cleanup
LIBS-libdl.so := $(LIBS) $(ldso)
diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c
index 5007a7e65..83dfd0898 100644
--- a/ldso/libdl/libdl.c
+++ b/ldso/libdl/libdl.c
@@ -651,7 +651,6 @@ void *dlsym(void *vhandle, const char *name)
ElfW(Addr) from;
struct dyn_elf *rpnt;
void *ret;
- struct elf_resolve *tls_tpnt = NULL;
struct symbol_ref sym_ref = { NULL, NULL };
/* Nastiness to support underscore prefixes. */
#ifdef __UCLIBC_UNDERSCORES__
@@ -973,6 +972,10 @@ static int do_dlclose(void *vhandle, int need_fini)
free(tpnt);
}
}
+ for (rpnt1 = handle->next; rpnt1; rpnt1 = rpnt1_tmp) {
+ rpnt1_tmp = rpnt1->next;
+ free(rpnt1);
+ }
free(handle->init_fini.init_fini);
free(handle);
diff --git a/libc/Makefile.in b/libc/Makefile.in
index dd666ac7c..3b6a17b32 100644
--- a/libc/Makefile.in
+++ b/libc/Makefile.in
@@ -15,6 +15,7 @@ ifneq ($(VERSION_SCRIPT),)
VERSION_SCRIPT := -Wl,--version-script,$(VERSION_SCRIPT)
endif
+LDFLAGS-$(UCLIBC_FORMAT_DSBT_ELF)-libc.so := -Wl,--dsbt-index=2
LDFLAGS-libc.so := $(LDFLAGS) $(VERSION_SCRIPT) -Wl,-init,$(SYMBOL_PREFIX)__uClibc_init
ifeq ($(UCLIBC_HAS_STDIO_FUTEXES),y)
CFLAGS += -D__USE_STDIO_FUTEXES__
diff --git a/libc/inet/getaddrinfo.c b/libc/inet/getaddrinfo.c
index cdfdb72cf..b3435a8b2 100644
--- a/libc/inet/getaddrinfo.c
+++ b/libc/inet/getaddrinfo.c
@@ -639,9 +639,13 @@ gaih_inet(const char *name, const struct gaih_service *service,
tmpbuflen *= 2;
tmpbuf = alloca(tmpbuflen);
rc = gethostbyaddr_r(at2->addr,
+#ifdef __UCLIBC_HAS_IPV6__
((at2->family == AF_INET6)
? sizeof(struct in6_addr)
: sizeof(struct in_addr)),
+#else
+ sizeof(struct in_addr),
+#endif
at2->family,
&th, tmpbuf, tmpbuflen,
&h, &herrno);
diff --git a/libc/inet/ifaddrs.c b/libc/inet/ifaddrs.c
index 3b8b674c2..39729ef47 100644
--- a/libc/inet/ifaddrs.c
+++ b/libc/inet/ifaddrs.c
@@ -59,7 +59,9 @@ struct ifaddrs_storage
struct sockaddr sa;
struct sockaddr_ll sl;
struct sockaddr_in s4;
+#ifdef __UCLIBC_HAS_IPV6__
struct sockaddr_in6 s6;
+#endif
} addr, netmask, broadaddr;
char name[IF_NAMESIZE + 1];
};
@@ -621,6 +623,7 @@ getifaddrs (struct ifaddrs **ifap)
rta_data, rta_payload);
break;
+#ifdef __UCLIBC_HAS_IPV6__
case AF_INET6:
/* Size must match that of an address for IPv6. */
if (rta_payload == 16)
@@ -633,6 +636,7 @@ getifaddrs (struct ifaddrs **ifap)
= ifam->ifa_index;
}
break;
+#endif
default:
if (rta_payload <= sizeof (ifas[ifa_index].addr))
@@ -668,6 +672,7 @@ getifaddrs (struct ifaddrs **ifap)
rta_data, rta_payload);
break;
+#ifdef __UCLIBC_HAS_IPV6__
case AF_INET6:
/* Size must match that of an address for IPv6. */
if (rta_payload == 16)
@@ -680,6 +685,7 @@ getifaddrs (struct ifaddrs **ifap)
ifam->ifa_index;
}
break;
+#endif
default:
if (rta_payload <= sizeof (ifas[ifa_index].addr))
@@ -709,6 +715,7 @@ getifaddrs (struct ifaddrs **ifap)
rta_data, rta_payload);
break;
+#ifdef __UCLIBC_HAS_IPV6__
case AF_INET6:
/* Size must match that of an address for IPv6. */
if (rta_payload == 16)
@@ -721,6 +728,7 @@ getifaddrs (struct ifaddrs **ifap)
= ifam->ifa_index;
}
break;
+#endif
default:
if (rta_payload <= sizeof (ifas[ifa_index].addr))
@@ -777,10 +785,12 @@ getifaddrs (struct ifaddrs **ifap)
max_prefixlen = 32;
break;
+#ifdef __UCLIBC_HAS_IPV6__
case AF_INET6:
cp = (char *) &ifas[ifa_index].netmask.s6.sin6_addr;
max_prefixlen = 128;
break;
+#endif
}
ifas[ifa_index].ifa.ifa_netmask->sa_family
diff --git a/libc/inet/rpc/clnt_tcp.c b/libc/inet/rpc/clnt_tcp.c
index d01fc80d5..d8d7bb359 100644
--- a/libc/inet/rpc/clnt_tcp.c
+++ b/libc/inet/rpc/clnt_tcp.c
@@ -402,6 +402,7 @@ clnttcp_control (CLIENT *cl, int request, char *info)
/* This will set the xid of the NEXT call */
*(u_long *)ct->ct_mcall = htonl (*(u_long *)info - 1);
/* decrement by 1 as clnttcp_call() increments once */
+ break;
case CLGET_VERS:
/*
* This RELIES on the information that, in the call body,
diff --git a/libc/inet/rpc/clnt_udp.c b/libc/inet/rpc/clnt_udp.c
index fe8b7f8e6..aca3e337b 100644
--- a/libc/inet/rpc/clnt_udp.c
+++ b/libc/inet/rpc/clnt_udp.c
@@ -554,6 +554,7 @@ clntudp_control (CLIENT *cl, int request, char *info)
/* This will set the xid of the NEXT call */
*(u_long *)cu->cu_outbuf = htonl(*(u_long *)info - 1);
/* decrement by 1 as clntudp_call() increments once */
+ break;
case CLGET_VERS:
/*
* This RELIES on the information that, in the call body,
diff --git a/libc/inet/rpc/clnt_unix.c b/libc/inet/rpc/clnt_unix.c
index c7756f700..9870149e9 100644
--- a/libc/inet/rpc/clnt_unix.c
+++ b/libc/inet/rpc/clnt_unix.c
@@ -377,6 +377,7 @@ clntunix_control (CLIENT *cl, int request, char *info)
/* This will set the xid of the NEXT call */
*(u_long *) ct->ct_mcall = htonl (*(u_long *)info - 1);
/* decrement by 1 as clntunix_call() increments once */
+ break;
case CLGET_VERS:
/*
* This RELIES on the information that, in the call body,
diff --git a/libc/inet/rpc/sa_len.c b/libc/inet/rpc/sa_len.c
index 3b37eba44..5f258db1f 100644
--- a/libc/inet/rpc/sa_len.c
+++ b/libc/inet/rpc/sa_len.c
@@ -52,10 +52,14 @@ int __libc_sa_len (sa_family_t af)
#endif
case AF_INET:
return sizeof (struct sockaddr_in);
+#ifdef __UCLIBC_HAS_IPV6__
case AF_INET6:
return sizeof (struct sockaddr_in6);
+#endif
+#if 0
case AF_IPX:
return sizeof (struct sockaddr_ipx);
+#endif
case AF_LOCAL:
return sizeof (struct sockaddr_un);
}
diff --git a/libc/inet/rpc/svc.c b/libc/inet/rpc/svc.c
index 0f5300c8b..b28485de3 100644
--- a/libc/inet/rpc/svc.c
+++ b/libc/inet/rpc/svc.c
@@ -41,6 +41,7 @@
#include <errno.h>
#include <unistd.h>
+#include <string.h>
#include "rpc_private.h"
#include <rpc/svc.h>
#include <rpc/pmap_clnt.h>
diff --git a/libc/misc/ctype/ctype.c b/libc/misc/ctype/ctype.c
index e46f66b58..1c40b244a 100644
--- a/libc/misc/ctype/ctype.c
+++ b/libc/misc/ctype/ctype.c
@@ -306,8 +306,6 @@ int tolower_l(int c, __locale_t l)
return __UCLIBC_CTYPE_IN_TO_DOMAIN(c) ? l->__ctype_tolower[c] : c;
}
libc_hidden_def(tolower_l)
-/*remove after 0.9.31. See ctype.h for why.
- *weak_alias (tolower_l, __tolower_l) */
#endif
/**********************************************************************/
@@ -346,9 +344,6 @@ int toupper_l(int c, __locale_t l)
#endif
return __UCLIBC_CTYPE_IN_TO_DOMAIN(c) ? l->__ctype_toupper[c] : c;
}
-libc_hidden_def(toupper_l)
-/*remove after 0.9.31. See ctype.h for why.
- *weak_alias (toupper_l, __toupper_l) */
#endif
/**********************************************************************/
diff --git a/libc/misc/elf/dl-iterate-phdr.c b/libc/misc/elf/dl-iterate-phdr.c
index a7677f11f..f0233ca37 100644
--- a/libc/misc/elf/dl-iterate-phdr.c
+++ b/libc/misc/elf/dl-iterate-phdr.c
@@ -62,9 +62,11 @@ dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info,
/* This entry describes this statically-linked program itself. */
struct dl_phdr_info info;
int ret;
-#ifdef __FDPIC__
+#if defined(__FDPIC__)
info.dlpi_addr.map = NULL;
info.dlpi_addr.got_value = NULL;
+#elif defined(__DSBT__)
+ info.dlpi_addr.map = NULL;
#else
info.dlpi_addr = 0;
#endif
diff --git a/libc/misc/fnmatch/fnmatch.c b/libc/misc/fnmatch/fnmatch.c
index 0fa043bad..2874413ec 100644
--- a/libc/misc/fnmatch/fnmatch.c
+++ b/libc/misc/fnmatch/fnmatch.c
@@ -334,11 +334,6 @@ is_char_class (const wchar_t *wcs)
# include "fnmatch_loop.c"
# endif
-#ifndef __UCLIBC_HAS_WCHAR__
-# undef MB_CUR_MAX
-# define MB_CUR_MAX 1
-#endif
-
int
fnmatch (const char *pattern, const char *string, int flags)
{
diff --git a/libc/misc/ftw/ftw.c b/libc/misc/ftw/ftw.c
index 4a62e388a..9031e3589 100644
--- a/libc/misc/ftw/ftw.c
+++ b/libc/misc/ftw/ftw.c
@@ -752,7 +752,7 @@ ftw_startup (const char *dir, int is_nftw, void *func, int descriptors,
/* Entry points. */
-#if __UCLIBC_HAS_FTW__
+#ifdef __UCLIBC_HAS_FTW__
int
FTW_NAME (const char *path, FTW_FUNC_T func, int descriptors)
{
@@ -760,7 +760,7 @@ FTW_NAME (const char *path, FTW_FUNC_T func, int descriptors)
}
#endif
-#if __UCLIBC_HAS_NFTW__
+#ifdef __UCLIBC_HAS_NFTW__
#ifndef _LIBC
int
NFTW_NAME (const char *path, NFTW_FUNC_T func, int descriptors, int flags)
diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c
index 36c0c6c63..71fdbd8a7 100644
--- a/libc/misc/internals/__uClibc_main.c
+++ b/libc/misc/internals/__uClibc_main.c
@@ -45,22 +45,15 @@ void *__libc_stack_end = NULL;
# ifdef __UCLIBC_HAS_SSP__
# include <dl-osinfo.h>
+static uintptr_t stack_chk_guard;
# ifndef THREAD_SET_STACK_GUARD
/* Only exported for architectures that don't store the stack guard canary
* in thread local area. */
-# include <stdint.h>
-uintptr_t stack_chk_guard;
/* for gcc-4.1 non-TLS */
uintptr_t __stack_chk_guard attribute_relro;
+# endif
/* for gcc-3.x + Etoh ssp */
-# ifdef __UCLIBC_HAS_SSP_COMPAT__
-# ifdef __HAVE_SHARED__
-strong_alias(__stack_chk_guard,__guard)
-# else
-uintptr_t __guard attribute_relro;
-# endif
-# endif
-# elif defined __UCLIBC_HAS_SSP_COMPAT__
+# ifdef __UCLIBC_HAS_SSP_COMPAT__
uintptr_t __guard attribute_relro;
# endif
# endif
@@ -255,18 +248,14 @@ void __uClibc_init(void)
#ifndef SHARED
# ifdef __UCLIBC_HAS_SSP__
/* Set up the stack checker's canary. */
+ stack_chk_guard = _dl_setup_stack_chk_guard();
# ifdef THREAD_SET_STACK_GUARD
- uintptr_t stack_chk_guard = _dl_setup_stack_chk_guard();
THREAD_SET_STACK_GUARD (stack_chk_guard);
-# ifdef __UCLIBC_HAS_SSP_COMPAT__
- stack_chk_guard = _dl_setup_stack_chk_guard();
- __guard = stack_chk_guard;
-# endif
# else
__stack_chk_guard = stack_chk_guard;
-# if !defined __HAVE_SHARED__ && defined __UCLIBC_HAS_SSP_COMPAT__
- __guard = stack_chk_guard;
-# endif
+# endif
+# ifdef __UCLIBC_HAS_SSP_COMPAT__
+ __guard = stack_chk_guard;
# endif
# endif
#endif
@@ -317,6 +306,11 @@ void __uClibc_fini(void)
}
libc_hidden_def(__uClibc_fini)
+#ifndef SHARED
+extern void __nptl_deallocate_tsd (void) __attribute ((weak));
+extern unsigned int __nptl_nthreads __attribute ((weak));
+#endif
+
/* __uClibc_main is the new main stub for uClibc. This function is
* called from crt1 (version 0.9.28 or newer), after ALL shared libraries
* are initialized, just before we call the application's main function.
@@ -497,7 +491,6 @@ void __uClibc_main(int (*main)(int, char **, char **), int argc,
# ifdef SHARED
__libc_pthread_functions.ptr__nptl_deallocate_tsd ();
# else
- extern void __nptl_deallocate_tsd (void) __attribute ((weak));
__nptl_deallocate_tsd ();
# endif
@@ -507,7 +500,6 @@ void __uClibc_main(int (*main)(int, char **, char **), int argc,
# ifdef SHARED
unsigned int *const ptr = __libc_pthread_functions.ptr_nthreads;
# else
- extern unsigned int __nptl_nthreads __attribute ((weak));
unsigned int *const ptr = &__nptl_nthreads;
# endif
diff --git a/libc/misc/internals/tempname.c b/libc/misc/internals/tempname.c
index 4145c9478..0db28455b 100644
--- a/libc/misc/internals/tempname.c
+++ b/libc/misc/internals/tempname.c
@@ -62,7 +62,10 @@ int attribute_hidden ___path_search (char *tmpl, size_t tmpl_len, const char *di
const char *pfx /*, int try_tmpdir*/)
{
/*const char *d; */
- size_t dlen, plen;
+ /* dir and pfx lengths should always fit into an int,
+ so don't bother using size_t here. Especially since
+ the printf func requires an int for precision (%*s). */
+ int dlen, plen;
if (!pfx || !pfx[0])
{
diff --git a/libc/misc/locale/locale.c b/libc/misc/locale/locale.c
index 52055a2d2..40303ab14 100644
--- a/libc/misc/locale/locale.c
+++ b/libc/misc/locale/locale.c
@@ -1057,6 +1057,7 @@ libc_hidden_def(__XL_NPP(nl_langinfo))
/**********************************************************************/
#ifdef L_newlocale
+#warning mask defines for extra locale categories
#ifdef __UCLIBC_MJN3_ONLY__
#warning TODO: Move posix and utf8 strings.
@@ -1302,7 +1303,9 @@ __locale_t newlocale(int category_mask, const char *locale, __locale_t base)
return base;
}
+#ifdef __UCLIBC_HAS_XLOCALE__
libc_hidden_def(newlocale)
+#endif
#endif
/**********************************************************************/
@@ -1336,7 +1339,6 @@ __locale_t duplocale(__locale_t dataset)
}
return r;
}
-libc_hidden_def(duplocale)
#endif
/**********************************************************************/
diff --git a/libc/misc/pthread/tsd.c b/libc/misc/pthread/tsd.c
index 835ee22ce..0c222e8e9 100644
--- a/libc/misc/pthread/tsd.c
+++ b/libc/misc/pthread/tsd.c
@@ -2,6 +2,7 @@
We define it here instead of in libpthread so t here instead of in libpthread so that it doesn't
need to have a TLS segment of its own just for this one pointer. */
+void **__libc_dl_error_tsd(void) __attribute__ ((const));
void ** __attribute__ ((const))
__libc_dl_error_tsd (void)
{
diff --git a/libc/misc/regex/regcomp.c b/libc/misc/regex/regcomp.c
index 8f2e18ce4..b25850ccd 100644
--- a/libc/misc/regex/regcomp.c
+++ b/libc/misc/regex/regcomp.c
@@ -819,11 +819,7 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
dfa->state_table = calloc (sizeof (struct re_state_table_entry), table_size);
dfa->state_hash_mask = table_size - 1;
-#ifdef __UCLIBC_HAS_WCHAR__
dfa->mb_cur_max = MB_CUR_MAX;
-#else
- dfa->mb_cur_max = 1;
-#endif
#if 0
if (dfa->mb_cur_max == 6
&& strcmp (_NL_CURRENT (LC_CTYPE, _NL_CTYPE_CODESET_NAME), "UTF-8") == 0)
diff --git a/libc/misc/regex/regex_internal.c b/libc/misc/regex/regex_internal.c
index de640e08d..c6ac8dda1 100644
--- a/libc/misc/regex/regex_internal.c
+++ b/libc/misc/regex/regex_internal.c
@@ -627,7 +627,7 @@ re_string_reconstruct (re_string_t *pstr, int idx, int eflags)
if (pstr->is_utf8)
{
- const unsigned char *raw, *p, *q, *end;
+ const unsigned char *raw, *p, *end;
/* Special case UTF-8. Multi-byte chars start with any
byte other than 0x80 - 0xbf. */
@@ -654,13 +654,11 @@ re_string_reconstruct (re_string_t *pstr, int idx, int eflags)
unsigned char buf[6];
size_t mbclen;
- q = p;
if (BE (pstr->trans != NULL, 0))
{
int i = mlen < 6 ? mlen : 6;
while (--i >= 0)
buf[i] = pstr->trans[p[i]];
- q = buf;
}
/* XXX Don't use mbrtowc, we know which conversion
to use (UTF-8 -> UCS4). */
diff --git a/libc/misc/sysvipc/msgq.c b/libc/misc/sysvipc/msgq.c
index 27eb1ff92..185cd268b 100644
--- a/libc/misc/sysvipc/msgq.c
+++ b/libc/misc/sysvipc/msgq.c
@@ -12,7 +12,7 @@
#ifdef __NR_msgctl
#define __NR___libc_msgctl __NR_msgctl
-static __inline__ _syscall3(int, __libc_msgctl, int, msqid, int, cmd, struct msqid_ds *, buf);
+static __inline__ _syscall3(int, __libc_msgctl, int, msqid, int, cmd, struct msqid_ds *, buf)
#endif
/* Message queue control operation. */
int msgctl(int msqid, int cmd, struct msqid_ds *buf)
diff --git a/libc/misc/sysvipc/sem.c b/libc/misc/sysvipc/sem.c
index e340216e9..cca4cdfcc 100644
--- a/libc/misc/sysvipc/sem.c
+++ b/libc/misc/sysvipc/sem.c
@@ -41,7 +41,7 @@ union semun {
#ifdef __NR_semctl
#define __NR___semctl __NR_semctl
-static __inline__ _syscall4(int, __semctl, int, semid, int, semnum, int, cmd, void *, arg);
+static __inline__ _syscall4(int, __semctl, int, semid, int, semnum, int, cmd, void *, arg)
#endif
int semctl(int semid, int semnum, int cmd, ...)
diff --git a/libc/misc/sysvipc/shm.c b/libc/misc/sysvipc/shm.c
index 4b7ea0753..27e871f27 100644
--- a/libc/misc/sysvipc/shm.c
+++ b/libc/misc/sysvipc/shm.c
@@ -55,7 +55,7 @@ void * shmat (int shmid, const void *shmaddr, int shmflg)
/* Provide operations to control over shared memory segments. */
#ifdef __NR_shmctl
#define __NR___libc_shmctl __NR_shmctl
-static __inline__ _syscall3(int, __libc_shmctl, int, shmid, int, cmd, struct shmid_ds *, buf);
+static __inline__ _syscall3(int, __libc_shmctl, int, shmid, int, cmd, struct shmid_ds *, buf)
#endif
int shmctl(int shmid, int cmd, struct shmid_ds *buf)
{
diff --git a/libc/misc/time/time.c b/libc/misc/time/time.c
index ff44892a8..19d68e105 100644
--- a/libc/misc/time/time.c
+++ b/libc/misc/time/time.c
@@ -799,7 +799,6 @@ size_t strftime(char *__restrict s, size_t maxsize,
{
return strftime_l(s, maxsize, format, timeptr, __UCLIBC_CURLOCALE);
}
-libc_hidden_def(strftime)
#else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
@@ -999,7 +998,6 @@ static int load_field(int k, const struct tm *__restrict timeptr)
#warning TODO: Check multibyte format string validity.
#endif
-libc_hidden_proto(__XL_NPP(strftime))
size_t __XL_NPP(strftime)(char *__restrict s, size_t maxsize,
const char *__restrict format,
const struct tm *__restrict timeptr __LOCALE_PARAM )
@@ -1013,7 +1011,7 @@ size_t __XL_NPP(strftime)(char *__restrict s, size_t maxsize,
const char *stack[MAX_PUSH];
size_t count;
size_t o_count;
- int field_val, i, j, lvl;
+ int field_val = 0, i = 0, j, lvl;
int x[3]; /* wday, yday, year */
int isofm, days;
char buf[__UIM_BUFLEN_LONG];
@@ -1291,7 +1289,9 @@ OUTPUT:
}
goto LOOP;
}
-libc_hidden_def(__XL_NPP(strftime))
+# ifdef L_strftime_l
+libc_hidden_def(strftime_l)
+# endif
#endif /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
@@ -1314,7 +1314,6 @@ char *strptime(const char *__restrict buf, const char *__restrict format,
{
return strptime_l(buf, format, tm, __UCLIBC_CURLOCALE);
}
-libc_hidden_def(strptime)
#else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
@@ -1460,7 +1459,6 @@ static const unsigned char spec[] = {
#define MAX_PUSH 4
-libc_hidden_proto(__XL_NPP(strptime))
char *__XL_NPP(strptime)(const char *__restrict buf, const char *__restrict format,
struct tm *__restrict tm __LOCALE_PARAM)
{
@@ -1671,7 +1669,9 @@ LOOP:
}
return NULL;
}
-libc_hidden_def(__XL_NPP(strptime))
+# ifdef L_strptime_l
+libc_hidden_def(strptime_l)
+# endif
#endif /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
@@ -2455,11 +2455,9 @@ size_t wcsftime(wchar_t *__restrict s, size_t maxsize,
{
return wcsftime_l(s, maxsize, format, timeptr, __UCLIBC_CURLOCALE);
}
-libc_hidden_def(wcsftime)
#else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
-libc_hidden_proto(__XL_NPP(wcsftime))
size_t __XL_NPP(wcsftime)(wchar_t *__restrict s, size_t maxsize,
const wchar_t *__restrict format,
const struct tm *__restrict timeptr __LOCALE_PARAM )
@@ -2467,7 +2465,9 @@ size_t __XL_NPP(wcsftime)(wchar_t *__restrict s, size_t maxsize,
#warning wcsftime always fails
return 0; /* always fail */
}
-libc_hidden_def(__XL_NPP(wcsftime))
+#ifdef L_wcsftime_l
+libc_hidden_def(wcsftime_l)
+#endif
#endif /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
diff --git a/libc/misc/utmp/utent.c b/libc/misc/utmp/utent.c
index bf265c2a3..11d615437 100644
--- a/libc/misc/utmp/utent.c
+++ b/libc/misc/utmp/utent.c
@@ -98,8 +98,8 @@ struct utmp *getutent(void)
__UCLIBC_MUTEX_UNLOCK(utmplock);
return ret;
}
-libc_hidden_def(getutent)
#endif
+libc_hidden_def(getutent)
void endutent(void)
{
diff --git a/libc/misc/wctype/_wctype.c b/libc/misc/wctype/_wctype.c
index 296293ff3..89269f45e 100644
--- a/libc/misc/wctype/_wctype.c
+++ b/libc/misc/wctype/_wctype.c
@@ -140,28 +140,27 @@ enum {
#ifdef __UCLIBC_DO_XLOCALE
#define ISW_FUNC_BODY(NAME) \
-libc_hidden_proto(__PASTE3(isw,NAME,_l)) \
int __PASTE3(isw,NAME,_l) (wint_t wc, __locale_t l) \
{ \
return iswctype_l(wc, __PASTE2(_CTYPE_is,NAME), l); \
-} \
-libc_hidden_def(__PASTE3(isw,NAME,_l))
+}
#else /* __UCLIBC_DO_XLOCALE */
#define ISW_FUNC_BODY(NAME) \
-libc_hidden_proto(__PASTE2(isw,NAME)) \
int __PASTE2(isw,NAME) (wint_t wc) \
{ \
return iswctype(wc, __PASTE2(_CTYPE_is,NAME)); \
-} \
-libc_hidden_def(__PASTE2(isw,NAME))
+}
#endif /* __UCLIBC_DO_XLOCALE */
/**********************************************************************/
#if defined(L_iswalnum) || defined(L_iswalnum_l)
ISW_FUNC_BODY(alnum);
+# ifdef L_iswalnum
+libc_hidden_def(iswalnum)
+# endif
#endif
/**********************************************************************/
@@ -198,6 +197,9 @@ ISW_FUNC_BODY(graph);
#if defined(L_iswlower) || defined(L_iswlower_l)
ISW_FUNC_BODY(lower);
+# ifdef L_iswlower
+libc_hidden_def(iswlower)
+# endif
#endif
/**********************************************************************/
@@ -216,12 +218,20 @@ ISW_FUNC_BODY(punct);
#if defined(L_iswspace) || defined(L_iswspace_l)
ISW_FUNC_BODY(space);
+# ifdef L_iswspace
+libc_hidden_def(iswspace)
+# else
+libc_hidden_def(iswspace_l)
+# endif
#endif
/**********************************************************************/
#if defined(L_iswupper) || defined(L_iswupper_l)
ISW_FUNC_BODY(upper);
+# ifdef L_iswupper
+libc_hidden_def(iswupper)
+# endif
#endif
/**********************************************************************/
@@ -461,7 +471,6 @@ wctype_t wctype_l (const char *property, __locale_t locale)
{
return wctype(property);
}
-libc_hidden_def(wctype_l)
#endif
/**********************************************************************/
diff --git a/libc/stdio/_scanf.c b/libc/stdio/_scanf.c
index 1ad81cbe3..f38e72b5c 100644
--- a/libc/stdio/_scanf.c
+++ b/libc/stdio/_scanf.c
@@ -198,7 +198,6 @@ int vscanf(const char * __restrict format, va_list arg)
{
return vfscanf(stdin, format, arg);
}
-libc_hidden_def(vscanf)
#endif
/**********************************************************************/
diff --git a/libc/stdio/_vfprintf.c b/libc/stdio/_vfprintf.c
index 3b007084d..3db8cdf67 100644
--- a/libc/stdio/_vfprintf.c
+++ b/libc/stdio/_vfprintf.c
@@ -417,6 +417,8 @@ extern uintmax_t _load_inttype(int desttype, const void *src, int uflag) attribu
/**********************************************************************/
#ifdef L_parse_printf_format
+#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_PRINTF__
+
/* NOTE: This function differs from the glibc version in that parsing stops
* upon encountering an invalid conversion specifier. Since this is the way
* my printf functions work, I think it makes sense to do it that way here.
@@ -485,6 +487,8 @@ size_t parse_printf_format(register const char *template,
}
#endif
+
+#endif
/**********************************************************************/
#ifdef L__ppfs_init
@@ -1670,6 +1674,9 @@ static int _do_one_spec(FILE * __restrict stream,
#endif
s = "(null)";
slen = 6;
+ /* Use an empty string rather than truncation if precision is too small. */
+ if (ppfs->info.prec >= 0 && ppfs->info.prec < slen)
+ slen = 0;
}
} else { /* char */
s = buf;
@@ -1726,6 +1733,9 @@ static int _do_one_spec(FILE * __restrict stream,
NULL_STRING:
s = "(null)";
SLEN = slen = 6;
+ /* Use an empty string rather than truncation if precision is too small. */
+ if (ppfs->info.prec >= 0 && ppfs->info.prec < slen)
+ SLEN = slen = 0;
}
} else { /* char */
*wbuf = btowc( (unsigned char)(*((const int *) *argptr)) );
diff --git a/libc/stdio/fwprintf.c b/libc/stdio/fwprintf.c
index 2f2dddc10..954970867 100644
--- a/libc/stdio/fwprintf.c
+++ b/libc/stdio/fwprintf.c
@@ -21,4 +21,3 @@ int fwprintf(FILE * __restrict stream, const wchar_t * __restrict format, ...)
return rv;
}
-libc_hidden_def(fwprintf)
diff --git a/libc/stdlib/_strtod.c b/libc/stdlib/_strtod.c
index dc5d55743..1d58258e7 100644
--- a/libc/stdlib/_strtod.c
+++ b/libc/stdlib/_strtod.c
@@ -544,7 +544,6 @@ libc_hidden_def(__XL_NPP(strtof))
#define Wchar char
#endif
-libc_hidden_proto(__XL_NPP(strtod))
double __XL_NPP(strtod)(const Wchar *__restrict str,
Wchar **__restrict endptr __LOCALE_PARAM )
{
@@ -562,7 +561,9 @@ double __XL_NPP(strtod)(const Wchar *__restrict str,
return y;
#endif
}
-libc_hidden_def(__XL_NPP(strtod))
+#ifdef L_strtod
+libc_hidden_def(strtod)
+#endif
#endif
#endif
@@ -580,7 +581,6 @@ libc_hidden_def(__XL_NPP(strtod))
#define Wchar char
#endif
-libc_hidden_proto(__XL_NPP(strtold))
long double __XL_NPP(strtold) (const Wchar *str, Wchar **endptr __LOCALE_PARAM )
{
#if FPMAX_TYPE == 3
@@ -597,7 +597,6 @@ long double __XL_NPP(strtold) (const Wchar *str, Wchar **endptr __LOCALE_PARAM
return y;
#endif
}
-libc_hidden_def(__XL_NPP(strtold))
#endif
#endif
diff --git a/libc/stdlib/arc4random.c b/libc/stdlib/arc4random.c
index 97f318a57..c7aed66b6 100644
--- a/libc/stdlib/arc4random.c
+++ b/libc/stdlib/arc4random.c
@@ -54,8 +54,7 @@ static __inline__ uint8_t arc4_getbyte(struct arc4_stream *);
static __inline__ uint32_t arc4_getword(struct arc4_stream *);
static __inline__ void
-arc4_init(as)
- struct arc4_stream *as;
+arc4_init(struct arc4_stream *as)
{
int n;
@@ -66,10 +65,7 @@ arc4_init(as)
}
static __inline__ void
-arc4_addrandom(as, dat, datlen)
- struct arc4_stream *as;
- u_char *dat;
- int datlen;
+arc4_addrandom(struct arc4_stream *as, u_char *dat, int datlen)
{
int n;
uint8_t si;
@@ -86,8 +82,7 @@ arc4_addrandom(as, dat, datlen)
}
static void
-arc4_stir(as)
- struct arc4_stream *as;
+arc4_stir(struct arc4_stream *as)
{
int fd;
struct {
@@ -137,8 +132,7 @@ arc4_stir(as)
}
static __inline__ uint8_t
-arc4_getbyte(as)
- struct arc4_stream *as;
+arc4_getbyte(struct arc4_stream *as)
{
uint8_t si, sj;
@@ -152,8 +146,7 @@ arc4_getbyte(as)
}
static __inline__ uint32_t
-arc4_getword(as)
- struct arc4_stream *as;
+arc4_getword(struct arc4_stream *as)
{
uint32_t val;
val = arc4_getbyte(as) << 24;
@@ -163,8 +156,8 @@ arc4_getword(as)
return val;
}
-void
-arc4random_stir(void)
+static void
+__arc4random_stir(void)
{
if (!rs_initialized) {
arc4_init(&rs);
@@ -172,13 +165,13 @@ arc4random_stir(void)
}
arc4_stir(&rs);
}
-libc_hidden_def(arc4random_stir)
+strong_alias(__arc4random_stir,arc4random_stir)
void
arc4random_addrandom(u_char *dat, int datlen)
{
if (!rs_initialized)
- arc4random_stir();
+ __arc4random_stir();
arc4_addrandom(&rs, dat, datlen);
}
@@ -186,7 +179,7 @@ uint32_t
arc4random(void)
{
if (!rs_initialized)
- arc4random_stir();
+ __arc4random_stir();
return arc4_getword(&rs);
}
diff --git a/libc/stdlib/drand48-iter.c b/libc/stdlib/drand48-iter.c
index 221cbe08f..7d705adca 100644
--- a/libc/stdlib/drand48-iter.c
+++ b/libc/stdlib/drand48-iter.c
@@ -21,15 +21,15 @@
#include <stdlib.h>
#include <limits.h>
#include <stdint.h>
+#include <stdlib.h>
#include <sys/types.h>
/* Global state for non-reentrant functions. */
-struct drand48_data __libc_drand48_data attribute_hidden;
+struct drand48_data __libc_drand48_data;
#ifdef __UCLIBC_MJN3_ONLY__
#warning turn int __drand48_iterate into void
#endif /* __UCLIBC_MJN3_ONLY__ */
-int __drand48_iterate (unsigned short int xsubi[3], struct drand48_data *buffer) attribute_hidden;
int __drand48_iterate (unsigned short int xsubi[3], struct drand48_data *buffer)
{
uint64_t X;
diff --git a/libc/stdlib/drand48.c b/libc/stdlib/drand48.c
index 8c9017b11..c53dcfbfc 100644
--- a/libc/stdlib/drand48.c
+++ b/libc/stdlib/drand48.c
@@ -19,10 +19,6 @@
#include <stdlib.h>
-
-/* Global state for non-reentrant functions. Defined in drand48-iter.c. */
-extern struct drand48_data __libc_drand48_data attribute_hidden;
-
double drand48 (void)
{
double result;
diff --git a/libc/stdlib/erand48.c b/libc/stdlib/erand48.c
index ee28d9635..f3603cde0 100644
--- a/libc/stdlib/erand48.c
+++ b/libc/stdlib/erand48.c
@@ -19,10 +19,6 @@
#include <stdlib.h>
-
-/* Global state for non-reentrant functions. Defined in drand48-iter.c. */
-extern struct drand48_data __libc_drand48_data attribute_hidden;
-
double erand48 (unsigned short int xsubi[3])
{
double result;
diff --git a/libc/stdlib/erand48_r.c b/libc/stdlib/erand48_r.c
index e36e73eb2..bd40a3488 100644
--- a/libc/stdlib/erand48_r.c
+++ b/libc/stdlib/erand48_r.c
@@ -21,9 +21,6 @@
#include <stdlib.h>
#include <limits.h>
-extern int __drand48_iterate(unsigned short xsubi[3],
- struct drand48_data *buffer) attribute_hidden;
-
int erand48_r (unsigned short int xsubi[3], struct drand48_data *buffer, double *result)
{
union ieee754_double temp;
diff --git a/libc/stdlib/jrand48.c b/libc/stdlib/jrand48.c
index 163c5408e..8a06ced56 100644
--- a/libc/stdlib/jrand48.c
+++ b/libc/stdlib/jrand48.c
@@ -19,10 +19,6 @@
#include <stdlib.h>
-
-/* Global state for non-reentrant functions. Defined in drand48-iter.c. */
-extern struct drand48_data __libc_drand48_data attribute_hidden;
-
long int jrand48 (unsigned short int xsubi[3])
{
long int result;
diff --git a/libc/stdlib/jrand48_r.c b/libc/stdlib/jrand48_r.c
index 24f7075f5..5652d1016 100644
--- a/libc/stdlib/jrand48_r.c
+++ b/libc/stdlib/jrand48_r.c
@@ -19,9 +19,6 @@
#include <stdlib.h>
-extern int __drand48_iterate(unsigned short xsubi[3],
- struct drand48_data *buffer) attribute_hidden;
-
int jrand48_r (unsigned short int xsubi[3], struct drand48_data *buffer, long int *result)
{
/* Compute next state. */
diff --git a/libc/stdlib/lrand48.c b/libc/stdlib/lrand48.c
index a0b15caff..915638b80 100644
--- a/libc/stdlib/lrand48.c
+++ b/libc/stdlib/lrand48.c
@@ -19,10 +19,6 @@
#include <stdlib.h>
-
-/* Global state for non-reentrant functions. Defined in drand48-iter.c. */
-extern struct drand48_data __libc_drand48_data attribute_hidden;
-
long int lrand48 (void)
{
long int result;
diff --git a/libc/stdlib/malloc/memalign.c b/libc/stdlib/malloc/memalign.c
index 6826d623a..5edd6e1cd 100644
--- a/libc/stdlib/malloc/memalign.c
+++ b/libc/stdlib/malloc/memalign.c
@@ -14,13 +14,12 @@
#include <stdlib.h>
#include <unistd.h>
#include <sys/mman.h>
+#include <sys/param.h> /* MAX */
#include "malloc.h"
#include "heap.h"
-#define MAX(x,y) ((x) > (y) ? (x) : (y))
-
/*
______________________ TOTAL _________________________
/ \
diff --git a/libc/stdlib/mrand48.c b/libc/stdlib/mrand48.c
index b209acd57..6f7cf734c 100644
--- a/libc/stdlib/mrand48.c
+++ b/libc/stdlib/mrand48.c
@@ -19,10 +19,6 @@
#include <stdlib.h>
-
-/* Global state for non-reentrant functions. Defined in drand48-iter.c. */
-extern struct drand48_data __libc_drand48_data attribute_hidden;
-
long int mrand48 (void)
{
long int result;
diff --git a/libc/stdlib/nrand48.c b/libc/stdlib/nrand48.c
index 97c197caa..5183484fa 100644
--- a/libc/stdlib/nrand48.c
+++ b/libc/stdlib/nrand48.c
@@ -19,10 +19,6 @@
#include <stdlib.h>
-
-/* Global state for non-reentrant functions. Defined in drand48-iter.c. */
-extern struct drand48_data __libc_drand48_data attribute_hidden;
-
long int nrand48 (unsigned short int xsubi[3])
{
long int result;
diff --git a/libc/stdlib/nrand48_r.c b/libc/stdlib/nrand48_r.c
index 0710e90ef..b8ed0eb31 100644
--- a/libc/stdlib/nrand48_r.c
+++ b/libc/stdlib/nrand48_r.c
@@ -19,9 +19,6 @@
#include <stdlib.h>
-extern int __drand48_iterate(unsigned short xsubi[3],
- struct drand48_data *buffer) attribute_hidden;
-
int nrand48_r (unsigned short int xsubi[3], struct drand48_data *buffer, long int *result)
{
/* Compute next state. */
diff --git a/libc/stdlib/seed48.c b/libc/stdlib/seed48.c
index 9ff8a480a..a62dc2e64 100644
--- a/libc/stdlib/seed48.c
+++ b/libc/stdlib/seed48.c
@@ -19,10 +19,6 @@
#include <stdlib.h>
-
-/* Global state for non-reentrant functions. Defined in drand48-iter.c. */
-extern struct drand48_data __libc_drand48_data attribute_hidden;
-
unsigned short int *
seed48 (unsigned short int seed16v[3])
{
diff --git a/libc/stdlib/srand48.c b/libc/stdlib/srand48.c
index 817d068c3..f55374371 100644
--- a/libc/stdlib/srand48.c
+++ b/libc/stdlib/srand48.c
@@ -19,10 +19,6 @@
#include <stdlib.h>
-
-/* Global state for non-reentrant functions. Defined in drand48-iter.c. */
-extern struct drand48_data __libc_drand48_data attribute_hidden;
-
void srand48 (long seedval)
{
srand48_r (seedval, &__libc_drand48_data);
diff --git a/libc/stdlib/stdlib.c b/libc/stdlib/stdlib.c
index 4d608eeac..cd9a0cac6 100644
--- a/libc/stdlib/stdlib.c
+++ b/libc/stdlib/stdlib.c
@@ -286,11 +286,11 @@ long atol(const char *nptr)
{
return strtol(nptr, (char **) NULL, 10);
}
-libc_hidden_def(atol)
#if UINT_MAX == ULONG_MAX
#undef atoi
extern __typeof(atol) atoi;
+/* the one in stdlib.h is not enough due to prototype mismatch */
libc_hidden_proto(atoi)
strong_alias(atol,atoi)
libc_hidden_def(atoi)
@@ -339,10 +339,13 @@ strong_alias(strtol,strtoimax)
#undef strtoll
#endif
extern __typeof(__XL_NPP(strtol)) __XL_NPP(strtoll);
+/* the one in stdlib.h is not enough due to prototype mismatch */
+#ifdef L_strtol
libc_hidden_proto(__XL_NPP(strtoll))
+#endif
strong_alias(__XL_NPP(strtol),__XL_NPP(strtoll))
+#ifdef L_strtol
libc_hidden_def(__XL_NPP(strtoll))
-#if !defined(L_strtol_l)
strong_alias(strtol,strtoq)
#endif
#endif
@@ -353,16 +356,14 @@ strong_alias(strtol,strtoq)
#if defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX)
-libc_hidden_proto(__XL_NPP(strtoll))
long long __XL_NPP(strtoll)(const char * __restrict str,
char ** __restrict endptr, int base
__LOCALE_PARAM)
{
return (long long) __XL_NPP(_stdlib_strto_ll)(str, endptr, base, 1 __LOCALE_ARG);
}
+#ifdef L_strtoll
libc_hidden_def(__XL_NPP(strtoll))
-
-#if !defined(L_strtoll_l)
#if (ULLONG_MAX == UINTMAX_MAX)
strong_alias(strtoll,strtoimax)
#endif
@@ -375,7 +376,6 @@ strong_alias(strtoll,strtoq)
/**********************************************************************/
#if defined(L_strtoul) || defined(L_strtoul_l)
-libc_hidden_proto(__XL_NPP(strtoul))
unsigned long __XL_NPP(strtoul)(const char * __restrict str,
char ** __restrict endptr, int base
__LOCALE_PARAM)
@@ -395,9 +395,7 @@ strong_alias(strtoul,strtoumax)
#undef strtoull
#endif
extern __typeof(__XL_NPP(strtoul)) __XL_NPP(strtoull);
-libc_hidden_proto(__XL_NPP(strtoull))
strong_alias(__XL_NPP(strtoul),__XL_NPP(strtoull))
-libc_hidden_def(__XL_NPP(strtoull))
#if !defined(L_strtoul_l)
strong_alias(strtoul,strtouq)
#endif
@@ -410,14 +408,12 @@ strong_alias(strtoul,strtouq)
#if defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX)
-libc_hidden_proto(__XL_NPP(strtoull))
unsigned long long __XL_NPP(strtoull)(const char * __restrict str,
char ** __restrict endptr, int base
__LOCALE_PARAM)
{
return __XL_NPP(_stdlib_strto_ll)(str, endptr, base, 0 __LOCALE_ARG);
}
-libc_hidden_def(__XL_NPP(strtoull))
#if !defined(L_strtoull_l)
#if (ULLONG_MAX == UINTMAX_MAX)
@@ -1047,13 +1043,11 @@ size_t wcstombs(char * __restrict s, const wchar_t * __restrict pwcs, size_t n)
/**********************************************************************/
#if defined(L_wcstol) || defined(L_wcstol_l)
-libc_hidden_proto(__XL_NPP(wcstol))
long __XL_NPP(wcstol)(const wchar_t * __restrict str,
wchar_t ** __restrict endptr, int base __LOCALE_PARAM)
{
return __XL_NPP(_stdlib_wcsto_l)(str, endptr, base, 1 __LOCALE_ARG);
}
-libc_hidden_def(__XL_NPP(wcstol))
#if (ULONG_MAX == UINTMAX_MAX) && !defined(L_wcstol_l)
strong_alias(wcstol,wcstoimax)
@@ -1066,9 +1060,7 @@ strong_alias(wcstol,wcstoimax)
#undef wcstoll
#endif
extern __typeof(__XL_NPP(wcstol)) __XL_NPP(wcstoll);
-libc_hidden_proto(__XL_NPP(wcstoll))
strong_alias(__XL_NPP(wcstol),__XL_NPP(wcstoll))
-libc_hidden_def(__XL_NPP(wcstoll))
#endif
#endif
@@ -1077,14 +1069,12 @@ libc_hidden_def(__XL_NPP(wcstoll))
#if defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX)
-libc_hidden_proto(__XL_NPP(wcstoll))
long long __XL_NPP(wcstoll)(const wchar_t * __restrict str,
wchar_t ** __restrict endptr, int base
__LOCALE_PARAM)
{
return (long long) __XL_NPP(_stdlib_wcsto_ll)(str, endptr, base, 1 __LOCALE_ARG);
}
-libc_hidden_def(__XL_NPP(wcstoll))
#if !defined(L_wcstoll_l)
#if (ULLONG_MAX == UINTMAX_MAX)
@@ -1099,14 +1089,12 @@ strong_alias(wcstoll,wcstoq)
/**********************************************************************/
#if defined(L_wcstoul) || defined(L_wcstoul_l)
-libc_hidden_proto(__XL_NPP(wcstoul))
unsigned long __XL_NPP(wcstoul)(const wchar_t * __restrict str,
wchar_t ** __restrict endptr, int base
__LOCALE_PARAM)
{
return __XL_NPP(_stdlib_wcsto_l)(str, endptr, base, 0 __LOCALE_ARG);
}
-libc_hidden_def(__XL_NPP(wcstoul))
#if (ULONG_MAX == UINTMAX_MAX) && !defined(L_wcstoul_l)
strong_alias(wcstoul,wcstoumax)
@@ -1119,9 +1107,7 @@ strong_alias(wcstoul,wcstoumax)
#undef wcstoull
#endif
extern __typeof(__XL_NPP(wcstoul)) __XL_NPP(wcstoull);
-libc_hidden_proto(__XL_NPP(wcstoull))
strong_alias(__XL_NPP(wcstoul),__XL_NPP(wcstoull))
-libc_hidden_def(__XL_NPP(wcstoull))
#endif
#endif
@@ -1130,14 +1116,12 @@ libc_hidden_def(__XL_NPP(wcstoull))
#if defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX)
-libc_hidden_proto(__XL_NPP(wcstoull))
unsigned long long __XL_NPP(wcstoull)(const wchar_t * __restrict str,
wchar_t ** __restrict endptr, int base
__LOCALE_PARAM)
{
return __XL_NPP(_stdlib_wcsto_ll)(str, endptr, base, 0 __LOCALE_ARG);
}
-libc_hidden_def(__XL_NPP(wcstoull))
#if !defined(L_wcstoull_l)
#if (ULLONG_MAX == UINTMAX_MAX)
diff --git a/libc/string/_collate.c b/libc/string/_collate.c
index 77d9eb62c..def56d260 100644
--- a/libc/string/_collate.c
+++ b/libc/string/_collate.c
@@ -62,7 +62,6 @@ size_t wcsxfrm(Wchar *__restrict ws1, const Wchar *__restrict ws2, size_t n)
{
return wcsxfrm_l(ws1, ws2, n, __UCLIBC_CURLOCALE );
}
-libc_hidden_def(wcsxfrm)
#else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
@@ -500,7 +499,6 @@ static void next_weight(col_state_t *cs, int pass __LOCALE_PARAM )
} while (1);
}
-libc_hidden_proto(__XL_NPP(wcscoll))
int __XL_NPP(wcscoll) (const Wchar *s0, const Wchar *s1 __LOCALE_PARAM )
{
col_state_t ws[2];
@@ -538,10 +536,6 @@ libc_hidden_def(__XL_NPP(wcscoll))
#ifdef WANT_WIDE
-extern size_t __wcslcpy(wchar_t *__restrict dst,
- const wchar_t *__restrict src, size_t n);
-
-libc_hidden_proto(__XL_NPP(wcsxfrm))
size_t __XL_NPP(wcsxfrm)(wchar_t *__restrict ws1, const wchar_t *__restrict ws2,
size_t n __LOCALE_PARAM )
{
@@ -579,7 +573,9 @@ size_t __XL_NPP(wcsxfrm)(wchar_t *__restrict ws1, const wchar_t *__restrict ws2,
}
return count-1;
}
+#if defined L_strxfrm_l || defined L_wcsxfrm_l
libc_hidden_def(__XL_NPP(wcsxfrm))
+#endif
#else /* WANT_WIDE */
@@ -623,7 +619,6 @@ static size_t store(unsigned char *s, size_t count, size_t n, __uwchar_t weight)
return r;
}
-libc_hidden_proto(__XL_NPP(strxfrm))
size_t __XL_NPP(strxfrm)(char *__restrict ws1, const char *__restrict ws2, size_t n
__LOCALE_PARAM )
{
@@ -661,7 +656,9 @@ size_t __XL_NPP(strxfrm)(char *__restrict ws1, const char *__restrict ws2, size_
}
return count-1;
}
+#ifdef L_strxfrm_l
libc_hidden_def(__XL_NPP(strxfrm))
+#endif
#endif /* WANT_WIDE */
diff --git a/libc/string/ffs.c b/libc/string/ffs.c
index 22efe4a1e..f39d304b7 100644
--- a/libc/string/ffs.c
+++ b/libc/string/ffs.c
@@ -5,11 +5,9 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-/* ffsl,ffsll */
-
-#include "_string.h"
-
-
+#include <limits.h>
+#include <string.h>
+
int ffs(int i)
{
#if 1
@@ -52,3 +50,6 @@ int ffs(int i)
#endif
}
libc_hidden_def(ffs)
+#if ULONG_MAX == UINT_MAX
+strong_alias_untyped(ffs, ffsl)
+#endif
diff --git a/libc/string/ffsll.c b/libc/string/ffsll.c
new file mode 100644
index 000000000..a7662900b
--- /dev/null
+++ b/libc/string/ffsll.c
@@ -0,0 +1,36 @@
+/* Copyright (C) 1991, 1992, 1997, 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Torbjorn Granlund (tege@sics.se).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <limits.h>
+#include <string.h>
+
+/* Find the first bit set in I. */
+int ffsll (long long int i)
+{
+ unsigned long long int x = i & -i;
+
+ if (x <= 0xffffffff)
+ return ffs (i);
+ else
+ return 32 + ffs (i >> 32);
+}
+
+#if ULONG_MAX != UINT_MAX
+strong_alias_untyped(ffsll, ffsl)
+#endif
diff --git a/libc/string/frv/memset.S b/libc/string/frv/memset.S
index a3e76c491..bc0f80db0 100644
--- a/libc/string/frv/memset.S
+++ b/libc/string/frv/memset.S
@@ -155,3 +155,4 @@ memset:
bralr
.size memset, .-memset
+libc_hidden_def(memset)
diff --git a/libc/string/generic/memmem.c b/libc/string/generic/memmem.c
index 0fccac77f..97384978b 100644
--- a/libc/string/generic/memmem.c
+++ b/libc/string/generic/memmem.c
@@ -48,5 +48,4 @@ void *memmem (const void *haystack, size_t haystack_len,
return NULL;
}
-libc_hidden_def(memmem)
#endif
diff --git a/libc/string/generic/strcpy.c b/libc/string/generic/strcpy.c
index 4d070531f..ace6dea58 100644
--- a/libc/string/generic/strcpy.c
+++ b/libc/string/generic/strcpy.c
@@ -17,9 +17,6 @@
02111-1307 USA. */
#include <string.h>
-#include <stddef.h>
-
-#include "memcopy.h"
/* Copy SRC to DEST. */
char *strcpy(char *dest, const char *src)
diff --git a/libc/string/memmem.c b/libc/string/memmem.c
index f568a4261..1b3a0bab6 100644
--- a/libc/string/memmem.c
+++ b/libc/string/memmem.c
@@ -37,5 +37,4 @@ void *memmem(const void *haystack, size_t haystacklen,
return NULL;
}
-libc_hidden_def(memmem)
#endif
diff --git a/libc/string/stpncpy.c b/libc/string/stpncpy.c
index 088145dea..50d83a131 100644
--- a/libc/string/stpncpy.c
+++ b/libc/string/stpncpy.c
@@ -27,7 +27,3 @@ Wchar *Wstpncpy(register Wchar * __restrict s1,
}
return s1 + (s2 - p);
}
-
-#ifndef WANT_WIDE
-libc_hidden_def(stpncpy)
-#endif
diff --git a/libc/string/strcasecmp.c b/libc/string/strcasecmp.c
index 33e48fa22..f894e426e 100644
--- a/libc/string/strcasecmp.c
+++ b/libc/string/strcasecmp.c
@@ -31,7 +31,9 @@ int strcasecmp(register const Wchar *s1, register const Wchar *s2)
{
return strcasecmp_l(s1, s2, __UCLIBC_CURLOCALE);
}
+#ifndef WANT_WIDE
libc_hidden_def(strcasecmp)
+#endif
#else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
@@ -59,6 +61,8 @@ int __XL_NPP(strcasecmp)(register const Wchar *s1, register const Wchar *s2
return r;
#endif
}
+#if !defined WANT_WIDE || (defined WANT_WIDE && defined __UCLIBC_DO_XLOCALE)
libc_hidden_def(__XL_NPP(strcasecmp))
+#endif
#endif /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
diff --git a/libc/string/strchr.c b/libc/string/strchr.c
index 462b7b1f1..7ea477362 100644
--- a/libc/string/strchr.c
+++ b/libc/string/strchr.c
@@ -23,8 +23,9 @@ Wchar *Wstrchr(register const Wchar *s, Wint c)
return NULL;
}
-libc_hidden_def(Wstrchr)
-
-#if !defined WANT_WIDE && defined __UCLIBC_SUSV3_LEGACY__
+#ifndef WANT_WIDE
+libc_hidden_def(strchr)
+# ifdef __UCLIBC_SUSV3_LEGACY__
weak_alias(strchr,index)
+# endif
#endif
diff --git a/libc/string/strchrnul.c b/libc/string/strchrnul.c
index d2d7df307..4751971bc 100644
--- a/libc/string/strchrnul.c
+++ b/libc/string/strchrnul.c
@@ -21,5 +21,7 @@ Wchar *Wstrchrnul(register const Wchar *s, Wint c)
while (*++s && (*s != ((Wchar)c)));
return (Wchar *) s;
}
+# ifndef WANT_WIDE
libc_hidden_def(Wstrchrnul)
+# endif
#endif
diff --git a/libc/string/strcpy.c b/libc/string/strcpy.c
index bb5a16872..549360c22 100644
--- a/libc/string/strcpy.c
+++ b/libc/string/strcpy.c
@@ -22,8 +22,6 @@ Wchar *Wstrcpy(Wchar * __restrict s1, const Wchar * __restrict s2)
return s1;
}
-#ifdef WANT_WIDE
-/* wcscpy does not need libc_hidden_def */
-#else
+#ifndef WANT_WIDE
libc_hidden_def(strcpy)
#endif
diff --git a/libc/string/strlcpy.c b/libc/string/strlcpy.c
index 0ccfc0e8a..83787049a 100644
--- a/libc/string/strlcpy.c
+++ b/libc/string/strlcpy.c
@@ -9,19 +9,16 @@
#ifdef WANT_WIDE
# define Wstrlcpy __wcslcpy
+# define Wstrxfrm wcsxfrm
#else
# define Wstrlcpy strlcpy
+# define Wstrxfrm strxfrm
#endif
/* OpenBSD function:
* Copy at most n-1 chars from src to dst and nul-terminate dst.
* Returns strlen(src), so truncation occurred if the return value is >= n. */
-#ifdef WANT_WIDE
-size_t Wstrlcpy(register Wchar *__restrict dst,
- register const Wchar *__restrict src,
- size_t n) attribute_hidden;
-#endif
size_t Wstrlcpy(register Wchar *__restrict dst,
register const Wchar *__restrict src,
size_t n)
@@ -45,19 +42,10 @@ size_t Wstrlcpy(register Wchar *__restrict dst,
return src - src0;
}
-#ifdef WANT_WIDE
-
-#ifndef __UCLIBC_HAS_LOCALE__
-strong_alias(__wcslcpy,wcsxfrm)
-libc_hidden_def(wcsxfrm)
-#endif
-
-#else
-
+#ifndef WANT_WIDE
libc_hidden_def(strlcpy)
-#ifndef __UCLIBC_HAS_LOCALE__
-strong_alias(strlcpy,strxfrm)
-libc_hidden_def(strxfrm)
#endif
+#ifndef __UCLIBC_HAS_LOCALE__
+strong_alias(Wstrlcpy,Wstrxfrm)
#endif
diff --git a/libc/string/strncasecmp.c b/libc/string/strncasecmp.c
index 2af305e16..2eac47dd4 100644
--- a/libc/string/strncasecmp.c
+++ b/libc/string/strncasecmp.c
@@ -31,7 +31,9 @@ int strncasecmp(register const Wchar *s1, register const Wchar *s2, size_t n)
{
return strncasecmp_l(s1, s2, n, __UCLIBC_CURLOCALE);
}
+#ifndef WANT_WIDE
libc_hidden_def(strncasecmp)
+#endif
#else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
@@ -62,6 +64,8 @@ int __XL_NPP(strncasecmp)(register const Wchar *s1, register const Wchar *s2,
return r;
#endif
}
+#if !defined WANT_WIDE || (defined WANT_WIDE && defined __UCLIBC_DO_XLOCALE)
libc_hidden_def(__XL_NPP(strncasecmp))
+#endif
#endif /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
diff --git a/libc/string/x86_64/memcpy.S b/libc/string/x86_64/memcpy.S
index 6d941e0f2..9c8169b42 100644
--- a/libc/string/x86_64/memcpy.S
+++ b/libc/string/x86_64/memcpy.S
@@ -26,12 +26,10 @@
#define MEMPCPY_P (defined memcpy)
.text
-#if defined __PIC__ && !defined NOT_IN_libc
+#if defined __PIC__ && !defined NOT_IN_libc && defined __UCLIBC_HAS_FORTIFY__
ENTRY (__memcpy_chk)
cmpq %rdx, %rcx
-#if defined __UCLIBC_HAS_SSP__
jb HIDDEN_JUMPTARGET (__chk_fail)
-#endif
END (__memcpy_chk)
#endif
ENTRY (BP_SYM (memcpy))
diff --git a/libc/string/x86_64/memset.S b/libc/string/x86_64/memset.S
index df265f394..6b758ce3a 100644
--- a/libc/string/x86_64/memset.S
+++ b/libc/string/x86_64/memset.S
@@ -29,12 +29,10 @@
#define LARGE $120000
.text
-#if defined __PIC__ && !defined NOT_IN_libc
+#if defined __PIC__ && !defined NOT_IN_libc && defined __UCLIBC_HAS_FORTIFY__
ENTRY (__memset_chk)
cmpq %rdx, %rcx
-#if defined __UCLIBC_HAS_SSP__
jb HIDDEN_JUMPTARGET (__chk_fail)
-#endif
END (__memset_chk)
#endif
ENTRY (memset)
@@ -144,6 +142,6 @@ END (memset)
libc_hidden_def(memset)
#endif
-#if !BZERO_P && defined __PIC__ && !defined NOT_IN_libc
+#if !BZERO_P && defined __PIC__ && !defined NOT_IN_libc && defined __UCLIBC_HAS_FORTIFY__
strong_alias (__memset_chk, __memset_zero_constant_len_parameter)
#endif
diff --git a/libc/sysdeps/linux/alpha/bits/kernel_stat.h b/libc/sysdeps/linux/alpha/bits/kernel_stat.h
index 8279a3915..e919b210d 100644
--- a/libc/sysdeps/linux/alpha/bits/kernel_stat.h
+++ b/libc/sysdeps/linux/alpha/bits/kernel_stat.h
@@ -1,10 +1,6 @@
#ifndef _BITS_STAT_STRUCT_H
#define _BITS_STAT_STRUCT_H
-#ifndef _LIBC
-#error bits/kernel_stat.h is for internal uClibc use only!
-#endif
-
/* This file provides whatever this particular arch's kernel thinks
* struct kernel_stat should look like... It turns out each arch has a
* different opinion on the subject... */
diff --git a/libc/sysdeps/linux/alpha/bits/sigstack.h b/libc/sysdeps/linux/alpha/bits/sigstack.h
index 7faaf98d5..e9fbc6d6f 100644
--- a/libc/sysdeps/linux/alpha/bits/sigstack.h
+++ b/libc/sysdeps/linux/alpha/bits/sigstack.h
@@ -22,12 +22,14 @@
#endif
+#if defined __UCLIBC_SUSV4_LEGACY__ || !defined __UCLIBC_STRICT_HEADERS__
/* Structure describing a signal stack (obsolete). */
struct sigstack
{
__ptr_t ss_sp; /* Signal stack pointer. */
int ss_onstack; /* Nonzero if executing on this stack. */
};
+#endif
/* Possible values for `ss_flags.'. */
diff --git a/libc/sysdeps/linux/alpha/bits/statvfs.h b/libc/sysdeps/linux/alpha/bits/statvfs.h
deleted file mode 100644
index d37d0ffcb..000000000
--- a/libc/sysdeps/linux/alpha/bits/statvfs.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/* Copyright (C) 1997, 1998, 2000, 2001 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
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#ifndef _SYS_STATVFS_H
-# error "Never include <bits/statvfs.h> directly; use <sys/statvfs.h> instead."
-#endif
-
-#include <bits/types.h> /* For __fsblkcnt_t and __fsfilcnt_t. */
-
-struct statvfs
- {
- unsigned long int f_bsize;
- unsigned long int f_frsize;
-#ifndef __USE_FILE_OFFSET64
- __fsblkcnt_t f_blocks;
- __fsblkcnt_t f_bfree;
- __fsblkcnt_t f_bavail;
- __fsfilcnt_t f_files;
- __fsfilcnt_t f_ffree;
- __fsfilcnt_t f_favail;
-#else
- __fsblkcnt64_t f_blocks;
- __fsblkcnt64_t f_bfree;
- __fsblkcnt64_t f_bavail;
- __fsfilcnt64_t f_files;
- __fsfilcnt64_t f_ffree;
- __fsfilcnt64_t f_favail;
-#endif
- unsigned long int f_fsid;
- unsigned long int f_flag;
- unsigned long int f_namemax;
- int __f_spare[6];
- };
-
-#ifdef __USE_LARGEFILE64
-struct statvfs64
- {
- unsigned long int f_bsize;
- unsigned long int f_frsize;
- __fsblkcnt64_t f_blocks;
- __fsblkcnt64_t f_bfree;
- __fsblkcnt64_t f_bavail;
- __fsfilcnt64_t f_files;
- __fsfilcnt64_t f_ffree;
- __fsfilcnt64_t f_favail;
- unsigned long int f_fsid;
- unsigned long int f_flag;
- unsigned long int f_namemax;
- int __f_spare[6];
- };
-#endif
-
-/* Definitions for the flag in `f_flag'. These definitions should be
- kept in sync which the definitions in <sys/mount.h>. */
-enum
-{
- ST_RDONLY = 1, /* Mount read-only. */
-#define ST_RDONLY ST_RDONLY
- ST_NOSUID = 2, /* Ignore suid and sgid bits. */
-#define ST_NOSUID ST_NOSUID
-#ifdef __USE_GNU
- ST_NODEV = 4, /* Disallow access to device special files. */
-# define ST_NODEV ST_NODEV
- ST_NOEXEC = 8, /* Disallow program execution. */
-# define ST_NOEXEC ST_NOEXEC
- ST_SYNCHRONOUS = 16, /* Writes are synced at once. */
-# define ST_SYNCHRONOUS ST_SYNCHRONOUS
- ST_MANDLOCK = 64, /* Allow mandatory locks on an FS. */
-# define ST_MANDLOCK ST_MANDLOCK
- ST_WRITE = 128, /* Write on file/directory/symlink. */
-# define ST_WRITE ST_WRITE
- ST_APPEND = 256, /* Append-only file. */
-# define ST_APPEND ST_APPEND
- ST_IMMUTABLE = 512, /* Immutable file. */
-# define ST_IMMUTABLE ST_IMMUTABLE
- ST_NOATIME = 1024, /* Do not update access times. */
-# define ST_NOATIME ST_NOATIME
- ST_NODIRATIME /* Do not update directory access times. */
-# define ST_NODIRATIME ST_NODIRATIME
-#endif /* Use GNU. */
-};
diff --git a/libc/sysdeps/linux/arm/aeabi_mb_cur_max.c b/libc/sysdeps/linux/arm/aeabi_mb_cur_max.c
index f12309eaf..77e979a65 100644
--- a/libc/sysdeps/linux/arm/aeabi_mb_cur_max.c
+++ b/libc/sysdeps/linux/arm/aeabi_mb_cur_max.c
@@ -23,9 +23,5 @@
int
__aeabi_MB_CUR_MAX (void)
{
-#ifdef __UCLIBC_HAS_WCHAR__
return MB_CUR_MAX;
-#else
- return 1;
-#endif
}
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/bits/atomic.h b/libc/sysdeps/linux/arm/bits/atomic.h
index 8f63e2510..0b90330dd 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/bits/atomic.h
+++ b/libc/sysdeps/linux/arm/bits/atomic.h
@@ -16,6 +16,9 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
+#if defined __thumb__ && !defined __thumb2__
+#include_next <common/bits/atomic.h>
+#else
#include <stdint.h>
#include <sysdep.h>
@@ -37,7 +40,12 @@ typedef uintmax_t uatomic_max_t;
void __arm_link_error (void);
-#ifdef __thumb2__
+/* Use the atomic builtins provided by GCC in case the backend provides
+ a pattern to do this efficiently. */
+
+#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
+#define atomic_full_barrier() __sync_synchronize ()
+#elif defined __thumb2__
#define atomic_full_barrier() \
__asm__ __volatile__ \
("movw\tip, #0x0fa0\n\t" \
@@ -64,17 +72,21 @@ void __arm_link_error (void);
#define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \
({ __arm_link_error (); oldval; })
+#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
+#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
+ __sync_val_compare_and_swap ((mem), (oldval), (newval))
+
/* It doesn't matter what register is used for a_oldval2, but we must
specify one to work around GCC PR rtl-optimization/21223. Otherwise
it may cause a_oldval or a_tmp to be moved to a different register. */
-#ifdef __thumb2__
+#elif defined __thumb2__
/* Thumb-2 has ldrex/strex. However it does not have barrier instructions,
so we still need to use the kernel helper. */
#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
- ({ register __typeof (oldval) a_oldval __asm__ ("r0"); \
- register __typeof (oldval) a_newval __asm__ ("r1") = (newval); \
- register __typeof (mem) a_ptr __asm__ ("r2") = (mem); \
+ ({ register __typeof (oldval) a_oldval __asm__ ("r0"); \
+ register __typeof (oldval) a_newval __asm__ ("r1") = (newval); \
+ register __typeof (mem) a_ptr __asm__ ("r2") = (mem); \
register __typeof (oldval) a_tmp __asm__ ("r3"); \
register __typeof (oldval) a_oldval2 __asm__ ("r4") = (oldval); \
__asm__ __volatile__ \
@@ -95,9 +107,9 @@ void __arm_link_error (void);
a_tmp; })
#else
#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
- ({ register __typeof (oldval) a_oldval __asm__ ("r0"); \
- register __typeof (oldval) a_newval __asm__ ("r1") = (newval); \
- register __typeof (mem) a_ptr __asm__ ("r2") = (mem); \
+ ({ register __typeof (oldval) a_oldval __asm__ ("r0"); \
+ register __typeof (oldval) a_newval __asm__ ("r1") = (newval); \
+ register __typeof (mem) a_ptr __asm__ ("r2") = (mem); \
register __typeof (oldval) a_tmp __asm__ ("r3"); \
register __typeof (oldval) a_oldval2 __asm__ ("r4") = (oldval); \
__asm__ __volatile__ \
@@ -120,3 +132,5 @@ void __arm_link_error (void);
#define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
({ __arm_link_error (); oldval; })
+
+#endif
diff --git a/libc/sysdeps/linux/arm/bits/kernel_stat.h b/libc/sysdeps/linux/arm/bits/kernel_stat.h
index 2ca63a223..7bd89f9ab 100644
--- a/libc/sysdeps/linux/arm/bits/kernel_stat.h
+++ b/libc/sysdeps/linux/arm/bits/kernel_stat.h
@@ -1,10 +1,6 @@
#ifndef _BITS_STAT_STRUCT_H
#define _BITS_STAT_STRUCT_H
-#ifndef _LIBC
-#error bits/kernel_stat.h is for internal uClibc use only!
-#endif
-
/* This file provides whatever this particular arch's kernel thinks
* struct kernel_stat should look like... It turns out each arch has a
* different opinion on the subject... */
diff --git a/libc/sysdeps/linux/arm/posix_fadvise.c b/libc/sysdeps/linux/arm/posix_fadvise.c
index 278bff981..80d3c5044 100644
--- a/libc/sysdeps/linux/arm/posix_fadvise.c
+++ b/libc/sysdeps/linux/arm/posix_fadvise.c
@@ -39,7 +39,7 @@ int posix_fadvise(int fd, off_t offset, off_t len, int advise)
/* weak_alias(__libc_posix_fadvise, posix_fadvise); */
-#else
+#elif defined __UCLIBC_HAS_STUBS__
int posix_fadvise(int fd attribute_unused, off_t offset attribute_unused, off_t len attribute_unused, int advice attribute_unused)
{
diff --git a/libc/sysdeps/linux/arm/posix_fadvise64.c b/libc/sysdeps/linux/arm/posix_fadvise64.c
index 4b27381d1..678c42f90 100644
--- a/libc/sysdeps/linux/arm/posix_fadvise64.c
+++ b/libc/sysdeps/linux/arm/posix_fadvise64.c
@@ -47,7 +47,7 @@ int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advise)
/* weak_alias(__libc_posix_fadvise64, posix_fadvise64); */
-#else
+#elif defined __UCLIBC_HAS_STUBS__
int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advise)
{
diff --git a/libc/sysdeps/linux/avr32/bits/kernel_stat.h b/libc/sysdeps/linux/avr32/bits/kernel_stat.h
index 8442c3c1c..d98c6cfef 100644
--- a/libc/sysdeps/linux/avr32/bits/kernel_stat.h
+++ b/libc/sysdeps/linux/avr32/bits/kernel_stat.h
@@ -1,10 +1,6 @@
#ifndef _BITS_STAT_STRUCT_H
#define _BITS_STAT_STRUCT_H
-#ifndef _LIBC
-#error bits/kernel_stat.h is for internal uClibc use only!
-#endif
-
/*
* This file provides struct stat, taken from kernel 2.6.4. Verified
* to match kernel 2.6.22.
diff --git a/libc/sysdeps/linux/bfin/Makefile.arch b/libc/sysdeps/linux/bfin/Makefile.arch
index 242703757..425a68898 100644
--- a/libc/sysdeps/linux/bfin/Makefile.arch
+++ b/libc/sysdeps/linux/bfin/Makefile.arch
@@ -6,7 +6,7 @@
#
CSRC := bsdsetjmp.c clone.c \
- sram-alloc.c sram-free.c dma-memcpy.c
+ sram-alloc.c sram-free.c dma-memcpy.c cacheflush.c
SSRC := __longjmp.S setjmp.S bsd-_setjmp.S
diff --git a/libc/sysdeps/linux/bfin/__longjmp.S b/libc/sysdeps/linux/bfin/__longjmp.S
index 673cd30e8..b2fafbb25 100644
--- a/libc/sysdeps/linux/bfin/__longjmp.S
+++ b/libc/sysdeps/linux/bfin/__longjmp.S
@@ -105,3 +105,5 @@ ___longjmp:
.size ___longjmp,.-___longjmp
libc_hidden_def(__longjmp)
+
+.section .note.GNU-stack,"",%progbits
diff --git a/libc/sysdeps/linux/bfin/bits/kernel_stat.h b/libc/sysdeps/linux/bfin/bits/kernel_stat.h
index b1a3251e5..7700d6109 100644
--- a/libc/sysdeps/linux/bfin/bits/kernel_stat.h
+++ b/libc/sysdeps/linux/bfin/bits/kernel_stat.h
@@ -1,10 +1,6 @@
#ifndef _BITS_STAT_STRUCT_H
#define _BITS_STAT_STRUCT_H
-#ifndef _LIBC
-#error bits/kernel_stat.h is for internal uClibc use only!
-#endif
-
/* This file provides whatever this particular arch's kernel thinks
* struct kernel_stat should look like... It turns out each arch has a
* different opinion on the subject... */
diff --git a/libc/sysdeps/linux/bfin/bits/setjmp.h b/libc/sysdeps/linux/bfin/bits/setjmp.h
index ee3f5e787..adb9c23af 100644
--- a/libc/sysdeps/linux/bfin/bits/setjmp.h
+++ b/libc/sysdeps/linux/bfin/bits/setjmp.h
@@ -52,6 +52,6 @@ typedef struct
/* Test if longjmp to JMPBUF would unwind the frame
containing a local variable at ADDRESS. */
#define _JMPBUF_UNWINDS(jmpbuf, address) \
- ((void *) (address) < (void *) (jmpbuf)->__pregs[6])
+ ((void *) (address) < (void *) (jmpbuf)->fp)
#endif /* bits/setjmp.h */
diff --git a/libc/sysdeps/linux/bfin/cacheflush.c b/libc/sysdeps/linux/bfin/cacheflush.c
new file mode 100644
index 000000000..a8d81c419
--- /dev/null
+++ b/libc/sysdeps/linux/bfin/cacheflush.c
@@ -0,0 +1,14 @@
+/*
+ * cacheflush.c - Cache control functions for Blackfin.
+ *
+ * Copyright (C) 2010 Analog Devices Inc.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <unistd.h>
+#include <errno.h>
+#include <sys/syscall.h>
+#include <sys/cachectl.h>
+
+_syscall3 (int, cacheflush, void *, start, const int, nbytes, const int, flags)
diff --git a/libc/sysdeps/linux/bfin/dma-memcpy.c b/libc/sysdeps/linux/bfin/dma-memcpy.c
index 274b99e8c..b715aeba0 100644
--- a/libc/sysdeps/linux/bfin/dma-memcpy.c
+++ b/libc/sysdeps/linux/bfin/dma-memcpy.c
@@ -1,6 +1,6 @@
#include <unistd.h>
#include <errno.h>
#include <sys/syscall.h>
+#include <bfin_sram.h>
-_syscall3 (__ptr_t, dma_memcpy, __ptr_t, dest, __ptr_t, src, size_t, len)
-
+_syscall3 (void *, dma_memcpy, void *, dest, const void *, src, size_t, len)
diff --git a/libc/sysdeps/linux/bfin/sram-alloc.c b/libc/sysdeps/linux/bfin/sram-alloc.c
index 6b33b2670..8518119d7 100644
--- a/libc/sysdeps/linux/bfin/sram-alloc.c
+++ b/libc/sysdeps/linux/bfin/sram-alloc.c
@@ -1,6 +1,6 @@
#include <unistd.h>
#include <errno.h>
#include <sys/syscall.h>
+#include <bfin_sram.h>
_syscall2 (__ptr_t, sram_alloc, size_t, len, unsigned long, flags)
-
diff --git a/libc/sysdeps/linux/bfin/sram-free.c b/libc/sysdeps/linux/bfin/sram-free.c
index 0fba936c8..8260eb660 100644
--- a/libc/sysdeps/linux/bfin/sram-free.c
+++ b/libc/sysdeps/linux/bfin/sram-free.c
@@ -1,6 +1,6 @@
#include <unistd.h>
#include <errno.h>
#include <sys/syscall.h>
+#include <bfin_sram.h>
-_syscall1 (__ptr_t, sram_free, __ptr_t, addr)
-
+_syscall1 (int, sram_free, const void *, addr)
diff --git a/libc/sysdeps/linux/bfin/sys/cachectl.h b/libc/sysdeps/linux/bfin/sys/cachectl.h
new file mode 100644
index 000000000..ee4c03155
--- /dev/null
+++ b/libc/sysdeps/linux/bfin/sys/cachectl.h
@@ -0,0 +1,25 @@
+/*
+ * cachectl.h - Functions for cache control on Blackfin.
+ *
+ * Copyright (C) 2010 Analog Devices, Inc.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#ifndef _SYS_CACHECTL_H
+#define _SYS_CACHECTL_H 1
+
+#include <features.h>
+
+/*
+ * Get the kernel definition for the flag bits
+ */
+#include <asm/cachectl.h>
+
+__BEGIN_DECLS
+
+extern int cacheflush (void *addr, __const int nbytes, __const int flags);
+
+__END_DECLS
+
+#endif /* sys/cachectl.h */
diff --git a/libc/sysdeps/linux/c6x/Makefile b/libc/sysdeps/linux/c6x/Makefile
new file mode 100644
index 000000000..633c91f3e
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/Makefile
@@ -0,0 +1,13 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+top_srcdir=../../../../
+top_builddir=../../../../
+all: objs
+include $(top_builddir)Rules.mak
+include Makefile.arch
+include $(top_srcdir)Makerules
diff --git a/libc/sysdeps/linux/c6x/Makefile.arch b/libc/sysdeps/linux/c6x/Makefile.arch
new file mode 100644
index 000000000..3e8dace07
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/Makefile.arch
@@ -0,0 +1,15 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+CSRC := brk.c pread_write.c syscall.c prctl.c
+#CSRC :=
+
+SSRC := __longjmp.S bsd-_setjmp.S bsd-setjmp.S clone.S setjmp.S _vfork.S
+#SSRC :=
+
+# libc-nonshared-y += $(ARCH_OUT)/_syscall.os
+
diff --git a/libc/sysdeps/linux/c6x/__longjmp.S b/libc/sysdeps/linux/c6x/__longjmp.S
new file mode 100644
index 000000000..b9d9f9d9c
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/__longjmp.S
@@ -0,0 +1,47 @@
+ ;
+ ; Port of uClibc for TMS320C6000 DSP architecture
+ ; Copyright (C) 2004 Texas Instruments Incorporated
+ ; Author of TMS320C6000 port: Aurelien Jacquiot
+ ;
+ ; This program is free software; you can redistribute it and/or modify it
+ ; under the terms of the GNU Library General Public License as published by
+ ; the Free Software Foundation; either version 2 of the License, or (at your
+ ; option) any later version.
+ ;
+ ; This program is distributed in the hope that it will be useful, but WITHOUT
+ ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
+ ; for more details.
+ ;
+ ; You should have received a copy of the GNU Library General Public License
+ ; along with this program; if not, write to the Free Software Foundation,
+ ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ ;
+
+ .global __longjmp
+
+__longjmp:
+ LDW .D1T1 *+A4(48),A3 ; return address
+ MV .D2X A4,B6 ; jmp_buf pointer
+|| MV .D1 A4,A6
+|| MV .S2 B4,B2 ; val
+
+ LDW .D1T1 *+A6(0),A10
+|| LDW .D2T2 *+B6(4),B10
+|| [B2] MV .S1X B4,A4
+||[!B2] MVK .L1 1,A4 ; return val or 1
+
+ LDW .D1T1 *+A6(8),A11
+|| LDW .D2T2 *+B6(12),B11
+ LDW .D1T1 *+A6(16),A12
+|| LDW .D2T2 *+B6(20),B12
+ LDW .D1T1 *+A6(24),A13
+|| LDW .D2T2 *+B6(28),B13
+ LDW .D1T1 *+A6(32),A14
+|| LDW .D2T2 *+B6(36),B14
+ LDW .D1T1 *+A6(40),A15
+|| LDW .D2T2 *+B6(44),B15
+|| B .S2X A3
+ NOP 5
+
+libc_hidden_def(__longjmp)
diff --git a/libc/sysdeps/linux/c6x/_vfork.S b/libc/sysdeps/linux/c6x/_vfork.S
new file mode 100644
index 000000000..d64dc504d
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/_vfork.S
@@ -0,0 +1,66 @@
+/*
+ * Port of uClibc for TMS320C6000 DSP architecture
+ * Copyright (C) 2004, 2011 Texas Instruments Incorporated
+ * Author of TMS320C6000 port: Aurelien Jacquiot
+ *
+ * Use clone syscall: Mark Salter <msalter@redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Library General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#define __ASSEMBLY__
+
+#include <asm/errno.h>
+#include <sys/syscall.h>
+#include <linux/sched.h>
+#include <asm/signal.h>
+
+#define CLONE_FLAGS (CLONE_VFORK | CLONE_VM | SIGCHLD)
+
+ .global __vfork
+__vfork:
+ MVK .S2 SYS_clone,B0
+ || MVKL .S1 CLONE_FLAGS,A4
+ MVKH .S1 CLONE_FLAGS,A4
+ || MVK .L2 0,B4
+#ifndef _TMS320C6400_PLUS
+ MVC .S2 CSR,B2
+ CLR .S2 B2,0,0,B1
+ MVC .S2 B1,CSR
+ MVC .S2 IFR,B1
+ SET .S2 B1,6,6,B1
+ MVC .S2 B1,ISR
+ MVC .S2 B2,CSR
+ NOP
+#else
+ SWE
+#endif
+
+ MVK .S2 -4096,B4
+ CMPGTU .L2X B4,A4,B2 ; check error
+ [B2] BNOP .S2 B3,5
+
+ NEG .S1 A4,A4
+ STW .D2T1 A4,*B15--[2]
+ STW .D2T2 B3,*+B15[1]
+ CALLP .S2 __errno_location,B3
+ LDW .D2T2 *+B15[1],B3
+ LDW .D2T1 *++B15[2],A5
+ NOP 3
+ BNOP .S2 B3,3
+ STW .D1T1 A5,*A4
+ MVK .L1 -1,A4
+
+weak_alias(__vfork,vfork)
+libc_hidden_weak(vfork)
diff --git a/libc/sysdeps/linux/c6x/bits/byteswap.h b/libc/sysdeps/linux/c6x/bits/byteswap.h
new file mode 100644
index 000000000..eff26d54e
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/bits/byteswap.h
@@ -0,0 +1,35 @@
+/*
+ * Port of uClibc for TMS320C6000 DSP architecture
+ * Copyright (C) 2004 Texas Instruments Incorporated
+ * Author of TMS320C6000 port: Aurelien Jacquiot
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Library General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef _ASM_BITS_BYTESWAP_H
+#define _ASM_BITS_BYTESWAP_H 1
+
+#if !defined _BYTESWAP_H && !defined _NETINET_IN_H
+# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
+#endif
+
+#ifdef __GNUC__
+#define __bswap_non_constant_32(x) __builtin_bswap32(x)
+#endif
+
+#include <bits/byteswap-common.h>
+
+#endif
diff --git a/libc/sysdeps/linux/c6x/bits/elf-dsbt.h b/libc/sysdeps/linux/c6x/bits/elf-dsbt.h
new file mode 100644
index 000000000..ff8b24bd7
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/bits/elf-dsbt.h
@@ -0,0 +1,123 @@
+/* Copyright (C) 2010 Texas Instruments Incorporated
+
+Borrowed heavily from frv arch:
+Copyright 2003, 2004 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
+modify it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of the
+License, or (at your option) any later version.
+
+In addition to the permissions in the GNU Lesser General Public
+License, the Free Software Foundation gives you unlimited
+permission to link the compiled version of this file with other
+programs, and to distribute those programs without any restriction
+coming from the use of this file. (The GNU Lesser General Public
+License restrictions do apply in other respects; for example, they
+cover modification of the file, and distribution when not linked
+into another program.)
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with the GNU C Library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA. */
+
+#ifndef _BITS_ELF_DSBT_H
+#define _BITS_ELF_DSBT_H
+
+/* These data structures are described in the DSBT ABI.
+ The kernel passes a process a memory map of logical
+ load segments. For PIC code to work, all code segments
+ must be combined into a single mapping while maintaining
+ their relationship to one another. The same is true for
+ RW data segments.
+
+ Furthermore,
+ segment there is an elf32_dsbt_loadseg entry. A pointer to an
+ elf32_dsbt_loadmap is passed in GR8 at start-up, and a pointer to
+ an additional such map is passed in GR9 for the interpreter, when
+ there is one. */
+
+#include <elf.h>
+
+/* This data structure represents a PT_LOAD segment. */
+struct elf32_dsbt_loadseg
+{
+ /* Core address to which the segment is mapped. */
+ Elf32_Addr addr;
+ /* VMA recorded in the program header. */
+ Elf32_Addr p_vaddr;
+ /* Size of this segment in memory. */
+ Elf32_Word p_memsz;
+};
+
+struct elf32_dsbt_loadmap {
+ /* Protocol version number, must be zero. */
+ Elf32_Word version;
+
+ /* Pointer to DSBT */
+ unsigned *dsbt_table;
+ unsigned dsbt_size;
+ unsigned dsbt_index;
+
+ /* number of segments */
+ Elf32_Word nsegs;
+
+ /* The actual memory map. */
+ struct elf32_dsbt_loadseg segs[0];
+};
+
+struct elf32_dsbt_loadaddr {
+ struct elf32_dsbt_loadmap *map;
+};
+
+
+/* Map a pointer's VMA to its corresponding address according to the
+ load map. */
+static __always_inline void *
+__reloc_pointer (void *p,
+ const struct elf32_dsbt_loadmap *map)
+{
+ int c;
+
+#if 0
+ if (map->version != 0)
+ /* Crash. */
+ ((void(*)())0)();
+#endif
+
+ /* No special provision is made for NULL. We don't want NULL
+ addresses to go through relocation, so they shouldn't be in
+ .rofixup sections, and, if they're present in dynamic
+ relocations, they shall be mapped to the NULL address without
+ undergoing relocations. */
+
+ for (c = 0; c < map->nsegs; c++)
+ {
+ unsigned long offset = p - (void*)map->segs[c].p_vaddr;
+ /* We only check for one-past-the-end for the second segment,
+ assumed to be the data segment, because other cases are
+ ambiguous in the absence of padding between segments, and
+ rofixup already serves as padding between text and data.
+ Unfortunately, unless we special-case the second segment,
+ we fail to relocate the _end symbol. */
+ if (offset < map->segs[c].p_memsz
+ || (offset == map->segs[c].p_memsz && c == 1))
+ return (char*)map->segs[c].addr + offset;
+ }
+
+ /* We might want to crash instead. */
+ return (void*)-1;
+}
+
+# define __RELOC_POINTER(ptr, loadaddr) \
+ (__reloc_pointer ((void*)(ptr), \
+ (loadaddr).map))
+
+#endif /* _BITS_ELF_DSBT_H */
diff --git a/libc/sysdeps/linux/c6x/bits/endian.h b/libc/sysdeps/linux/c6x/bits/endian.h
new file mode 100644
index 000000000..7297f9e2e
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/bits/endian.h
@@ -0,0 +1,11 @@
+/* c6x is little-endian by default. */
+
+#ifndef _ENDIAN_H
+# error "Never use <bits/endian.h> directly; include <endian.h> instead."
+#endif
+
+#ifdef _BIG_ENDIAN
+#define __BYTE_ORDER __BIG_ENDIAN
+#else
+#define __BYTE_ORDER __LITTLE_ENDIAN
+#endif
diff --git a/libc/sysdeps/linux/c6x/bits/fcntl.h b/libc/sysdeps/linux/c6x/bits/fcntl.h
new file mode 100644
index 000000000..6c0d5647f
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/bits/fcntl.h
@@ -0,0 +1,235 @@
+/* O_*, F_*, FD_* bit values for Linux.
+ Copyright (C) 2000 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _FCNTL_H
+# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
+#endif
+
+
+#include <sys/types.h>
+#ifdef __USE_GNU
+# include <bits/uio.h>
+#endif
+
+/* open/fcntl - O_SYNC is only implemented on blocks devices and on files
+ located on an ext2 file system */
+#define O_ACCMODE 0003
+#define O_RDONLY 00
+#define O_WRONLY 01
+#define O_RDWR 02
+#define O_CREAT 0100 /* not fcntl */
+#define O_EXCL 0200 /* not fcntl */
+#define O_NOCTTY 0400 /* not fcntl */
+#define O_TRUNC 01000 /* not fcntl */
+#define O_APPEND 02000
+#define O_NONBLOCK 04000
+#define O_NDELAY O_NONBLOCK
+#define O_SYNC 010000
+#define O_FSYNC O_SYNC
+#define O_ASYNC 020000
+#define O_DIRECT 040000
+
+#ifdef __USE_GNU
+# define O_LARGEFILE 0100000
+# define O_DIRECTORY 0200000 /* Must be a directory. */
+# define O_NOFOLLOW 0400000 /* don't follow links */
+# define O_NOATIME 01000000
+# define O_CLOEXEC 02000000/* set close on exec */
+#endif
+
+/* For now Linux has synchronisity options for data and read operations.
+ We define the symbols here but let them do the same as O_SYNC since
+ this is a superset. */
+#if defined __USE_POSIX199309 || defined __USE_UNIX98
+# define O_DSYNC O_SYNC /* Synchronize data. */
+# define O_RSYNC O_SYNC /* Synchronize read operations. */
+#endif
+
+#ifdef __USE_LARGEFILE64
+# define O_LARGEFILE 0100000
+#endif
+
+/* Values for the second argument to `fcntl'. */
+#define F_DUPFD 0 /* Duplicate file descriptor. */
+#define F_GETFD 1 /* Get file descriptor flags. */
+#define F_SETFD 2 /* Set file descriptor flags. */
+#define F_GETFL 3 /* Get file status flags. */
+#define F_SETFL 4 /* Set file status flags. */
+#ifndef __USE_FILE_OFFSET64
+# define F_GETLK 5 /* Get record locking info. */
+# define F_SETLK 6 /* Set record locking info (non-blocking). */
+# define F_SETLKW 7 /* Set record locking info (blocking). */
+#else
+# define F_GETLK F_GETLK64 /* Get record locking info. */
+# define F_SETLK F_SETLK64 /* Set record locking info (non-blocking).*/
+# define F_SETLKW F_SETLKW64 /* Set record locking info (blocking). */
+#endif
+#define F_GETLK64 12 /* Get record locking info. */
+#define F_SETLK64 13 /* Set record locking info (non-blocking). */
+#define F_SETLKW64 14 /* Set record locking info (blocking). */
+
+#if defined __USE_BSD || defined __USE_XOPEN2K
+# define F_SETOWN 8 /* Get owner of socket (receiver of SIGIO). */
+# define F_GETOWN 9 /* Set owner of socket (receiver of SIGIO). */
+#endif
+
+#ifdef __USE_GNU
+# define F_SETSIG 10 /* Set number of signal to be sent. */
+# define F_GETSIG 11 /* Get number of signal to be sent. */
+#endif
+
+#ifdef __USE_GNU
+# define F_SETLEASE 1024 /* Set a lease. */
+# define F_GETLEASE 1025 /* Enquire what lease is active. */
+# define F_NOTIFY 1026 /* Request notfications on a directory. */
+#endif
+
+/* For F_[GET|SET]FL. */
+#define FD_CLOEXEC 1 /* actually anything with low bit set goes */
+
+/* For posix fcntl() and `l_type' field of a `struct flock' for lockf(). */
+#define F_RDLCK 0 /* Read lock. */
+#define F_WRLCK 1 /* Write lock. */
+#define F_UNLCK 2 /* Remove lock. */
+
+/* For old implementation of bsd flock(). */
+#define F_EXLCK 4 /* or 3 */
+#define F_SHLCK 8 /* or 4 */
+
+#ifdef __USE_BSD
+/* Operations for bsd flock(), also used by the kernel implementation. */
+# define LOCK_SH 1 /* shared lock */
+# define LOCK_EX 2 /* exclusive lock */
+# define LOCK_NB 4 /* or'd with one of the above to prevent
+ blocking */
+# define LOCK_UN 8 /* remove lock */
+#endif
+
+#ifdef __USE_GNU
+# define LOCK_MAND 32 /* This is a mandatory flock: */
+# define LOCK_READ 64 /* ... which allows concurrent read operations. */
+# define LOCK_WRITE 128 /* ... which allows concurrent write operations. */
+# define LOCK_RW 192 /* ... Which allows concurrent read & write operations. */
+#endif
+
+#ifdef __USE_GNU
+/* Types of directory notifications that may be requested with F_NOTIFY. */
+# define DN_ACCESS 0x00000001 /* File accessed. */
+# define DN_MODIFY 0x00000002 /* File modified. */
+# define DN_CREATE 0x00000004 /* File created. */
+# define DN_DELETE 0x00000008 /* File removed. */
+# define DN_RENAME 0x00000010 /* File renamed. */
+# define DN_ATTRIB 0x00000020 /* File changed attibutes. */
+# define DN_MULTISHOT 0x80000000 /* Don't remove notifier. */
+#endif
+
+struct flock
+ {
+ short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
+ short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
+#ifndef __USE_FILE_OFFSET64
+ __off_t l_start; /* Offset where the lock begins. */
+ __off_t l_len; /* Size of the locked area; zero means until EOF. */
+#else
+ __off64_t l_start; /* Offset where the lock begins. */
+ __off64_t l_len; /* Size of the locked area; zero means until EOF. */
+#endif
+ __pid_t l_pid; /* Process holding the lock. */
+ };
+
+#ifdef __USE_LARGEFILE64
+struct flock64
+ {
+ short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
+ short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
+ __off64_t l_start; /* Offset where the lock begins. */
+ __off64_t l_len; /* Size of the locked area; zero means until EOF. */
+ __pid_t l_pid; /* Process holding the lock. */
+ };
+#endif
+
+/* Define some more compatibility macros to be backward compatible with
+ BSD systems which did not managed to hide these kernel macros. */
+#ifdef __USE_BSD
+# define FAPPEND O_APPEND
+# define FFSYNC O_FSYNC
+# define FASYNC O_ASYNC
+# define FNONBLOCK O_NONBLOCK
+# define FNDELAY O_NDELAY
+#endif /* Use BSD. */
+
+/* Advise to `posix_fadvise'. */
+#ifdef __USE_XOPEN2K
+# define POSIX_FADV_NORMAL 0 /* No further special treatment. */
+# define POSIX_FADV_RANDOM 1 /* Expect random page references. */
+# define POSIX_FADV_SEQUENTIAL 2 /* Expect sequential page references. */
+# define POSIX_FADV_WILLNEED 3 /* Will need these pages. */
+# define POSIX_FADV_DONTNEED 4 /* Don't need these pages. */
+# define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */
+#endif
+
+#if defined __USE_GNU && defined __UCLIBC_LINUX_SPECIFIC__
+/* Flags for SYNC_FILE_RANGE. */
+# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
+ in the range before performing the
+ write. */
+# define SYNC_FILE_RANGE_WRITE 2 /* Initiate writeout of all those
+ dirty pages in the range which are
+ not presently under writeback. */
+# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
+ the range after performing the
+ write. */
+
+/* Flags for SPLICE and VMSPLICE. */
+# define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
+# define SPLICE_F_NONBLOCK 2 /* Don't block on the pipe splicing
+ (but we may still block on the fd
+ we splice from/to). */
+# define SPLICE_F_MORE 4 /* Expect more data. */
+# define SPLICE_F_GIFT 8 /* Pages passed in are a gift. */
+#endif
+
+__BEGIN_DECLS
+
+#if defined __USE_GNU && defined __UCLIBC_LINUX_SPECIFIC__
+
+/* Provide kernel hint to read ahead. */
+extern ssize_t readahead (int __fd, __off64_t __offset, size_t __count)
+ __THROW;
+
+
+/* Selective file content synch'ing. */
+extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to,
+ unsigned int __flags);
+
+/* Splice address range into a pipe. */
+extern ssize_t vmsplice (int __fdout, const struct iovec *__iov,
+ size_t __count, unsigned int __flags);
+
+/* Splice two files together. */
+extern ssize_t splice (int __fdin, __off64_t *__offin, int __fdout,
+ __off64_t *__offout, size_t __len,
+ unsigned int __flags);
+
+/* In-kernel implementation of tee for pipe buffers. */
+extern ssize_t tee (int __fdin, int __fdout, size_t __len,
+ unsigned int __flags);
+
+#endif
+__END_DECLS
diff --git a/libc/sysdeps/linux/c6x/bits/kernel_stat.h b/libc/sysdeps/linux/c6x/bits/kernel_stat.h
new file mode 100644
index 000000000..f8381c703
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/bits/kernel_stat.h
@@ -0,0 +1,49 @@
+#ifndef _BITS_STAT_STRUCT_H
+#define _BITS_STAT_STRUCT_H
+
+/* This file provides whatever this particular arch's kernel thinks
+ * struct kernel_stat should look like... It turns out each arch has a
+ * different opinion on the subject... */
+
+struct kernel_stat {
+ unsigned long st_dev; /* Device. */
+ unsigned long st_ino; /* File serial number. */
+ unsigned int st_mode; /* File mode. */
+ unsigned int st_nlink; /* Link count. */
+ unsigned int st_uid; /* User ID of the file's owner. */
+ unsigned int st_gid; /* Group ID of the file's group. */
+ unsigned long st_rdev; /* Device number, if device. */
+ unsigned long __pad1;
+ long st_size; /* Size of file, in bytes. */
+ int st_blksize; /* Optimal block size for I/O. */
+ int __pad2;
+ long st_blocks; /* Number 512-byte blocks allocated. */
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+ unsigned int __unused4;
+ unsigned int __unused5;
+};
+
+struct kernel_stat64 {
+ unsigned long long st_dev; /* Device. */
+ unsigned long long st_ino; /* File serial number. */
+ unsigned int st_mode; /* File mode. */
+ unsigned int st_nlink; /* Link count. */
+ unsigned int st_uid; /* User ID of the file's owner. */
+ unsigned int st_gid; /* Group ID of the file's group. */
+ unsigned long long st_rdev; /* Device number, if device. */
+ unsigned long long __pad1;
+ long long st_size; /* Size of file, in bytes. */
+ int st_blksize; /* Optimal block size for I/O. */
+ int __pad2;
+ long long st_blocks; /* Number 512-byte blocks allocated. */
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+ unsigned int __unused4;
+ unsigned int __unused5;
+};
+
+#endif /* _BITS_STAT_STRUCT_H */
+
diff --git a/libc/sysdeps/linux/c6x/bits/kernel_types.h b/libc/sysdeps/linux/c6x/bits/kernel_types.h
new file mode 100644
index 000000000..755730959
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/bits/kernel_types.h
@@ -0,0 +1,46 @@
+/* Note that we use the exact same include guard #define names
+ * as asm/posix_types.h. This will avoid gratuitous conflicts
+ * with the posix_types.h kernel header, and will ensure that
+ * our private content, and not the kernel header, will win.
+ * -Erik
+ */
+#ifndef __ASM_GENERIC_POSIX_TYPES_H
+#define __ASM_GENERIC_POSIX_TYPES_H
+
+typedef unsigned int __kernel_dev_t;
+typedef unsigned long __kernel_ino_t;
+typedef unsigned int __kernel_mode_t;
+typedef unsigned long __kernel_nlink_t;
+typedef int __kernel_pid_t;
+typedef int __kernel_ipc_pid_t;
+typedef unsigned int __kernel_uid_t;
+typedef unsigned int __kernel_gid_t;
+typedef long __kernel_suseconds_t;
+typedef int __kernel_daddr_t;
+typedef unsigned int __kernel_uid32_t;
+typedef unsigned int __kernel_gid32_t;
+typedef unsigned int __kernel_old_uid_t;
+typedef unsigned int __kernel_old_gid_t;
+typedef unsigned int __kernel_old_dev_t;
+typedef unsigned int __kernel_size_t;
+typedef int __kernel_ssize_t;
+typedef int __kernel_ptrdiff_t;
+typedef long __kernel_off_t;
+typedef long long __kernel_loff_t;
+typedef long __kernel_time_t;
+typedef long __kernel_clock_t;
+typedef int __kernel_timer_t;
+typedef int __kernel_clockid_t;
+typedef char * __kernel_caddr_t;
+typedef unsigned short __kernel_uid16_t;
+typedef unsigned short __kernel_gid16_t;
+
+typedef struct {
+#ifdef __USE_ALL
+ int val[2];
+#else
+ int __val[2];
+#endif
+} __kernel_fsid_t;
+
+#endif /* __ASM_GENERIC_POSIX_TYPES_H */
diff --git a/libc/sysdeps/linux/c6x/bits/mathdef.h b/libc/sysdeps/linux/c6x/bits/mathdef.h
new file mode 100644
index 000000000..df12adf03
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/bits/mathdef.h
@@ -0,0 +1,39 @@
+/* Copyright (C) 1997, 1998, 1999, 2000 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#if !defined _MATH_H && !defined _COMPLEX_H
+# error "Never use <bits/mathdef.h> directly; include <math.h> instead"
+#endif
+
+#if defined __USE_ISOC99 && defined _MATH_H && !defined _MATH_H_MATHDEF
+# define _MATH_H_MATHDEF 1
+
+typedef float float_t;
+typedef double double_t;
+
+/* The values returned by `ilogb' for 0 and NaN respectively. */
+# define FP_ILOGB0 (-2147483647 - 1)
+# define FP_ILOGBNAN (2147483647)
+
+#endif /* ISO C99 */
+
+#ifndef __NO_LONG_DOUBLE_MATH
+/* Signal that we do not really have a `long double'. This disables the
+ declaration of all the `long double' function variants. */
+# define __NO_LONG_DOUBLE_MATH 1
+#endif
diff --git a/libc/sysdeps/linux/c6x/bits/nan.h b/libc/sysdeps/linux/c6x/bits/nan.h
new file mode 100644
index 000000000..85225da9f
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/bits/nan.h
@@ -0,0 +1,57 @@
+/* `NAN' constant for IEEE 754 machines.
+ Copyright (C) 1992,1996,1997,1999,2004,2006 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _MATH_H
+# error "Never use <bits/nan.h> directly; include <math.h> instead."
+#endif
+
+/* IEEE Not A Number. */
+
+/*
+ * Copied from the common code and modified for TI tool wrapper.
+ * Copyright (C) 2010 Texas Instruments Incorporated
+ */
+
+#if __GNUC_PREREQ(3,3)
+
+# define NAN (__builtin_nanf (""))
+
+#elif defined __GNUC__ && ! defined __TI_TOOL_WRAPPER__
+
+# define NAN \
+ (__extension__ \
+ ((union { unsigned __l __attribute__ ((__mode__ (__SI__))); float __d; }) \
+ { __l: 0x7fc00000UL }).__d)
+
+#else
+
+# include <endian.h>
+
+# if __BYTE_ORDER == __BIG_ENDIAN
+# define __nan_bytes { 0x7f, 0xc0, 0, 0 }
+# endif
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+# define __nan_bytes { 0, 0, 0xc0, 0x7f }
+# endif
+
+static union { unsigned char __c[4]; float __d; } __nan_union
+ = { __nan_bytes };
+# define NAN (__nan_union.__d)
+
+#endif /* GCC. */
diff --git a/libc/sysdeps/linux/c6x/bits/poll.h b/libc/sysdeps/linux/c6x/bits/poll.h
new file mode 100644
index 000000000..f7a739315
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/bits/poll.h
@@ -0,0 +1,43 @@
+/* Copyright (C) 1997, 2001 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_POLL_H
+# error "Never use <bits/poll.h> directly; include <sys/poll.h> instead."
+#endif
+
+/* Event types that can be polled for. These bits may be set in `events'
+ to indicate the interesting event types; they will appear in `revents'
+ to indicate the status of the file descriptor. */
+#define POLLIN 0x001 /* There is data to read. */
+#define POLLPRI 0x002 /* There is urgent data to read. */
+#define POLLOUT 0x004 /* Writing now will not block. */
+
+#ifdef __USE_XOPEN
+/* These values are defined in XPG4.2. */
+# define POLLRDNORM 0x040 /* Normal data may be read. */
+# define POLLRDBAND 0x080 /* Priority data may be read. */
+# define POLLWRNORM POLLOUT /* Writing now will not block. */
+# define POLLWRBAND 0x100 /* Priority data may be written. */
+#endif
+
+/* Event types always implicitly polled for. These bits need not be set in
+ `events', but they will appear in `revents' to indicate the status of
+ the file descriptor. */
+#define POLLERR 0x008 /* Error condition. */
+#define POLLHUP 0x010 /* Hung up. */
+#define POLLNVAL 0x020 /* Invalid polling request. */
diff --git a/libc/sysdeps/linux/c6x/bits/resource.h b/libc/sysdeps/linux/c6x/bits/resource.h
new file mode 100644
index 000000000..57d17821e
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/bits/resource.h
@@ -0,0 +1,209 @@
+/* Bit values & structures for resource limits. Linux/m68k version.
+ Copyright (C) 1994,1996,1997,1998,1999,2000,2001 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_RESOURCE_H
+# error "Never use <bits/resource.h> directly; include <sys/resource.h> instead."
+#endif
+
+#include <bits/types.h>
+
+/* Transmute defines to enumerations. The macro re-definitions are
+ necessary because some programs want to test for operating system
+ features with #ifdef RUSAGE_SELF. In ISO C the reflexive
+ definition is a no-op. */
+
+/* Kinds of resource limit. */
+enum __rlimit_resource
+{
+ /* Per-process CPU limit, in seconds. */
+ RLIMIT_CPU = 0,
+#define RLIMIT_CPU RLIMIT_CPU
+
+ /* Largest file that can be created, in bytes. */
+ RLIMIT_FSIZE = 1,
+#define RLIMIT_FSIZE RLIMIT_FSIZE
+
+ /* Maximum size of data segment, in bytes. */
+ RLIMIT_DATA = 2,
+#define RLIMIT_DATA RLIMIT_DATA
+
+ /* Maximum size of stack segment, in bytes. */
+ RLIMIT_STACK = 3,
+#define RLIMIT_STACK RLIMIT_STACK
+
+ /* Largest core file that can be created, in bytes. */
+ RLIMIT_CORE = 4,
+#define RLIMIT_CORE RLIMIT_CORE
+
+ /* Largest resident set size, in bytes.
+ This affects swapping; processes that are exceeding their
+ resident set size will be more likely to have physical memory
+ taken from them. */
+ RLIMIT_RSS = 5,
+#define RLIMIT_RSS RLIMIT_RSS
+
+ /* Number of open files. */
+ RLIMIT_NOFILE = 7,
+ RLIMIT_OFILE = RLIMIT_NOFILE, /* BSD name for same. */
+#define RLIMIT_NOFILE RLIMIT_NOFILE
+#define RLIMIT_OFILE RLIMIT_OFILE
+
+ /* Address space limit. */
+ RLIMIT_AS = 9,
+#define RLIMIT_AS RLIMIT_AS
+
+ /* Number of processes. */
+ RLIMIT_NPROC = 6,
+#define RLIMIT_NPROC RLIMIT_NPROC
+
+ /* Locked-in-memory address space. */
+ RLIMIT_MEMLOCK = 8,
+#define RLIMIT_MEMLOCK RLIMIT_MEMLOCK
+
+ /* Maximum number of file locks. */
+ RLIMIT_LOCKS = 10,
+#define RLIMIT_LOCKS RLIMIT_LOCKS
+
+ RLIMIT_NLIMITS = 11,
+ RLIM_NLIMITS = RLIMIT_NLIMITS
+#define RLIMIT_NLIMITS RLIMIT_NLIMITS
+#define RLIM_NLIMITS RLIM_NLIMITS
+};
+
+/* Value to indicate that there is no limit. */
+#ifndef __USE_FILE_OFFSET64
+# define RLIM_INFINITY ((unsigned long)(~0UL))
+#else
+# define RLIM_INFINITY 0xffffffffffffffffuLL
+#endif
+
+#ifdef __USE_LARGEFILE64
+# define RLIM64_INFINITY 0xffffffffffffffffuLL
+#endif
+
+/* We can represent all limits. */
+#define RLIM_SAVED_MAX RLIM_INFINITY
+#define RLIM_SAVED_CUR RLIM_INFINITY
+
+
+/* Type for resource quantity measurement. */
+#ifndef __USE_FILE_OFFSET64
+typedef __rlim_t rlim_t;
+#else
+typedef __rlim64_t rlim_t;
+#endif
+#ifdef __USE_LARGEFILE64
+typedef __rlim64_t rlim64_t;
+#endif
+
+struct rlimit
+ {
+ /* The current (soft) limit. */
+ rlim_t rlim_cur;
+ /* The hard limit. */
+ rlim_t rlim_max;
+ };
+
+#ifdef __USE_LARGEFILE64
+struct rlimit64
+ {
+ /* The current (soft) limit. */
+ rlim64_t rlim_cur;
+ /* The hard limit. */
+ rlim64_t rlim_max;
+ };
+#endif
+
+/* Whose usage statistics do you want? */
+enum __rusage_who
+{
+ /* The calling process. */
+ RUSAGE_SELF = 0,
+#define RUSAGE_SELF RUSAGE_SELF
+
+ /* All of its terminated child processes. */
+ RUSAGE_CHILDREN = -1,
+#define RUSAGE_CHILDREN RUSAGE_CHILDREN
+
+ /* Both. */
+ RUSAGE_BOTH = -2
+#define RUSAGE_BOTH RUSAGE_BOTH
+};
+
+#define __need_timeval
+#include <bits/time.h> /* For `struct timeval'. */
+
+/* Structure which says how much of each resource has been used. */
+struct rusage
+ {
+ /* Total amount of user time used. */
+ struct timeval ru_utime;
+ /* Total amount of system time used. */
+ struct timeval ru_stime;
+ /* Maximum resident set size (in kilobytes). */
+ long ru_maxrss;
+ /* Amount of sharing of text segment memory
+ with other processes (kilobyte-seconds). */
+ long ru_ixrss;
+ /* Amount of data segment memory used (kilobyte-seconds). */
+ long ru_idrss;
+ /* Amount of stack memory used (kilobyte-seconds). */
+ long ru_isrss;
+ /* Number of soft page faults (i.e. those serviced by reclaiming
+ a page from the list of pages awaiting reallocation. */
+ long ru_minflt;
+ /* Number of hard page faults (i.e. those that required I/O). */
+ long ru_majflt;
+ /* Number of times a process was swapped out of physical memory. */
+ long ru_nswap;
+ /* Number of input operations via the file system. Note: This
+ and `ru_oublock' do not include operations with the cache. */
+ long ru_inblock;
+ /* Number of output operations via the file system. */
+ long ru_oublock;
+ /* Number of IPC messages sent. */
+ long ru_msgsnd;
+ /* Number of IPC messages received. */
+ long ru_msgrcv;
+ /* Number of signals delivered. */
+ long ru_nsignals;
+ /* Number of voluntary context switches, i.e. because the process
+ gave up the process before it had to (usually to wait for some
+ resource to be available). */
+ long ru_nvcsw;
+ /* Number of involuntary context switches, i.e. a higher priority process
+ became runnable or the current process used up its time slice. */
+ long ru_nivcsw;
+ };
+
+/* Priority limits. */
+#define PRIO_MIN -20 /* Minimum priority a process can have. */
+#define PRIO_MAX 20 /* Maximum priority a process can have. */
+
+/* The type of the WHICH argument to `getpriority' and `setpriority',
+ indicating what flavor of entity the WHO argument specifies. */
+enum __priority_which
+{
+ PRIO_PROCESS = 0, /* WHO is a process ID. */
+#define PRIO_PROCESS PRIO_PROCESS
+ PRIO_PGRP = 1, /* WHO is a process group ID. */
+#define PRIO_PGRP PRIO_PGRP
+ PRIO_USER = 2 /* WHO is a user ID. */
+#define PRIO_USER PRIO_USER
+};
diff --git a/libc/sysdeps/linux/c6x/bits/setjmp.h b/libc/sysdeps/linux/c6x/bits/setjmp.h
new file mode 100644
index 000000000..259e23b34
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/bits/setjmp.h
@@ -0,0 +1,39 @@
+/*
+ * Port of uClibc for TMS320C6000 DSP architecture
+ * Copyright (C) 2004 Texas Instruments Incorporated
+ * Author of TMS320C6000 port: Aurelien Jacquiot
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Library General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef _SETJMP_H
+# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
+#endif
+
+typedef struct {
+ unsigned long __regs[12]; /* save A10,B10... A15,B15*/
+ unsigned long __pc; /* the return address */
+} __jmp_buf[1];
+
+/* the stack pointer (B15) */
+#define JP_SP 11
+
+/* Test if longjmp to JMPBUF would unwind the frame
+ containing a local variable at ADDRESS. */
+#define _JMPBUF_UNWINDS(jmpbuf, address) \
+ ((void *) (address) < (void *) (jmpbuf)->__regs[JP_SP])
+
+
diff --git a/libc/sysdeps/linux/c6x/bits/sigcontextinfo.h b/libc/sysdeps/linux/c6x/bits/sigcontextinfo.h
new file mode 100644
index 000000000..b7e08cfc9
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/bits/sigcontextinfo.h
@@ -0,0 +1,26 @@
+/* Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>, 1998.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define SIGCONTEXT int _code, struct sigcontext *
+#define SIGCONTEXT_EXTRA_ARGS _code,
+#define GET_PC(ctx) ((void *) (ctx)->sc_pc)
+#define GET_FRAME(ctx) ((void *) __builtin_frame_address (1))
+#define GET_STACK(ctx) ((void *) (ctx)->sc_usp)
+#define CALL_SIGHANDLER(handler, signo, ctx) \
+ (handler)((signo), SIGCONTEXT_EXTRA_ARGS (ctx))
diff --git a/libc/sysdeps/linux/c6x/bits/stackinfo.h b/libc/sysdeps/linux/c6x/bits/stackinfo.h
new file mode 100644
index 000000000..9dbf06ae6
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/bits/stackinfo.h
@@ -0,0 +1,28 @@
+/* Copyright (C) 1999 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* This file contains a bit of information about the stack allocation
+ of the processor. */
+
+#ifndef _STACKINFO_H
+#define _STACKINFO_H 1
+
+/* On c6x the stack grows down. */
+#define _STACK_GROWS_DOWN 1
+
+#endif /* stackinfo.h */
diff --git a/libc/sysdeps/linux/c6x/bits/syscalls.h b/libc/sysdeps/linux/c6x/bits/syscalls.h
new file mode 100644
index 000000000..56a1667c3
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/bits/syscalls.h
@@ -0,0 +1,183 @@
+#ifndef _BITS_SYSCALLS_H
+#define _BITS_SYSCALLS_H
+#ifndef _SYSCALL_H
+# error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
+#endif
+
+#ifndef __ASSEMBLER__
+
+#include <errno.h>
+
+#define SYS_ify(syscall_name) (__NR_##syscall_name)
+
+#undef __SYSCALL_STRING
+# define __SYSCALL_STRING \
+ "swe\n\t" \
+ "nop\n\t"
+
+# define __SYSCALL_RES_CHECK (__res < -255 || __res >= 0)
+
+#define __SYSCALL_CLOBBERS "cc", "memory"
+
+#define __SYSCALL_RETURN(type) \
+ if (__SYSCALL_RES_CHECK) \
+ return (type) __res; \
+ __set_errno (-__res); \
+ return (type) -1;
+
+#ifndef NOT_IN_libc
+#define DEBUG_SYSCALL(name) { \
+ char d[64];\
+ write( 2, d, snprintf( d, 64, "syscall %d error %d\n", __NR_##name, _inline_sys_result)); \
+}
+#else
+#define DEBUG_SYSCALL(name) do{} while(0)
+#endif
+
+#undef INLINE_SYSCALL
+#define INLINE_SYSCALL(name, nr, args...) \
+ ({ unsigned int _inline_sys_result = INTERNAL_SYSCALL (name, , nr, args); \
+ if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (_inline_sys_result, ), 0)) \
+ { \
+ __set_errno (INTERNAL_SYSCALL_ERRNO (_inline_sys_result, )); \
+ _inline_sys_result = (unsigned int) -1; \
+ } \
+ (int) _inline_sys_result; })
+
+#undef INLINE_SYSCALL_NOERR
+#define INLINE_SYSCALL_NOERR(name, nr, args...) \
+ ({ unsigned int _inline_sys_result = INTERNAL_SYSCALL (name, , nr, args); \
+ (int) _inline_sys_result; })
+
+#undef INTERNAL_SYSCALL_DECL
+#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
+
+
+#define INTERNAL_SYSCALL( name, err, nr, args...) \
+ INTERNAL_SYSCALL_NCS( __NR_##name, err, nr, args )
+
+
+#define INTERNAL_SYSCALL_NCS(sys_num, err, nr, args...) \
+ ({ \
+ register long __A4 __asm__("A4"); \
+ register long __b0 __asm__("B0") = sys_num; \
+ LOAD_ARGS_##nr(args) \
+ __asm__ __volatile__(__SYSCALL_STRING \
+ : "=a" (__A4) \
+ : "b" (__b0) ASM_ARGS_##nr \
+ : __SYSCALL_CLOBBERS ); \
+ (int)__A4; \
+ })
+
+#undef INTERNAL_SYSCALL_ERROR_P
+#define INTERNAL_SYSCALL_ERROR_P(val, err) \
+ ((unsigned int) (val) >= 0xfffff001u)
+
+#undef INTERNAL_SYSCALL_ERRNO
+#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
+
+#if 0
+# define CALL_ERRNO_LOCATION "call __errno_location;"
+#define __CLONE_SYSCALL_STRING \
+ "ta 0x10;" \
+ "bcs 2f;" \
+ " sub %%o1, 1, %%o1;" \
+ "and %%A4, %%o1, %%A4;" \
+ "1:" \
+ ".subsection 2;" \
+ "2:" \
+ "save %%sp, -192, %%sp;" \
+ CALL_ERRNO_LOCATION \
+ " nop;" \
+ "st %%i0, [%%A4];" \
+ "ba 1b;" \
+ " restore %%g0, -1, %%A4;" \
+ ".previous;"
+
+#define INLINE_CLONE_SYSCALL(arg1,arg2,arg3,arg4,arg5) \
+({ \
+ register long __A4 __asm__ ("A4") = (long)(arg1); \
+ register long __B4 __asm__ ("B4") = (long)(arg2); \
+ register long __A6 __asm__ ("A6") = (long)(arg3); \
+ register long __B6 __asm__ ("B6") = (long)(arg4); \
+ register long __A8 __asm__ ("A8") = (long)(arg5); \
+ register long __g1 __asm__ ("g1") = __NR_clone; \
+ __asm __volatile (__CLONE_SYSCALL_STRING : \
+ "=r" (__g1), "=r" (__A4), "=r" (__B4) : \
+ "0" (__g1), "1" (__A4), "2" (__B4), \
+ "r" (__A6), "r" (__B6), "r" (__A8) : \
+ __SYSCALL_CLOBBERS); \
+ __A4; \
+})
+#endif
+
+#define LOAD_ARGS_0()
+#define ASM_ARGS_0
+#define LOAD_ARGS_1(A4) \
+ __A4 = (int)A4; \
+ LOAD_ARGS_0()
+#define ASM_ARGS_1 ASM_ARGS_0, "a" (__A4)
+#define LOAD_ARGS_2(A4, B4) \
+ register int __B4 __asm__ ("B4") = (int) (B4); \
+ LOAD_ARGS_1 (A4)
+#define ASM_ARGS_2 ASM_ARGS_1, "b" (__B4)
+#define LOAD_ARGS_3(A4, B4, A6) \
+ register int __A6 __asm__ ("A6") = (int) (A6); \
+ LOAD_ARGS_2 (A4, B4)
+#define ASM_ARGS_3 ASM_ARGS_2, "a" (__A6)
+#define LOAD_ARGS_4(A4, B4, A6, B6) \
+ register int __B6 __asm__ ("B6") = (int) (B6); \
+ LOAD_ARGS_3 (A4, B4, A6)
+#define ASM_ARGS_4 ASM_ARGS_3, "b" (__B6)
+#define LOAD_ARGS_5(A4, B4, A6, B6, A8) \
+ register int __A8 __asm__ ("A8") = (int) (A8); \
+ LOAD_ARGS_4 (A4, B4, A6, B6)
+#define ASM_ARGS_5 ASM_ARGS_4, "a" (__A8)
+#define LOAD_ARGS_6(A4, B4, A6, B6, A8, B8) \
+ register int __B8 __asm__ ("B8") = (int) (B8); \
+ LOAD_ARGS_5 (A4, B4, A6, B6, A8)
+#define ASM_ARGS_6 ASM_ARGS_5, "b" (__B8)
+
+#ifndef _syscall0
+
+#define C_DECL_ARGS_0() void
+#define C_DECL_ARGS_1(t, v) t v
+#define C_DECL_ARGS_2(t, v, args...) t v, C_DECL_ARGS_1(args)
+#define C_DECL_ARGS_3(t, v, args...) t v, C_DECL_ARGS_2(args)
+#define C_DECL_ARGS_4(t, v, args...) t v, C_DECL_ARGS_3(args)
+#define C_DECL_ARGS_5(t, v, args...) t v, C_DECL_ARGS_4(args)
+#define C_DECL_ARGS_6(t, v, args...) t v, C_DECL_ARGS_5(args)
+
+#define C_ARGS_0()
+#define C_ARGS_1(t, v) v
+#define C_ARGS_2(t, v, args...) v, C_ARGS_1(args)
+#define C_ARGS_3(t, v, args...) v, C_ARGS_2(args)
+#define C_ARGS_4(t, v, args...) v, C_ARGS_3(args)
+#define C_ARGS_5(t, v, args...) v, C_ARGS_4(args)
+#define C_ARGS_6(t, v, args...) v, C_ARGS_5(args)
+
+#define SYSCALL_FUNC(nargs, type, name, args...) \
+type name(C_DECL_ARGS_##nargs(args)) { \
+ return (type)INLINE_SYSCALL(name, nargs, C_ARGS_##nargs(args)); \
+}
+
+#define SYSCALL_NOERR_FUNC(nargs, type, name, args...) \
+type name(C_DECL_ARGS_##nargs(args)) { \
+ return (type)INLINE_SYSCALL_NOERR(name, nargs, C_ARGS_##nargs(args)); \
+}
+
+#define _syscall0(args...) SYSCALL_FUNC(0, args)
+#define _syscall_noerr0(args...) SYSCALL_NOERR_FUNC(0, args)
+#define _syscall1(args...) SYSCALL_FUNC(1, args)
+#define _syscall_noerr1(args...) SYSCALL_NOERR_FUNC(1, args)
+#define _syscall2(args...) SYSCALL_FUNC(2, args)
+#define _syscall3(args...) SYSCALL_FUNC(3, args)
+#define _syscall4(args...) SYSCALL_FUNC(4, args)
+#define _syscall5(args...) SYSCALL_FUNC(5, args)
+#define _syscall6(args...) SYSCALL_FUNC(6, args)
+
+#endif /* _syscall0 */
+
+#endif /* __ASSEMBLER__ */
+#endif /* _BITS_SYSCALLS_H */
+
diff --git a/libc/sysdeps/linux/c6x/bits/uClibc_arch_features.h b/libc/sysdeps/linux/c6x/bits/uClibc_arch_features.h
new file mode 100644
index 000000000..59e7de987
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/bits/uClibc_arch_features.h
@@ -0,0 +1,48 @@
+/*
+ * Track misc arch-specific features that aren't config options
+ */
+
+#ifndef _BITS_UCLIBC_ARCH_FEATURES_H
+#define _BITS_UCLIBC_ARCH_FEATURES_H
+
+/* instruction used when calling abort() to kill yourself */
+/*#define __UCLIBC_ABORT_INSTRUCTION__ "asm instruction"*/
+#undef __UCLIBC_ABORT_INSTRUCTION__
+
+/* can your target use syscall6() for mmap ? */
+#define __UCLIBC_MMAP_HAS_6_ARGS__
+
+/* does your target use syscall4() for truncate64 ? (32bit arches only) */
+#undef __UCLIBC_TRUNCATE64_HAS_4_ARGS__
+
+/* does your target have a broken create_module() ? */
+#undef __UCLIBC_BROKEN_CREATE_MODULE__
+
+/* does your target have to worry about older [gs]etrlimit() ? */
+#undef __UCLIBC_HANDLE_OLDER_RLIMIT__
+
+/* does your target have an asm .set ? */
+#define __UCLIBC_HAVE_ASM_SET_DIRECTIVE__
+
+/* define if target doesn't like .global */
+#undef __UCLIBC_ASM_GLOBAL_DIRECTIVE__
+
+/* define if target supports .weak */
+#define __UCLIBC_HAVE_ASM_WEAK_DIRECTIVE__
+
+/* define if target supports .weakext */
+#undef __UCLIBC_HAVE_ASM_WEAKEXT_DIRECTIVE__
+
+/* needed probably only for ppc64 */
+#undef __UCLIBC_HAVE_ASM_GLOBAL_DOT_NAME__
+
+/* define if target supports CFI pseudo ops */
+#undef __UCLIBC_HAVE_ASM_CFI_DIRECTIVES__
+
+/* define if target supports IEEE signed zero floats */
+#define __UCLIBC_HAVE_SIGNED_ZERO__
+
+/* only weird assemblers generally need this */
+#define __UCLIBC_ASM_LINE_SEP__ @
+
+#endif /* _BITS_UCLIBC_ARCH_FEATURES_H */
diff --git a/libc/sysdeps/linux/c6x/bits/wordsize.h b/libc/sysdeps/linux/c6x/bits/wordsize.h
new file mode 100644
index 000000000..ba643b60a
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/bits/wordsize.h
@@ -0,0 +1,19 @@
+/* Copyright (C) 1999 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define __WORDSIZE 32
diff --git a/libc/sysdeps/linux/c6x/brk.c b/libc/sysdeps/linux/c6x/brk.c
new file mode 100644
index 000000000..7eb486308
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/brk.c
@@ -0,0 +1,54 @@
+/*
+ * Port of uClibc for TMS320C6000 DSP architecture
+ * Copyright (C) 2004 Texas Instruments Incorporated
+ * Author of TMS320C6000 port: Aurelien Jacquiot
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Library General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <unistd.h>
+#include <sys/syscall.h>
+#include <errno.h>
+
+libc_hidden_proto(brk)
+
+/* This must be initialized data because commons can't have aliases. */
+void * __curbrk attribute_hidden = 0;
+
+int brk (void *addr)
+{
+ void *newbrk;
+
+ __asm__ __volatile__ ( \
+ "mv .d1 %2, A4\n\t" \
+ "mvk .s2 %1, B0\n\t" \
+ "swe\n\t" \
+ "nop\n\t" \
+ "mv .d2 B0, %0" \
+ : "=b" (newbrk) \
+ : "i" (__NR_brk), \
+ "a" (addr) \
+ : "memory", "cc", "B0", "A4"); \
+
+ __curbrk = newbrk;
+
+ if (newbrk < addr) {
+ __set_errno (ENOMEM);
+ return -1;
+ }
+ return 0;
+}
+libc_hidden_def(brk)
diff --git a/libc/sysdeps/linux/c6x/bsd-_setjmp.s b/libc/sysdeps/linux/c6x/bsd-_setjmp.s
new file mode 100644
index 000000000..566318a2a
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/bsd-_setjmp.s
@@ -0,0 +1,48 @@
+ ;
+ ; Port of uClibc for TMS320C6000 DSP architecture
+ ; Copyright (C) 2004 Texas Instruments Incorporated
+ ; Author of TMS320C6000 port: Aurelien Jacquiot
+ ;
+ ; This program is free software; you can redistribute it and/or modify it
+ ; under the terms of the GNU Library General Public License as published by
+ ; the Free Software Foundation; either version 2 of the License, or (at your
+ ; option) any later version.
+ ;
+ ; This program is distributed in the hope that it will be useful, but WITHOUT
+ ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
+ ; for more details.
+ ;
+ ; You should have received a copy of the GNU Library General Public License
+ ; along with this program; if not, write to the Free Software Foundation,
+ ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ ;
+
+ .global _setjmp
+
+_setjmp:
+ MV .D2X A4,B4 ; jmp_buf address
+|| STW .D1T2 B3,*+A4(48) ; return address
+
+ STW .D1T1 A10,*+A4(0)
+|| STW .D2T2 B10,*+B4(4)
+|| ZERO .L1 A6
+
+ STW .D1T1 A6,*+A4(52) ; no signal mask set
+|| B .S2 B3 ; returns in 5 cycles
+
+ STW .D1T1 A11,*+A4(8)
+|| STW .D2T2 B11,*+B4(12)
+ STW .D1T1 A12,*+A4(16)
+|| STW .D2T2 B12,*+B4(20)
+ STW .D1T1 A13,*+A4(24)
+|| STW .D2T2 B13,*+B4(28)
+ STW .D1T1 A14,*+A4(32)
+|| STW .D2T2 B14,*+B4(36)
+ STW .D1T1 A15,*+A4(40)
+|| STW .D2T2 B15,*+B4(44)
+|| ZERO .L1 A4 ; return values
+
+
+
+
diff --git a/libc/sysdeps/linux/c6x/bsd-setjmp.S b/libc/sysdeps/linux/c6x/bsd-setjmp.S
new file mode 100644
index 000000000..3ab597d8e
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/bsd-setjmp.S
@@ -0,0 +1,67 @@
+ ;
+ ; Port of uClibc for TMS320C6000 DSP architecture
+ ; Copyright (C) 2004 Texas Instruments Incorporated
+ ; Author of TMS320C6000 port: Aurelien Jacquiot
+ ;
+ ; This program is free software; you can redistribute it and/or modify it
+ ; under the terms of the GNU Library General Public License as published by
+ ; the Free Software Foundation; either version 2 of the License, or (at your
+ ; option) any later version.
+ ;
+ ; This program is distributed in the hope that it will be useful, but WITHOUT
+ ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
+ ; for more details.
+ ;
+ ; You should have received a copy of the GNU Library General Public License
+ ; along with this program; if not, write to the Free Software Foundation,
+ ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ ;
+
+ .global setjmp
+setjmp:
+#if 0
+.if 1 /* was: .if (CONFIG_UCLIBC_SHARED == 0) */
+
+ MVKL .S1 ___curr_eh_stack_entry,A6
+|| SUB .D1X A4,B15,A3
+ MVKH .S1 ___curr_eh_stack_entry,A6
+|| CMPGT .L1 A3,4,A0 ; A0 set if C++ exceptions case
+
+ LDW .D1T1 *A6,A2
+.else
+ MVKL .S2 (___curr_eh_stack_entry - $bss)/4,B6
+|| SUB .D1X A4,B15,A3
+ MVKH .S2 (___curr_eh_stack_entry - $bss)/4,B6
+|| CMPGT .L1 A3,4,A0 ; A0 set if C++ exceptions case
+
+ LDW .D2T1 *+B14[B6],A2
+.endif
+ NOP
+#else
+ MVK .S1 0, A0
+#endif
+
+ MVK .L2 1,B4 ; indicate to ___sigjmp_save to save signal mask
+|| MV .D2X A4,B6 ; jmp_buf address
+|| STW .D1T2 B3,*+A4(48) ; return address
+
+ ADDAW .D1 A2,2,A2
+ [A0] CMPEQ .L1 A4,A2,A0 ; A0 set if C++ exceptions case
+
+ STW .D1T1 A10,*+A4(0)
+|| STW .D2T2 B10,*+B6(4)
+||[!A0] B .S1 __sigjmp_save ; branch to ___sigjmp_save in 5 cycles
+||[A0] B .S2 B3
+
+ STW .D1T1 A11,*+A4(8)
+|| STW .D2T2 B11,*+B6(12)
+ STW .D1T1 A12,*+A4(16)
+|| STW .D2T2 B12,*+B6(20)
+ STW .D1T1 A13,*+A4(24)
+|| STW .D2T2 B13,*+B6(28)
+ STW .D1T1 A14,*+A4(32)
+|| STW .D2T2 B14,*+B6(36)
+ STW .D1T1 A15,*+A4(40)
+|| STW .D2T2 B15,*+B6(44)
+||[A0] ZERO .L1 A4 ; returns 0 for the C++ case
diff --git a/libc/sysdeps/linux/c6x/clone.S b/libc/sysdeps/linux/c6x/clone.S
new file mode 100644
index 000000000..6fba5bb98
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/clone.S
@@ -0,0 +1,98 @@
+ ;
+ ; Port of uClibc for TMS320C6000 DSP architecture
+ ; Copyright (C) 2004 Texas Instruments Incorporated
+ ; Author of TMS320C6000 port: Aurelien Jacquiot
+ ;
+ ; This program is free software; you can redistribute it and/or modify it
+ ; under the terms of the GNU Library General Public License as published by
+ ; the Free Software Foundation; either version 2 of the License, or (at your
+ ; option) any later version.
+ ;
+ ; This program is distributed in the hope that it will be useful, but WITHOUT
+ ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
+ ; for more details.
+ ;
+ ; You should have received a copy of the GNU Library General Public License
+ ; along with this program; if not, write to the Free Software Foundation,
+ ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ ;
+#define __ASSEMBLY__
+
+ ; int _clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg);
+
+#include <asm/errno.h>
+#include <sys/syscall.h>
+
+ .global __clone
+ .global clone
+ .global __errno_location
+
+ ;Currently supports only
+ ;int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg)
+ ;
+ ;Requires update for supporting
+ ; int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg,
+ ; int *parent_tidptr, struct user_desc *newtls, int *child_pidptr)
+
+__clone:
+ ; index 1 points to the forth argument and is to be moved to B6
+ LDW .D2T2 *+B15[1],B5
+ NOP 4
+ OR .D2X B4,A4,B2 ; sanity check arguments, no NULL function or stack pointers
+|| MV .S2 B4,B9
+|| MV .D1 A4,A9 ; backup fn and child_stack pointers
+
+ [!B2] B .S2 __syscall_error
+||[!B2] MVK .S1 EINVAL,A4
+ NOP 4
+
+ MV .D1 A6,A4 ; get flags as arg0, arg1 is the new stack
+|| AND .D2 ~7,B4,B4
+
+ ; do the system call
+|| MVK .S2 __NR_clone,B0
+|| MV .L2 B5,B6
+0:
+#ifndef _TMS320C6400_PLUS
+ MVC .S2 CSR,B2
+ CLR .S2 B2,0,0,B1
+ MVC .S2 B1,CSR
+ MVC .S2 IFR,B1
+ SET .S2 B1,6,6,B1
+ MVC .S2 B1,ISR
+ MVC .S2 B2,CSR
+ NOP
+#else
+ SWE
+#endif
+
+ MV .D2 B9,B4 ; restore child stack
+
+|| CMPEQ .L1 0,A4,A2
+|| CMPLT .L2X A4,0,B2
+
+ [B2] B .S2 __syscall_error ; if syscall < 0, it is an error
+ NOP 5
+ [A2] B .S2X A9 ; branch to function
+|| [A2] MV .D1X B6,A4 ; set arg (B6 is preserved by syscall)
+ [!A2] B .S2 B3 ; otherwise (syscall result > 0) returns directly
+ [A2] ADDKPC .S2 __return_thread,B3, 4
+
+__return_thread:
+ b .s2 HIDDEN_JUMPTARGET(_exit)
+ nop 5
+
+__syscall_error:
+ NEG .S1 A4,A4
+ STW .D2T1 A4,*B15--[2]
+ STW .D2T2 B3,*+B15[1]
+ CALLP .S2 __errno_location,B3
+ LDW .D2T2 *+B15[1],B3
+ LDW .D2T1 *++B15[2],A5
+ NOP 3
+ BNOP .S2 B3,3
+ STW .D1T1 A5,*A4
+ MVK .L1 -1,A4
+
+.set clone, __clone
diff --git a/libc/sysdeps/linux/c6x/crt1.S b/libc/sysdeps/linux/c6x/crt1.S
new file mode 100644
index 000000000..810f39557
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/crt1.S
@@ -0,0 +1,67 @@
+;
+; Port of uClibc for TMS320C6000 DSP architecture
+;
+; Copyright (C) 2010 Texas Instruments Incorporated
+; Mark Salter <msalter@redhat.com>
+;
+; This program is free software; you can redistribute it and/or modify it
+; under the terms of the GNU Library General Public License as published by
+; the Free Software Foundation; either version 2 of the License, or (at your
+; option) any later version.
+;
+; This program is distributed in the hope that it will be useful, but WITHOUT
+; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
+; for more details.
+;
+; You should have received a copy of the GNU Library General Public License
+; along with this program; if not, write to the Free Software Foundation,
+; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+;
+
+ .text
+
+ ;; On entry, the dynamic linker
+ ;;
+ ;; 0(sp) pad0
+ ;; 4(sp) pad1
+ ;; 8(sp) argc
+ ;; 12(sp) argv[0]
+ ;; ...
+ ;; (4*(argc+3))(sp) NULL
+ ;; (4*(argc+4))(sp) envp[0]
+ ;; ...
+ ;; NULL
+
+ ;; Register values are unspecified, except:
+ ;;
+ ;; A4 --> pointer to rtld fini rountine
+ ;; B14 --> pointer to application DSBT table
+
+ .global _start
+_start:
+ .global _c_int00
+_c_int00:
+ ;; Things to do:
+ ;;
+ ;; * call __uClibc_main(
+ ;; int (*main)(int, char **, char **), A4
+ ;; int argc, B4
+ ;; char **argv, A6
+ ;; void (*app_init)(void), B6
+ ;; void (*app_fini)(void), A8
+ ;; void (*rtld_fini)(void), B8
+ ;; void *stack_end) A10
+
+ MV .D2X A4,B8 ; rtld_fini
+
+ LDW .D2T1 *+B14($GOT(main)), A4
+ LDW .D2T2 *+B14($GOT(_init)), B6
+ B .S2 __uClibc_main
+|| LDW .D2T1 *+B14($GOT(_fini)), A8
+
+ LDW .D2T2 *+B15(8),B4 ; argc
+ ADDAW .D1X B15,3,A6 ; **argv
+ MV .D1X B15,A10 ; stack_end
+|| ZERO .L1 A15 ; clear FP
+ NOP 2
diff --git a/libc/sysdeps/linux/c6x/crti.S b/libc/sysdeps/linux/c6x/crti.S
new file mode 100644
index 000000000..e689a04d1
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/crti.S
@@ -0,0 +1,17 @@
+/*
+ * This file just supplies function prologues for the .init and .fini
+ * sections. It is linked in before crtbegin.o.
+ */
+
+ .section .init
+ .globl _init
+ .type _init,@function
+_init:
+ add .l2 -8, B15, B15
+ stw .d2t2 B3,*+B15(4)
+ .section .fini
+ .globl _fini
+ .type _fini,@function
+_fini:
+ add .l2 -8, B15, B15
+ stw .d2t2 B3,*+B15(4)
diff --git a/libc/sysdeps/linux/c6x/crtn.S b/libc/sysdeps/linux/c6x/crtn.S
new file mode 100644
index 000000000..37e799df3
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/crtn.S
@@ -0,0 +1,19 @@
+/*
+ * This file supplies function epilogues for the .init and .fini sections.
+ * It is linked in after all other files.
+ */
+
+ .section .init
+ ldw .d2t2 *+B15(4), B3
+ add .d2 B15, 8, B15
+ nop 3
+ ret .s2 B3
+ nop 5
+
+ .section .fini
+ ldw .d2t2 *+B15(4), B3
+ add .d2 B15, 8, B15
+ nop 3
+ ret .s2 B3
+ nop 5
+
diff --git a/libc/sysdeps/linux/c6x/prctl.c b/libc/sysdeps/linux/c6x/prctl.c
new file mode 100644
index 000000000..fcf1f9d54
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/prctl.c
@@ -0,0 +1,43 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * prctl() for uClibc
+ *
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <stdarg.h>
+/* psm: including sys/prctl.h would depend on kernel headers */
+
+#ifdef __NR_prctl
+extern int prctl (int __option, ...);
+int prctl (int __option, ...)
+{
+ register long no __asm__("B0");
+ register long a __asm__("A4");
+ register long b __asm__("B4");
+ register long c __asm__("A6");
+ register long d __asm__("B6");
+ register long e __asm__("A8");
+ int __res;
+ va_list ap;
+
+ va_start( ap, __option);
+ a = __option;
+ b = va_arg( ap, long);
+ c = va_arg( ap, long);
+ d = va_arg( ap, long);
+ e = va_arg( ap, long);
+ va_end( ap );
+
+ no = __NR_prctl;
+
+ __asm__ __volatile__ ("SWE" : "=a" (a) : "a" (a), "b" (b), "a" (c), "b" (d), "a" (e), "b" (no)
+ : "memory", "cc");
+
+ __res = a;
+ __SYSCALL_RETURN (int);
+}
+#endif
diff --git a/libc/sysdeps/linux/c6x/pread_write.c b/libc/sysdeps/linux/c6x/pread_write.c
new file mode 100644
index 000000000..f985b4374
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/pread_write.c
@@ -0,0 +1,103 @@
+/* vi: set sw=4 ts=4:
+ *
+ * Copyright (C) 2002 by Erik Andersen <andersen@uclibc.org>
+ * Based in part on the files
+ * ./sysdeps/unix/sysv/linux/pwrite.c,
+ * ./sysdeps/unix/sysv/linux/pread.c,
+ * sysdeps/posix/pread.c
+ * sysdeps/posix/pwrite.c
+ * from GNU libc 2.2.5, but reworked considerably...
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Library General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#define _LARGEFILE64_SOURCE
+#include <features.h>
+#undef __OPTIMIZE__
+/* We absolutely do _NOT_ want interfaces silently
+ * * * renamed under us or very bad things will happen... */
+#ifdef __USE_FILE_OFFSET64
+# undef __USE_FILE_OFFSET64
+#endif
+
+
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/syscall.h>
+#include <unistd.h>
+#include <stdint.h>
+
+extern __typeof(pread) __libc_pread;
+extern __typeof(pwrite) __libc_pwrite;
+#ifdef __UCLIBC_HAS_LFS__
+extern __typeof(pread64) __libc_pread64;
+extern __typeof(pwrite64) __libc_pwrite64;
+#endif
+
+#ifdef __NR_pread64 /* Newer kernels renamed but it's the same. */
+# ifdef __NR_pread
+# error "__NR_pread and __NR_pread64 both defined???"
+# endif
+# define __NR_pread __NR_pread64
+#endif
+
+#define __NR___syscall_pread __NR_pread
+static inline _syscall5(ssize_t, __syscall_pread, int, fd, void *, buf,
+ size_t, count, off_t, offset_hi, off_t, offset_lo);
+
+ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset)
+{
+ return(__syscall_pread(fd,buf,count,offset,offset >> 31));
+}
+weak_alias (__libc_pread, pread)
+
+#if defined __UCLIBC_HAS_LFS__
+ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset)
+{
+ uint32_t low = offset & 0xffffffff;
+ uint32_t high = offset >> 32;
+ return(__syscall_pread(fd, buf, count, low, high));
+}
+weak_alias (__libc_pread64, pread64)
+#endif /* __UCLIBC_HAS_LFS__ */
+
+
+#ifdef __NR_pwrite64 /* Newer kernels renamed but it's the same. */
+# ifdef __NR_pwrite
+# error "__NR_pwrite and __NR_pwrite64 both defined???"
+# endif
+# define __NR_pwrite __NR_pwrite64
+#endif
+
+#define __NR___syscall_pwrite __NR_pwrite
+static inline _syscall5(ssize_t, __syscall_pwrite, int, fd, const void *, buf,
+ size_t, count, off_t, offset_hi, off_t, offset_lo);
+
+ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset)
+{
+ return(__syscall_pwrite(fd,buf,count,offset,offset >> 31));
+}
+weak_alias (__libc_pwrite, pwrite)
+
+#if defined __UCLIBC_HAS_LFS__
+ssize_t __libc_pwrite64(int fd, const void *buf, size_t count, off64_t offset)
+{
+ uint32_t low = offset & 0xffffffff;
+ uint32_t high = offset >> 32;
+ return(__syscall_pwrite(fd, buf, count, low, high));
+}
+weak_alias (__libc_pwrite64, pwrite64)
+#endif /* __UCLIBC_HAS_LFS__ */
+
diff --git a/libc/sysdeps/linux/c6x/setjmp.s b/libc/sysdeps/linux/c6x/setjmp.s
new file mode 100644
index 000000000..28a4f0370
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/setjmp.s
@@ -0,0 +1,43 @@
+ ;
+ ; Port of uClibc for TMS320C6000 DSP architecture
+ ; Copyright (C) 2004 Texas Instruments Incorporated
+ ; Author of TMS320C6000 port: Aurelien Jacquiot
+ ;
+ ; This program is free software; you can redistribute it and/or modify it
+ ; under the terms of the GNU Library General Public License as published by
+ ; the Free Software Foundation; either version 2 of the License, or (at your
+ ; option) any later version.
+ ;
+ ; This program is distributed in the hope that it will be useful, but WITHOUT
+ ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
+ ; for more details.
+ ;
+ ; You should have received a copy of the GNU Library General Public License
+ ; along with this program; if not, write to the Free Software Foundation,
+ ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ ;
+
+ .global __sigsetjmp
+; .ref __sigjmp_save
+
+__sigsetjmp:
+ MV .D2X A4,B6 ; jmp_buf address
+|| STW .D1T2 B3,*+A4(48) ; return address
+
+ STW .D1T1 A10,*+A4(0)
+|| STW .D2T2 B10,*+B6(4)
+|| B .S2 __sigjmp_save ; branch to ___sigjmp_save in 5 cycles
+
+ STW .D1T1 A11,*+A4(8)
+|| STW .D2T2 B11,*+B6(12)
+ STW .D1T1 A12,*+A4(16)
+|| STW .D2T2 B12,*+B6(20)
+ STW .D1T1 A13,*+A4(24)
+|| STW .D2T2 B13,*+B6(28)
+ STW .D1T1 A14,*+A4(32)
+|| STW .D2T2 B14,*+B6(36)
+ STW .D1T1 A15,*+A4(40)
+|| STW .D2T2 B15,*+B6(44)
+
+
diff --git a/libc/sysdeps/linux/c6x/sigaction.c b/libc/sysdeps/linux/c6x/sigaction.c
new file mode 100644
index 000000000..1865998ee
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/sigaction.c
@@ -0,0 +1,115 @@
+/*
+ Copyright (C) 2010 Texas Instruments Incorporated
+ Adapted from i386 version by Mark Salter <msalter@redhat.com>
+
+ Copyright (C) 1997, 1998, 1999, 2000 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
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ Totally hacked up for uClibc by Erik Andersen <andersen@codepoet.org>
+ */
+
+#include <errno.h>
+#include <signal.h>
+#include <string.h>
+#include <sys/syscall.h>
+#include <bits/kernel_sigaction.h>
+
+#define SA_RESTORER 0x04000000
+
+extern __typeof(sigaction) __libc_sigaction;
+
+extern void restore_rt(void) __asm__ ("__restore_rt") attribute_hidden;
+extern void restore(void) __asm__ ("__restore") attribute_hidden;
+
+/* If ACT is not NULL, change the action for SIG to *ACT.
+ If OACT is not NULL, put the old action for SIG in *OACT. */
+int __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
+{
+ int result;
+ struct kernel_sigaction kact, koact;
+
+#ifdef SIGCANCEL
+ if (sig == SIGCANCEL) {
+ __set_errno (EINVAL);
+ return -1;
+ }
+#endif
+
+ if (act) {
+ kact.k_sa_handler = act->sa_handler;
+ memcpy (&kact.sa_mask, &act->sa_mask, sizeof (kact.sa_mask));
+ kact.sa_flags = act->sa_flags;
+
+ kact.sa_flags = act->sa_flags | SA_RESTORER;
+ kact.sa_restorer = ((act->sa_flags & SA_SIGINFO)
+ ? &restore_rt : &restore);
+ }
+
+ /* XXX The size argument hopefully will have to be changed to the
+ real size of the user-level sigset_t. */
+ result = __syscall_rt_sigaction(sig, act ? __ptrvalue (&kact) : NULL,
+ oact ? __ptrvalue (&koact) : NULL, _NSIG / 8);
+
+ if (oact && result >= 0) {
+ oact->sa_handler = koact.k_sa_handler;
+ memcpy (&oact->sa_mask, &koact.sa_mask, sizeof (oact->sa_mask));
+ oact->sa_flags = koact.sa_flags;
+ oact->sa_restorer = koact.sa_restorer;
+ }
+ return result;
+}
+
+#ifndef LIBC_SIGACTION
+weak_alias(__libc_sigaction,sigaction)
+libc_hidden_weak(sigaction)
+#endif
+
+/* NOTE: Please think twice before making any changes to the bits of
+ code below. GDB needs some intimate knowledge about it to
+ recognize them as signal trampolines, and make backtraces through
+ signal handlers work right. Important are both the names
+ (__restore and __restore_rt) and the exact instruction sequence.
+ If you ever feel the need to make any changes, please notify the
+ appropriate GDB maintainer. */
+
+#define RESTORE(name, syscall) RESTORE2 (name, syscall)
+#define RESTORE2(name, syscall) \
+__asm__ \
+ ( \
+ " .text\n" \
+ " .global " #name "\n" \
+ "__" #name ":\n" \
+ " MVK " #syscall ",B0\n" \
+ " SWE\n" \
+ " NOP\n" \
+ " NOP\n" \
+ " NOP\n" \
+ " NOP\n" \
+ " NOP\n" \
+ " NOP\n" \
+ );
+
+#ifdef __NR_rt_sigaction
+/* The return code for realtime-signals. */
+RESTORE (restore_rt, __NR_rt_sigreturn)
+#endif
+
+#ifdef __NR_sigreturn
+/* For the boring old signals. */
+RESTORE (restore, __NR_sigreturn)
+#endif
diff --git a/libc/sysdeps/linux/c6x/sys/procfs.h b/libc/sysdeps/linux/c6x/sys/procfs.h
new file mode 100644
index 000000000..41c2d0866
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/sys/procfs.h
@@ -0,0 +1,122 @@
+/* Copyright (C) 1996, 1997, 1999, 2000, 2001 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_PROCFS_H
+#define _SYS_PROCFS_H 1
+
+/* This is somewhat modelled after the file of the same name on SVR4
+ systems. It provides a definition of the core file format for ELF
+ used on Linux. It doesn't have anything to do with the /proc file
+ system, even though Linux has one.
+
+ Anyway, the whole purpose of this file is for GDB and GDB only.
+ Don't read too much into it. Don't use it for anything other than
+ GDB unless you know what you are doing. */
+
+#include <features.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/user.h>
+
+__BEGIN_DECLS
+
+/* Type for a general-purpose register. */
+typedef unsigned long elf_greg_t;
+
+/* And the whole bunch of them. We could have used `struct
+ user_regs_struct' directly in the typedef, but tradition says that
+ the register set is an array, which does have some peculiar
+ semantics, so leave it that way. */
+#define ELF_NGREG 20
+typedef elf_greg_t elf_gregset_t[ELF_NGREG];
+
+/* Signal info. */
+struct elf_siginfo
+ {
+ int si_signo; /* Signal number. */
+ int si_code; /* Extra code. */
+ int si_errno; /* Errno. */
+ };
+
+
+/* Definitions to generate Intel SVR4-like core files. These mostly
+ have the same names as the SVR4 types with "elf_" tacked on the
+ front to prevent clashes with Linux definitions, and the typedef
+ forms have been avoided. This is mostly like the SVR4 structure,
+ but more Linuxy, with things that Linux does not support and which
+ GDB doesn't really use excluded. */
+
+struct elf_prstatus
+ {
+ struct elf_siginfo pr_info; /* Info associated with signal. */
+ short int pr_cursig; /* Current signal. */
+ unsigned long int pr_sigpend; /* Set of pending signals. */
+ unsigned long int pr_sighold; /* Set of held signals. */
+ __pid_t pr_pid;
+ __pid_t pr_ppid;
+ __pid_t pr_pgrp;
+ __pid_t pr_sid;
+ struct timeval pr_utime; /* User time. */
+ struct timeval pr_stime; /* System time. */
+ struct timeval pr_cutime; /* Cumulative user time. */
+ struct timeval pr_cstime; /* Cumulative system time. */
+ elf_gregset_t pr_reg; /* GP registers. */
+ int pr_fpvalid; /* True if math copro being used. */
+ };
+
+
+#define ELF_PRARGSZ (80) /* Number of chars for args. */
+
+struct elf_prpsinfo
+ {
+ char pr_state; /* Numeric process state. */
+ char pr_sname; /* Char for pr_state. */
+ char pr_zomb; /* Zombie. */
+ char pr_nice; /* Nice val. */
+ unsigned long int pr_flag; /* Flags. */
+ unsigned short int pr_uid;
+ unsigned short int pr_gid;
+ int pr_pid, pr_ppid, pr_pgrp, pr_sid;
+ /* Lots missing */
+ char pr_fname[16]; /* Filename of executable. */
+ char pr_psargs[ELF_PRARGSZ]; /* Initial part of arg list. */
+ };
+
+
+/* The rest of this file provides the types for emulation of the
+ Solaris <proc_service.h> interfaces that should be implemented by
+ users of libthread_db. */
+
+/* Addresses. */
+typedef void *psaddr_t;
+
+/* Register sets. Linux has different names. */
+typedef elf_gregset_t prgregset_t;
+typedef elf_gregset_t prfpregset_t;
+
+/* We don't have any differences between processes and threads,
+ therefore have only one PID type. */
+typedef __pid_t lwpid_t;
+
+/* Process status and info. In the end we do provide typedefs for them. */
+typedef struct elf_prstatus prstatus_t;
+typedef struct elf_prpsinfo prpsinfo_t;
+
+__END_DECLS
+
+#endif /* sys/procfs.h */
diff --git a/libc/sysdeps/linux/c6x/sys/ptrace.h b/libc/sysdeps/linux/c6x/sys/ptrace.h
new file mode 100644
index 000000000..b8a7a49d5
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/sys/ptrace.h
@@ -0,0 +1,176 @@
+/* `ptrace' debugger support interface. Linux version.
+ Copyright (C) 1996-1999,2000,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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_PTRACE_H
+#define _SYS_PTRACE_H 1
+
+#include <features.h>
+
+__BEGIN_DECLS
+
+/* Type of the REQUEST argument to `ptrace.' */
+enum __ptrace_request
+{
+ /* Indicate that the process making this request should be traced.
+ All signals received by this process can be intercepted by its
+ parent, and its parent can use the other `ptrace' requests. */
+ PTRACE_TRACEME = 0,
+#define PT_TRACE_ME PTRACE_TRACEME
+
+ /* Return the word in the process's text space at address ADDR. */
+ PTRACE_PEEKTEXT = 1,
+#define PT_READ_I PTRACE_PEEKTEXT
+
+ /* Return the word in the process's data space at address ADDR. */
+ PTRACE_PEEKDATA = 2,
+#define PT_READ_D PTRACE_PEEKDATA
+
+ /* Return the word in the process's user area at offset ADDR. */
+ PTRACE_PEEKUSER = 3,
+#define PT_READ_U PTRACE_PEEKUSER
+
+ /* Write the word DATA into the process's text space at address ADDR. */
+ PTRACE_POKETEXT = 4,
+#define PT_WRITE_I PTRACE_POKETEXT
+
+ /* Write the word DATA into the process's data space at address ADDR. */
+ PTRACE_POKEDATA = 5,
+#define PT_WRITE_D PTRACE_POKEDATA
+
+ /* Write the word DATA into the process's user area at offset ADDR. */
+ PTRACE_POKEUSER = 6,
+#define PT_WRITE_U PTRACE_POKEUSER
+
+ /* Continue the process. */
+ PTRACE_CONT = 7,
+#define PT_CONTINUE PTRACE_CONT
+
+ /* Kill the process. */
+ PTRACE_KILL = 8,
+#define PT_KILL PTRACE_KILL
+
+ /* Single step the process.
+ This is not supported on all machines. */
+ PTRACE_SINGLESTEP = 9,
+#define PT_STEP PTRACE_SINGLESTEP
+
+ /* Get all general purpose registers used by a processes.
+ This is not supported on all machines. */
+ PTRACE_GETREGS = 12,
+#define PT_GETREGS PTRACE_GETREGS
+
+ /* Set all general purpose registers used by a processes.
+ This is not supported on all machines. */
+ PTRACE_SETREGS = 13,
+#define PT_SETREGS PTRACE_SETREGS
+
+ /* Get all floating point registers used by a processes.
+ This is not supported on all machines. */
+ PTRACE_GETFPREGS = 14,
+#define PT_GETFPREGS PTRACE_GETFPREGS
+
+ /* Set all floating point registers used by a processes.
+ This is not supported on all machines. */
+ PTRACE_SETFPREGS = 15,
+#define PT_SETFPREGS PTRACE_SETFPREGS
+
+ /* Attach to a process that is already running. */
+ PTRACE_ATTACH = 16,
+#define PT_ATTACH PTRACE_ATTACH
+
+ /* Detach from a process attached to with PTRACE_ATTACH. */
+ PTRACE_DETACH = 17,
+#define PT_DETACH PTRACE_DETACH
+
+ /* Get all extended floating point registers used by a processes.
+ This is not supported on all machines. */
+ PTRACE_GETFPXREGS = 18,
+#define PT_GETFPXREGS PTRACE_GETFPXREGS
+
+ /* Set all extended floating point registers used by a processes.
+ This is not supported on all machines. */
+ PTRACE_SETFPXREGS = 19,
+#define PT_SETFPXREGS PTRACE_SETFPXREGS
+
+ /* Continue and stop at the next (return from) syscall. */
+ PTRACE_SYSCALL = 24,
+#define PT_SYSCALL PTRACE_SYSCALL
+
+ /* Obtain the load map of the main program or the interpreter of the
+ ptraced process, depending on whether the addr argument is
+ (void*)0 or (void*)1, respectively. */
+ PTRACE_GETDSBT = 31,
+#define PT_GETDSBT PTRACE_GETDSBT
+
+ /* Set ptrace filter options. */
+ PTRACE_SETOPTIONS = 0x4200,
+#define PT_SETOPTIONS PTRACE_SETOPTIONS
+
+ /* Get last ptrace message. */
+ PTRACE_GETEVENTMSG = 0x4201,
+#define PT_GETEVENTMSG PTRACE_GETEVENTMSG
+
+ /* Get siginfo for process. */
+ PTRACE_GETSIGINFO = 0x4202,
+#define PT_GETSIGINFO PTRACE_GETSIGINFO
+
+ /* Set new siginfo for process. */
+ PTRACE_SETSIGINFO = 0x4203
+#define PT_SETSIGINFO PTRACE_SETSIGINFO
+};
+
+#define PTRACE_GETDSBT_EXEC ((void*)0) /* [addr] request the executable loadmap */
+#define PTRACE_GETDSBT_INTERP ((void*)1) /* [addr] request the interpreter loadmap */
+
+/* Options set using PTRACE_SETOPTIONS. */
+enum __ptrace_setoptions {
+ PTRACE_O_TRACESYSGOOD = 0x00000001,
+ PTRACE_O_TRACEFORK = 0x00000002,
+ PTRACE_O_TRACEVFORK = 0x00000004,
+ PTRACE_O_TRACECLONE = 0x00000008,
+ PTRACE_O_TRACEEXEC = 0x00000010,
+ PTRACE_O_TRACEVFORKDONE = 0x00000020,
+ PTRACE_O_TRACEEXIT = 0x00000040,
+ PTRACE_O_MASK = 0x0000007f
+};
+
+/* Wait extended result codes for the above trace options. */
+enum __ptrace_eventcodes {
+ PTRACE_EVENT_FORK = 1,
+ PTRACE_EVENT_VFORK = 2,
+ PTRACE_EVENT_CLONE = 3,
+ PTRACE_EVENT_EXEC = 4,
+ PTRACE_EVENT_VFORK_DONE = 5,
+ PTRACE_EVENT_EXIT = 6
+};
+
+/* Perform process tracing functions. REQUEST is one of the values
+ above, and determines the action to be taken.
+ For all requests except PTRACE_TRACEME, PID specifies the process to be
+ traced.
+
+ PID and the other arguments described above for the various requests should
+ appear (those that are used for the particular request) as:
+ pid_t PID, void *ADDR, int DATA, void *ADDR2
+ after REQUEST. */
+extern long int ptrace (enum __ptrace_request __request, ...) __THROW;
+
+__END_DECLS
+
+#endif /* _SYS_PTRACE_H */
diff --git a/libc/sysdeps/linux/c6x/sys/reg.h b/libc/sysdeps/linux/c6x/sys/reg.h
new file mode 100644
index 000000000..46857ba71
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/sys/reg.h
@@ -0,0 +1,26 @@
+/*
+ * Port of uClibc for TMS320C6000 DSP architecture
+ * Copyright (C) 2004 Texas Instruments Incorporated
+ * Author of TMS320C6000 port: Aurelien Jacquiot
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Library General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+#ifndef _SYS_REG_H
+#define _SYS_REG_H 1
+
+#include <asm/ptrace.h>
+
+#endif /* _SYS_REG_H */
diff --git a/libc/sysdeps/linux/c6x/sys/ucontext.h b/libc/sysdeps/linux/c6x/sys/ucontext.h
new file mode 100644
index 000000000..9a3922a2e
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/sys/ucontext.h
@@ -0,0 +1,39 @@
+/* Copyright (C) 1997, 1999, 2001 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_UCONTEXT_H
+#define _SYS_UCONTEXT_H 1
+
+#include <features.h>
+#include <signal.h>
+#include <bits/sigcontext.h>
+
+/* A machine context is exactly a sigcontext. */
+typedef struct sigcontext mcontext_t;
+
+/* Userlevel context. */
+typedef struct ucontext
+{
+ unsigned long uc_flags;
+ struct ucontext *uc_link;
+ stack_t uc_stack;
+ mcontext_t uc_mcontext;
+ __sigset_t uc_sigmask;
+} ucontext_t;
+
+#endif /* sys/ucontext.h */
diff --git a/libc/sysdeps/linux/c6x/sys/user.h b/libc/sysdeps/linux/c6x/sys/user.h
new file mode 100644
index 000000000..8c0a99dd8
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/sys/user.h
@@ -0,0 +1,28 @@
+/* Copyright (C) 2010 Texas Instruments Incorporated
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_USER_H
+#define _SYS_USER_H 1
+
+/* The whole purpose of this file is for GDB and GDB only. Don't read
+ too much into it. Don't use it for anything other than GDB unless
+ you know what you are doing. */
+
+/* Left blank as a placeholder for now */
+
+#endif /* sys/user.h */
diff --git a/libc/sysdeps/linux/c6x/syscall.c b/libc/sysdeps/linux/c6x/syscall.c
new file mode 100644
index 000000000..ea947b28e
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/syscall.c
@@ -0,0 +1,49 @@
+/*
+ * syscall.c
+ *
+ * Port on Texas Instruments TMS320C6x architecture
+ *
+ * Copyright (C) 2006, 2010 Texas Instruments Incorporated
+ * Author: Thomas Charleux (thomas.charleux@jaluna.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <features.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/syscall.h>
+#include <unistd.h>
+#include <stdarg.h>
+
+long int syscall (long int __sysno, ...)
+{
+ register long no __asm__("B0");
+ register long a __asm__("A4");
+ register long b __asm__("B4");
+ register long c __asm__("A6");
+ register long d __asm__("B6");
+ register long e __asm__("A8");
+ register long f __asm__("B8");
+ long __res;
+ va_list ap;
+
+ va_start( ap, __sysno);
+ a = va_arg( ap, long);
+ b = va_arg( ap, long);
+ c = va_arg( ap, long);
+ d = va_arg( ap, long);
+ e = va_arg( ap, long);
+ f = va_arg( ap, long);
+ va_end( ap );
+
+ no = __sysno;
+
+ __asm__ __volatile__ ("SWE" : "=a" (a) : "a" (a), "b" (b), "a" (c), "b" (d), "a" (e), "b" (f), "b" (no)
+ : "memory", "cc");
+
+ __res = a;
+ __SYSCALL_RETURN (long);
+}
diff --git a/libc/sysdeps/linux/common/Makefile.in b/libc/sysdeps/linux/common/Makefile.in
index cf4cf8708..3f9791104 100644
--- a/libc/sysdeps/linux/common/Makefile.in
+++ b/libc/sysdeps/linux/common/Makefile.in
@@ -8,123 +8,69 @@
COMMON_DIR := $(top_srcdir)libc/sysdeps/linux/common
COMMON_OUT := $(top_builddir)libc/sysdeps/linux/common
-CSRC := $(notdir $(wildcard $(COMMON_DIR)/*.c))
+CSRC-y := $(notdir $(wildcard $(COMMON_DIR)/*.c))
+CSRC- := ssp-local.c
-ifneq ($(UCLIBC_HAS_LFS),y)
CSRC_LFS := $(notdir $(wildcard $(COMMON_DIR)/*64.c))
-CSRC := $(filter-out llseek.c $(CSRC_LFS),$(CSRC))
-endif
-
-CSRC := $(filter-out ssp-local.c,$(CSRC))
-ifneq ($(UCLIBC_HAS_SSP),y)
-CSRC := $(filter-out ssp.c,$(CSRC))
-endif
-
-ifneq ($(UCLIBC_LINUX_MODULE_24),y)
-CSRC := $(filter-out create_module.c query_module.c get_kernel_syms.c,$(CSRC))
-endif
+CSRC-y := $(filter-out llseek.c $(CSRC_LFS),$(CSRC-y))
+CSRC-$(UCLIBC_HAS_LFS) += llseek.c $(CSRC_LFS)
-ifneq ($(UCLIBC_LINUX_SPECIFIC),y)
+CSRC-$(if $(or $(UCLIBC_HAS_SSP),$(UCLIBC_HAS_FORTIFY)),y) += ssp.c
+CSRC-$(UCLIBC_LINUX_MODULE_24) += create_module.c query_module.c \
+ get_kernel_syms.c
# we need these internally: fstatfs.c statfs.c
-CSRC := $(filter-out capget.c capset.c inotify.c ioperm.c iopl.c \
+CSRC-$(UCLIBC_LINUX_SPECIFIC) += capget.c capset.c inotify.c ioperm.c iopl.c \
modify_ldt.c personality.c ppoll.c prctl.c readahead.c reboot.c \
remap_file_pages.c sched_getaffinity.c sched_setaffinity.c \
sendfile64.c sendfile.c setfsgid.c setfsuid.c setresuid.c \
splice.c vmsplice.c tee.c signalfd.c swapoff.c swapon.c \
- sync_file_range.c sysctl.c sysinfo.c timerfd.c uselib.c vhangup.c,$(CSRC))
-ifneq ($(UCLIBC_HAS_THREADS_NATIVE),y)
-# we need madvise.c in NPTL
-CSRC := $(filter-pout madvise.c,$(CSRC))
-endif
-endif
-
+ sync_file_range.c sysctl.c sysinfo.c timerfd.c uselib.c vhangup.c
+CSRC-$(if $(and $(UCLIBC_LINUX_SPECIFIC),$(UCLIBC_HAS_THREADS_NATIVE)),y) += madvise.c
ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
-CSRC := $(filter-out fork.c getpid.c raise.c open.c close.c read.c write.c, $(CSRC))
-ifeq ($(TARGET_ARCH),arm)
-CSRC := $(filter-out vfork.c, $(CSRC))
-else ifeq ($(TARGET_ARCH),x86_64)
-CSRC := $(filter-out vfork.c, $(CSRC))
-else ifeq ($(TARGET_ARCH),mips)
-ifeq ($(CONFIG_MIPS_O32_ABI),y)
-CSRC := $(filter-out waitpid.c, $(CSRC))
-endif
-else
-CSRC := $(filter-out waitpid.c, $(CSRC))
-endif
+CSRC- += fork.c getpid.c raise.c open.c close.c read.c write.c
+CSRC- += $(if $(findstring =arm=,=$(TARGET_ARCH)=),vfork.c)
+CSRC- += $(if $(findstring =x86_64=,=$(TARGET_ARCH)=),vfork.c)
+CSRC- += $(if $(findstring =mips=y=,=$(TARGET_ARCH)=$(CONFIG_MIPS_O32_ABI)=),waitpid.c)
endif
-
-ifneq ($(ARCH_USE_MMU),y)
# stubbed out in mman.h
-CSRC := $(filter-out msync.c, $(CSRC))
-endif
-
-ifneq ($(UCLIBC_BSD_SPECIFIC),y)
+CSRC-$(ARCH_USE_MMU) += msync.c
# we need these internally: getdomainname.c
-CSRC := $(filter-out mincore.c setdomainname.c,$(CSRC))
-endif
-
-ifneq ($(UCLIBC_NTP_LEGACY),y)
-CSRC := $(filter-out ntp_gettime.c,$(CSRC))
-endif
-
-
-ifneq ($(UCLIBC_HAS_REALTIME),y)
+CSRC-$(UCLIBC_BSD_SPECIFIC) += mincore.c setdomainname.c
+CSRC-$(UCLIBC_NTP_LEGACY) += ntp_gettime.c
# aio_cancel|aio_error|aio_fsync|aio_read|aio_return|aio_suspend|aio_write|clock_getres|clock_gettime|clock_settime|clock_settime|fdatasync|lio_listio|mlockall|munlockall|mlock|munlock|mq_close|mq_getattr|mq_notify|mq_open|mq_receive|mq_timedreceive|mq_send|mq_timedsend|mq_setattr|mq_unlink|nanosleep|sched_getparam|sched_get_priority_max|sched_get_priority_min|sched_getscheduler|sched_rr_get_interval|sched_setparam|sched_setscheduler|sem_close|sem_destroy|sem_getvalue|sem_init|sem_open|sem_post|sem_trywait|sem_wait|sem_unlink|sem_wait|shm_open|shm_unlink|sigqueue|sigtimedwait|sigwaitinfo|sigwaitinfo|timer_create|timer_delete|timer_getoverrun|timer_gettime|timer_settime
-CSRC := $(filter-out clock_getres.c clock_gettime.c clock_settime.c fdatasync.c Makefile.in mlockall.c mlock.c munlockall.c munlock.c nanosleep.c __rt_sigtimedwait.c sched_getparam.c sched_get_priority_max.c sched_get_priority_min.c sched_getscheduler.c sched_rr_get_interval.c sched_setparam.c sched_setscheduler.c sigqueue.c,$(CSRC))
-endif
-
-
-ifneq ($(UCLIBC_HAS_ADVANCED_REALTIME),y)
+CSRC-$(UCLIBC_HAS_REALTIME) += clock_getres.c clock_gettime.c clock_settime.c \
+ fdatasync.c mlockall.c mlock.c munlockall.c munlock.c \
+ nanosleep.c __rt_sigtimedwait.c sched_getparam.c \
+ sched_get_priority_max.c sched_get_priority_min.c sched_getscheduler.c \
+ sched_rr_get_interval.c sched_setparam.c sched_setscheduler.c sigqueue.c
# clock_getcpuclockid|clock_nanosleep|mq_timedreceive|mq_timedsend|posix_fadvise|posix_fallocate|posix_madvise|posix_memalign|posix_mem_offset|posix_spawnattr_destroy|posix_spawnattr_init|posix_spawnattr_getflags|posix_spawnattr_setflags|posix_spawnattr_getpgroup|posix_spawnattr_setpgroup|posix_spawnattr_getschedparam|posix_spawnattr_setschedparam|posix_spawnattr_getschedpolicy|posix_spawnattr_setschedpolicy|posix_spawnattr_getsigdefault|posix_spawnattr_setsigdefault|posix_spawnattr_getsigmask|posix_spawnattr_setsigmask|posix_spawnattr_init|posix_spawnattr_setflags|posix_spawnattr_setpgroup|posix_spawnattr_setschedparam|posix_spawnattr_setschedpolicy|posix_spawnattr_setsigdefault|posix_spawnattr_setsigmask|posix_spawn_file_actions_addclose|posix_spawn_file_actions_addopen|posix_spawn_file_actions_adddup2|posix_spawn_file_actions_addopen|posix_spawn_file_actions_destroy|posix_spawn_file_actions_init|posix_spawn_file_actions_init|posix_spawn|posix_spawnp|posix_spawnp|posix_typed_mem_get_info|pthread_mutex_timedlock|sem_timedwait
-CSRC := $(filter-out posix_fadvise64.c posix_fadvise.c,$(CSRC))
-endif
-
-ifneq ($(UCLIBC_SUSV4_LEGACY),y)
-CSRC := $(filter-out utime.c,$(CSRC))
-endif
-
-ifneq ($(UCLIBC_HAS_EPOLL),y)
-CSRC := $(filter-out epoll.c,$(CSRC))
-endif
-
-ifneq ($(UCLIBC_HAS_XATTR),y)
-CSRC := $(filter-out xattr.c,$(CSRC))
-endif
-
-ifneq ($(UCLIBC_HAS_PROFILING),y)
-CSRC := $(filter-out noophooks.c pcprofile.c,$(CSRC))
-endif
-
-ifneq ($(UCLIBC_SV4_DEPRECATED),y)
-CSRC := $(filter-out ustat.c,$(CSRC))
-endif
-
-ifeq ($(TARGET_ARCH),sh)
-CSRC := $(filter-out longjmp.c vfork.c,$(CSRC))
-endif
-
-ifeq ($(TARGET_ARCH),sparc)
-CSRC := $(filter-out vfork.c,$(CSRC))
-endif
-
-ifeq ($(TARGET_ARCH),i386)
-CSRC := $(filter-out vfork.c,$(CSRC))
-endif
+CSRC-$(UCLIBC_HAS_ADVANCED_REALTIME) += posix_fadvise64.c posix_fadvise.c
+CSRC-$(UCLIBC_SUSV4_LEGACY) += utime.c
+CSRC-$(UCLIBC_HAS_EPOLL) += epoll.c
+CSRC-$(UCLIBC_HAS_XATTR) += xattr.c
+CSRC-$(UCLIBC_HAS_PROFILING) += noophooks.c #pcprofile.c
+CSRC-$(UCLIBC_SV4_DEPRECATED) += ustat.c
+CSRC- += $(if $(findstring =c6x=,=$(TARGET_ARCH)=),vfork.c)
+CSRC- += $(if $(findstring =sh=,=$(TARGET_ARCH)=),longjmp.c vfork.c)
+CSRC- += $(if $(findstring =sparc=,=$(TARGET_ARCH)=),vfork.c)
+CSRC- += $(if $(findstring =i386=,=$(TARGET_ARCH)=),vfork.c)
+
+CSRC-y := $(filter-out $(CSRC-),$(CSRC-y))
# provided via pthreads builddir
-CSRC := $(filter-out $(libc_a_CSRC) $(notdir $(libpthread_libc_OBJS:.o=.c)),$(CSRC))
+CSRC-y := $(filter-out $(libc_a_CSRC) $(notdir $(libpthread_libc_OBJS:.o=.c)),$(CSRC-y))
SSRC := $(filter-out $(libc_a_SSRC) $(notdir $(libpthread_libc_OBJS:.o=.S)),$(SSRC))
# fails for some reason
ifneq ($(strip $(ARCH_OBJS)),)
-CSRC := $(filter-out $(notdir $(ARCH_OBJS:.o=.c)) $(ARCH_OBJ_FILTEROUT),$(CSRC))
+CSRC-y := $(filter-out $(notdir $(ARCH_OBJS:.o=.c)) $(ARCH_OBJ_FILTEROUT),$(CSRC-y))
endif
CFLAGS-ssp.c := $(SSP_DISABLE_FLAGS)
CFLAGS-ssp-local.c := $(SSP_DISABLE_FLAGS)
-COMMON_SRC := $(patsubst %.c,$(COMMON_DIR)/%.c,$(CSRC))
-COMMON_OBJ := $(patsubst %.c,$(COMMON_OUT)/%.o,$(CSRC))
+COMMON_SRC := $(patsubst %.c,$(COMMON_DIR)/%.c,$(CSRC-y))
+COMMON_OBJ := $(patsubst %.c,$(COMMON_OUT)/%.o,$(CSRC-y))
libc-y += $(COMMON_OBJ)
libc-static-$(UCLIBC_HAS_SSP) += $(COMMON_OUT)/ssp-local.o
diff --git a/libc/sysdeps/linux/common/__rt_sigtimedwait.c b/libc/sysdeps/linux/common/__rt_sigtimedwait.c
index a7ab8fb61..26860d2d2 100644
--- a/libc/sysdeps/linux/common/__rt_sigtimedwait.c
+++ b/libc/sysdeps/linux/common/__rt_sigtimedwait.c
@@ -86,16 +86,6 @@ int attribute_hidden __sigtimedwait(const sigset_t * set, siginfo_t * info,
return __rt_sigtimedwait(set, info, timeout, _NSIG / 8);
}
# endif /* !__UCLIBC_HAS_THREADS_NATIVE__ */
-#else
-int attribute_hidden __sigtimedwait(const sigset_t * set, siginfo_t * info,
- const struct timespec *timeout)
-{
- if (set == NULL)
- __set_errno(EINVAL);
- else
- __set_errno(ENOSYS);
- return -1;
-}
-#endif
weak_alias(__sigtimedwait,sigtimedwait)
libc_hidden_weak(sigtimedwait)
+#endif
diff --git a/libc/sysdeps/linux/common/__rt_sigwaitinfo.c b/libc/sysdeps/linux/common/__rt_sigwaitinfo.c
index 92a11c9b6..6b4332715 100644
--- a/libc/sysdeps/linux/common/__rt_sigwaitinfo.c
+++ b/libc/sysdeps/linux/common/__rt_sigwaitinfo.c
@@ -83,16 +83,7 @@ int attribute_hidden __sigwaitinfo(const sigset_t * set, siginfo_t * info)
return __rt_sigwaitinfo(set, info, NULL, _NSIG / 8);
}
# endif
-#else
-int attribute_hidden __sigwaitinfo(const sigset_t * set, siginfo_t * info)
-{
- if (set == NULL)
- __set_errno(EINVAL);
- else
- __set_errno(ENOSYS);
- return -1;
-}
-#endif
libc_hidden_proto(sigwaitinfo)
weak_alias (__sigwaitinfo, sigwaitinfo)
libc_hidden_weak(sigwaitinfo)
+#endif
diff --git a/libc/sysdeps/linux/common/__syscall_fcntl.c b/libc/sysdeps/linux/common/__syscall_fcntl.c
index 5da3c5f32..6d4c339ab 100644
--- a/libc/sysdeps/linux/common/__syscall_fcntl.c
+++ b/libc/sysdeps/linux/common/__syscall_fcntl.c
@@ -40,6 +40,7 @@ int __fcntl_nocancel (int fd, int cmd, ...)
# endif
return INLINE_SYSCALL (fcntl, 3, fd, cmd, arg);
}
+libc_hidden_def(__fcntl_nocancel)
int __libc_fcntl (int fd, int cmd, ...)
{
diff --git a/libc/sysdeps/linux/common/bdflush.c b/libc/sysdeps/linux/common/bdflush.c
index 687a8f9a7..c2a05ed88 100644
--- a/libc/sysdeps/linux/common/bdflush.c
+++ b/libc/sysdeps/linux/common/bdflush.c
@@ -12,10 +12,4 @@
#ifdef __NR_bdflush
_syscall2(int, bdflush, int, __func, long int, __data)
-#else
-int bdflush(int __func, long int __data)
-{
- __set_errno(ENOSYS);
- return -1;
-}
#endif
diff --git a/libc/sysdeps/linux/common/bits/sigstack.h b/libc/sysdeps/linux/common/bits/sigstack.h
index 7f260367b..2b3b321bd 100644
--- a/libc/sysdeps/linux/common/bits/sigstack.h
+++ b/libc/sysdeps/linux/common/bits/sigstack.h
@@ -22,12 +22,14 @@
#endif
+#if defined __UCLIBC_SUSV4_LEGACY__ || !defined __UCLIBC_STRICT_HEADERS__
/* Structure describing a signal stack (obsolete). */
struct sigstack
{
void *ss_sp; /* Signal stack pointer. */
int ss_onstack; /* Nonzero if executing on this stack. */
};
+#endif
/* Possible values for `ss_flags.'. */
diff --git a/libc/sysdeps/linux/common/bits/sigthread.h b/libc/sysdeps/linux/common/bits/sigthread.h
index 960bde18a..4f14b9f45 100644
--- a/libc/sysdeps/linux/common/bits/sigthread.h
+++ b/libc/sysdeps/linux/common/bits/sigthread.h
@@ -1,5 +1,5 @@
/* Signal handling function for threaded programs.
- Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2002, 2009 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
@@ -35,4 +35,10 @@ extern int pthread_sigmask (int __how,
/* Send signal SIGNO to the given thread. */
extern int pthread_kill (pthread_t __threadid, int __signo) __THROW;
+#if defined __USE_GNU && defined __UCLIBC_HAS_THREADS_NATIVE__
+/* Queue signal and data to a thread. */
+extern int pthread_sigqueue (pthread_t __threadid, int __signo,
+ const union sigval __value) __THROW;
+#endif
+
#endif /* bits/sigthread.h */
diff --git a/libc/sysdeps/linux/common/bits/socket.h b/libc/sysdeps/linux/common/bits/socket.h
index 11f6e9715..7e12733ae 100644
--- a/libc/sysdeps/linux/common/bits/socket.h
+++ b/libc/sysdeps/linux/common/bits/socket.h
@@ -98,8 +98,18 @@ enum __socket_type
#define PF_IRDA 23 /* IRDA sockets. */
#define PF_PPPOX 24 /* PPPoX sockets. */
#define PF_WANPIPE 25 /* Wanpipe API sockets. */
+#define PF_LLC 26 /* Linux LLC. */
+#define PF_CAN 29 /* Controller Area Network. */
+#define PF_TIPC 30 /* TIPC sockets. */
#define PF_BLUETOOTH 31 /* Bluetooth sockets. */
-#define PF_MAX 32 /* For now.. */
+#define PF_IUCV 32 /* IUCV sockets. */
+#define PF_RXRPC 33 /* RxRPC sockets. */
+#define PF_ISDN 34 /* mISDN sockets. */
+#define PF_PHONET 35 /* Phonet sockets. */
+#define PF_IEEE802154 36 /* IEEE 802.15.4 sockets. */
+#define PF_CAIF 37 /* CAIF sockets. */
+#define PF_ALG 38 /* Algorithm sockets. */
+#define PF_MAX 39 /* For now.. */
/* Address families. */
#define AF_UNSPEC PF_UNSPEC
@@ -130,7 +140,17 @@ enum __socket_type
#define AF_IRDA PF_IRDA
#define AF_PPPOX PF_PPPOX
#define AF_WANPIPE PF_WANPIPE
+#define AF_LLC PF_LLC
+#define AF_CAN PF_CAN
+#define AF_TIPC PF_TIPC
#define AF_BLUETOOTH PF_BLUETOOTH
+#define AF_IUCV PF_IUCV
+#define AF_RXRPC PF_RXRPC
+#define AF_ISDN PF_ISDN
+#define AF_PHONET PF_PHONET
+#define AF_IEEE802154 PF_IEEE802154
+#define AF_CAIF PF_CAIF
+#define AF_ALG PF_ALG
#define AF_MAX PF_MAX
/* Socket level values. Others are defined in the appropriate headers.
diff --git a/libc/sysdeps/linux/common/bits/statvfs.h b/libc/sysdeps/linux/common/bits/statvfs.h
index cca0871ac..84717c3d9 100644
--- a/libc/sysdeps/linux/common/bits/statvfs.h
+++ b/libc/sysdeps/linux/common/bits/statvfs.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 1998, 2000, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1997,1998,2000,2001,2002,2006 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
@@ -101,7 +101,9 @@ enum
# define ST_IMMUTABLE ST_IMMUTABLE
ST_NOATIME = 1024, /* Do not update access times. */
# define ST_NOATIME ST_NOATIME
- ST_NODIRATIME = 2048 /* Do not update directory access times. */
+ ST_NODIRATIME = 2048, /* Do not update directory access times. */
# define ST_NODIRATIME ST_NODIRATIME
+ ST_RELATIME = 4096 /* Update atime relative to mtime/ctime. */
+# define ST_RELATIME ST_RELATIME
#endif /* Use GNU. */
};
diff --git a/libc/sysdeps/linux/common/bits/syscalls-common.h b/libc/sysdeps/linux/common/bits/syscalls-common.h
index 5e4e350c5..1b84d9e2b 100644
--- a/libc/sysdeps/linux/common/bits/syscalls-common.h
+++ b/libc/sysdeps/linux/common/bits/syscalls-common.h
@@ -97,6 +97,7 @@ type name(C_DECL_ARGS_##nargs(args)) { \
}
#define _syscall0(args...) SYSCALL_FUNC(0, args)
+#define _syscall_noerr0(args...) SYSCALL_NOERR_FUNC(0, args)
#define _syscall1(args...) SYSCALL_FUNC(1, args)
#define _syscall_noerr1(args...) SYSCALL_NOERR_FUNC(1, args)
#define _syscall2(args...) SYSCALL_FUNC(2, args)
diff --git a/libc/sysdeps/linux/common/bits/types.h b/libc/sysdeps/linux/common/bits/types.h
index 24d0056fb..c4c10e2ff 100644
--- a/libc/sysdeps/linux/common/bits/types.h
+++ b/libc/sysdeps/linux/common/bits/types.h
@@ -200,11 +200,6 @@ __STD_TYPE __U32_TYPE __socklen_t;
#undef __STD_TYPE
-#ifdef _LIBC
-/* Used in `struct shmid_ds'. */
-typedef __kernel_ipc_pid_t __ipc_pid_t;
-#endif
-
/* Now add the thread types. */
#if defined __UCLIBC_HAS_THREADS__ && (defined __USE_POSIX199506 || defined __USE_UNIX98)
# include <bits/pthreadtypes.h>
diff --git a/libc/sysdeps/linux/common/bits/uClibc_ctype.h b/libc/sysdeps/linux/common/bits/uClibc_ctype.h
index 3bf4e1b28..5ff281d8e 100644
--- a/libc/sysdeps/linux/common/bits/uClibc_ctype.h
+++ b/libc/sysdeps/linux/common/bits/uClibc_ctype.h
@@ -95,7 +95,7 @@
/**********************************************************************/
__BEGIN_DECLS
-#if defined _LIBC && (defined NOT_IN_libc || defined IS_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)
diff --git a/libc/sysdeps/linux/common/bits/uClibc_errno.h b/libc/sysdeps/linux/common/bits/uClibc_errno.h
deleted file mode 100644
index 9c1561841..000000000
--- a/libc/sysdeps/linux/common/bits/uClibc_errno.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-#ifndef _BITS_UCLIBC_ERRNO_H
-#define _BITS_UCLIBC_ERRNO_H 1
-
-#ifdef IS_IN_rtld
-# undef errno
-# define errno _dl_errno
-extern int _dl_errno; /* attribute_hidden; */
-#elif defined __UCLIBC_HAS_THREADS__
-# include <tls.h>
-# if defined USE___THREAD && USE___THREAD
-# undef errno
-# ifndef NOT_IN_libc
-# define errno __libc_errno
-# else
-# define errno errno
-# endif
-extern __thread int errno attribute_tls_model_ie;
-# endif /* USE___THREAD */
-#endif /* IS_IN_rtld */
-
-#define __set_errno(val) (errno = (val))
-
-#ifndef __ASSEMBLER__
-extern int *__errno_location (void) __THROW __attribute__ ((__const__))
-# ifdef IS_IN_rtld
- attribute_hidden
-# endif
-;
-# if defined __UCLIBC_HAS_THREADS__
-# include <tls.h>
-# if defined USE___THREAD && USE___THREAD
-libc_hidden_proto(__errno_location)
-# endif
-# endif
-
-#endif /* !__ASSEMBLER__ */
-
-#endif
diff --git a/libc/sysdeps/linux/common/capget.c b/libc/sysdeps/linux/common/capget.c
index 361de845d..c3e8c5771 100644
--- a/libc/sysdeps/linux/common/capget.c
+++ b/libc/sysdeps/linux/common/capget.c
@@ -11,10 +11,4 @@
int capget(void *header, void *data);
#ifdef __NR_capget
_syscall2(int, capget, void *, header, void *, data)
-#else
-int capget(void *header, void *data)
-{
- __set_errno(ENOSYS);
- return -1;
-}
#endif
diff --git a/libc/sysdeps/linux/common/capset.c b/libc/sysdeps/linux/common/capset.c
index 0a77e05f4..c0cf5deb0 100644
--- a/libc/sysdeps/linux/common/capset.c
+++ b/libc/sysdeps/linux/common/capset.c
@@ -8,13 +8,8 @@
*/
#include <sys/syscall.h>
+
int capset(void *header, const void *data);
#ifdef __NR_capset
_syscall2(int, capset, void *, header, const void *, data)
-#elif defined __UCLIBC_HAS_STUBS__
-int capset(void *header, const void *data)
-{
- __set_errno(ENOSYS);
- return -1;
-}
#endif
diff --git a/libc/sysdeps/linux/common/create_module.c b/libc/sysdeps/linux/common/create_module.c
index d8f24466d..ddd7c4cff 100644
--- a/libc/sysdeps/linux/common/create_module.c
+++ b/libc/sysdeps/linux/common/create_module.c
@@ -49,11 +49,4 @@ unsigned long create_module(const char *name, size_t size)
_syscall2(unsigned long, create_module, const char *, name, size_t, size)
#endif
-#else /* !__NR_create_module */
-caddr_t create_module(const char *name attribute_unused, size_t size attribute_unused);
-caddr_t create_module(const char *name attribute_unused, size_t size attribute_unused)
-{
- __set_errno(ENOSYS);
- return (caddr_t)-1;
-}
#endif
diff --git a/libc/sysdeps/linux/common/delete_module.c b/libc/sysdeps/linux/common/delete_module.c
index 44f9b30ae..8ac6e559e 100644
--- a/libc/sysdeps/linux/common/delete_module.c
+++ b/libc/sysdeps/linux/common/delete_module.c
@@ -10,10 +10,4 @@
int delete_module(const char *name, unsigned int flags);
#ifdef __NR_delete_module
_syscall2(int, delete_module, const char *, name, unsigned int, flags)
-#elif defined __UCLIBC_HAS_STUBS__
-int delete_module(const char *name, unsigned int flags)
-{
- __set_errno(ENOSYS);
- return -1;
-}
#endif
diff --git a/libc/sysdeps/linux/common/epoll.c b/libc/sysdeps/linux/common/epoll.c
index 86272d9aa..dda92282e 100644
--- a/libc/sysdeps/linux/common/epoll.c
+++ b/libc/sysdeps/linux/common/epoll.c
@@ -15,12 +15,6 @@
*/
#ifdef __NR_epoll_create
_syscall1(int, epoll_create, int, size)
-#else
-int epoll_create(int size)
-{
- __set_errno(ENOSYS);
- return -1;
-}
#endif
/*
@@ -28,12 +22,6 @@ int epoll_create(int size)
*/
#ifdef __NR_epoll_ctl
_syscall4(int,epoll_ctl, int, epfd, int, op, int, fd, struct epoll_event *, event)
-#else
-int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event)
-{
- __set_errno(ENOSYS);
- return -1;
-}
#endif
/*
@@ -41,10 +29,4 @@ int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event)
*/
#ifdef __NR_epoll_wait
_syscall4(int, epoll_wait, int, epfd, struct epoll_event *, events, int, maxevents, int, timeout)
-#else
-int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout)
-{
- __set_errno(ENOSYS);
- return -1;
-}
#endif
diff --git a/libc/sysdeps/linux/common/fdatasync.c b/libc/sysdeps/linux/common/fdatasync.c
index 19d37b6e0..e51c72365 100644
--- a/libc/sysdeps/linux/common/fdatasync.c
+++ b/libc/sysdeps/linux/common/fdatasync.c
@@ -40,11 +40,4 @@ int fdatasync(int fd)
# endif
}
-#elif defined __UCLIBC_HAS_STUBS__
-/* no syscall available, so provide a stub */
-int fdatasync(int fd)
-{
- __set_errno(ENOSYS);
- return -1;
-}
#endif
diff --git a/libc/sysdeps/linux/common/fork.c b/libc/sysdeps/linux/common/fork.c
index f21ec35b8..14e00a2cd 100644
--- a/libc/sysdeps/linux/common/fork.c
+++ b/libc/sysdeps/linux/common/fork.c
@@ -20,16 +20,4 @@ weak_alias(__libc_fork,fork)
libc_hidden_weak(fork)
#endif
-#elif defined __UCLIBC_HAS_STUBS__
-
-extern __typeof(fork) __libc_fork;
-pid_t __libc_fork(void)
-{
- __set_errno(ENOSYS);
- return -1;
-}
-weak_alias(__libc_fork,fork)
-libc_hidden_weak(fork)
-link_warning(fork, "fork: this function is not implemented on no-mmu systems")
-
#endif
diff --git a/libc/sysdeps/linux/common/get_kernel_syms.c b/libc/sysdeps/linux/common/get_kernel_syms.c
index d6595eaf5..6124a81d4 100644
--- a/libc/sysdeps/linux/common/get_kernel_syms.c
+++ b/libc/sysdeps/linux/common/get_kernel_syms.c
@@ -13,10 +13,4 @@ struct kernel_sym;
int get_kernel_syms(struct kernel_sym *table attribute_unused);
#ifdef __NR_get_kernel_syms
_syscall1(int, get_kernel_syms, struct kernel_sym *, table)
-#else
-int get_kernel_syms(struct kernel_sym *table attribute_unused)
-{
- __set_errno(ENOSYS);
- return -1;
-}
#endif
diff --git a/libc/sysdeps/linux/common/getegid.c b/libc/sysdeps/linux/common/getegid.c
index f2b6401cf..80a8ac9bb 100644
--- a/libc/sysdeps/linux/common/getegid.c
+++ b/libc/sysdeps/linux/common/getegid.c
@@ -10,24 +10,12 @@
#include <sys/syscall.h>
#include <unistd.h>
-
-#if defined(__NR_getegid32)
+#ifdef __NR_getegid32
# undef __NR_getegid
# define __NR_getegid __NR_getegid32
-_syscall0(gid_t, getegid)
-
-#elif defined(__NR_getegid)
-# define __NR___syscall_getegid __NR_getegid
-static __inline__ _syscall0(int, __syscall_getegid)
-gid_t getegid(void)
-{
- return (__syscall_getegid());
-}
-#else
-
-gid_t getegid(void)
-{
- return (getgid());
-}
#endif
+
+#ifdef __NR_getegid
+_syscall_noerr0(gid_t, getegid)
libc_hidden_def(getegid)
+#endif
diff --git a/libc/sysdeps/linux/common/geteuid.c b/libc/sysdeps/linux/common/geteuid.c
index 6111e5d1b..610fbc170 100644
--- a/libc/sysdeps/linux/common/geteuid.c
+++ b/libc/sysdeps/linux/common/geteuid.c
@@ -10,25 +10,12 @@
#include <sys/syscall.h>
#include <unistd.h>
-
-#if defined(__NR_geteuid32)
+#ifdef __NR_geteuid32
# undef __NR_geteuid
# define __NR_geteuid __NR_geteuid32
-_syscall0(uid_t, geteuid)
-
-#elif defined(__NR_geteuid)
-# define __NR___syscall_geteuid __NR_geteuid
-static __inline__ _syscall0(int, __syscall_geteuid)
-uid_t geteuid(void)
-{
- return (__syscall_geteuid());
-}
-
-#else
-uid_t geteuid(void)
-{
- return (getuid());
-}
#endif
+#ifdef __NR_geteuid
+_syscall_noerr0(uid_t, geteuid)
libc_hidden_def(geteuid)
+#endif
diff --git a/libc/sysdeps/linux/common/getgid.c b/libc/sysdeps/linux/common/getgid.c
index 80c60034e..ccfbfc067 100644
--- a/libc/sysdeps/linux/common/getgid.c
+++ b/libc/sysdeps/linux/common/getgid.c
@@ -10,7 +10,7 @@
#include <sys/syscall.h>
#include <unistd.h>
-#if defined __NR_getxgid
+#ifdef __NR_getxgid
# undef __NR_getgid
# define __NR_getgid __NR_getxgid
#endif
@@ -19,5 +19,9 @@
# define __NR_getgid __NR_getgid32
#endif
-_syscall0(gid_t, getgid)
+_syscall_noerr0(gid_t, getgid)
libc_hidden_def(getgid)
+#if !defined __NR_getegid32 && !defined __NR_getegid
+strong_alias(getgid,getegid)
+libc_hidden_def(getegid)
+#endif
diff --git a/libc/sysdeps/linux/common/getpgrp.c b/libc/sysdeps/linux/common/getpgrp.c
index 5d36ba155..0af9dc499 100644
--- a/libc/sysdeps/linux/common/getpgrp.c
+++ b/libc/sysdeps/linux/common/getpgrp.c
@@ -12,17 +12,11 @@
#ifdef __NR_getpgrp
/* According to the manpage the POSIX.1 version is favoured */
-_syscall0(pid_t, getpgrp)
+_syscall_noerr0(pid_t, getpgrp)
#elif defined __NR_getpgid && (defined __NR_getpid || defined __NR_getxpid)
/* IA64 doesn't have a getpgrp syscall */
pid_t getpgrp(void)
{
return getpgid(getpid());
}
-#elif defined __UCLIBC_HAS_STUBS__
-pid_t getpgrp(void)
-{
- __set_errno(ENOSYS);
- return -1;
-}
#endif
diff --git a/libc/sysdeps/linux/common/getpid.c b/libc/sysdeps/linux/common/getpid.c
index 8041022e7..d9a69084f 100644
--- a/libc/sysdeps/linux/common/getpid.c
+++ b/libc/sysdeps/linux/common/getpid.c
@@ -10,11 +10,13 @@
#include <sys/syscall.h>
#include <unistd.h>
-extern __typeof(getpid) __libc_getpid;
-#if defined __NR_getxpid
+#ifdef __NR_getxpid
+# undef __NR_getpid
# define __NR_getpid __NR_getxpid
#endif
-#define __NR___libc_getpid __NR_getpid
-_syscall0(pid_t, __libc_getpid)
-weak_alias(__libc_getpid, getpid)
+
+_syscall_noerr0(pid_t, getpid)
libc_hidden_weak(getpid)
+#ifndef __NR_getppid
+strong_alias(getpid,getppid)
+#endif
diff --git a/libc/sysdeps/linux/common/getppid.c b/libc/sysdeps/linux/common/getppid.c
index 4f2b0e933..9d85661d9 100644
--- a/libc/sysdeps/linux/common/getppid.c
+++ b/libc/sysdeps/linux/common/getppid.c
@@ -9,11 +9,7 @@
#include <sys/syscall.h>
#include <unistd.h>
+
#ifdef __NR_getppid
-_syscall0(pid_t, getppid)
-#else
-pid_t getppid(void)
-{
- return getpid();
-}
+_syscall_noerr0(pid_t, getppid)
#endif
diff --git a/libc/sysdeps/linux/common/getuid.c b/libc/sysdeps/linux/common/getuid.c
index b6f813a06..f921acb2e 100644
--- a/libc/sysdeps/linux/common/getuid.c
+++ b/libc/sysdeps/linux/common/getuid.c
@@ -10,7 +10,7 @@
#include <sys/syscall.h>
#include <unistd.h>
-#if defined __NR_getxuid
+#ifdef __NR_getxuid
# undef __NR_getuid
# define __NR_getuid __NR_getxuid
#endif
@@ -19,5 +19,9 @@
# define __NR_getuid __NR_getuid32
#endif
-_syscall0(uid_t, getuid)
+_syscall_noerr0(uid_t, getuid)
libc_hidden_def(getuid)
+#if !defined __NR_geteuid32 && !defined __NR_geteuid
+strong_alias(getuid,geteuid)
+libc_hidden_def(geteuid)
+#endif
diff --git a/libc/sysdeps/linux/common/init_module.c b/libc/sysdeps/linux/common/init_module.c
index 8a6e94199..cf6d74721 100644
--- a/libc/sysdeps/linux/common/init_module.c
+++ b/libc/sysdeps/linux/common/init_module.c
@@ -15,11 +15,5 @@ int init_module(void *first, void *second, void *third, void *fourth, void *fift
* and let the kernel cope with whatever it gets. It's good at that. */
_syscall5(int, init_module, void *, first, void *, second, void *, third,
void *, fourth, void *, fifth)
-#else
-int init_module(void *first, void *second, void *third, void *fourth, void *fifth)
-{
- __set_errno(ENOSYS);
- return -1;
-}
#endif
diff --git a/libc/sysdeps/linux/common/longjmp.c b/libc/sysdeps/linux/common/longjmp.c
index 4d1442414..b07eced6a 100644
--- a/libc/sysdeps/linux/common/longjmp.c
+++ b/libc/sysdeps/linux/common/longjmp.c
@@ -24,6 +24,10 @@
extern void __longjmp (__jmp_buf __env, int __val) attribute_noreturn;
libc_hidden_proto(__longjmp)
+#if 0
+extern void _longjmp_unwind (jmp_buf env, int val);
+#endif
+
extern __typeof(longjmp) __libc_longjmp attribute_noreturn;
/* Set the signal mask to the one specified in ENV, and jump
to the position specified in ENV, causing the setjmp
diff --git a/libc/sysdeps/linux/common/lutimes.c b/libc/sysdeps/linux/common/lutimes.c
index 0b4a8ea45..e01d40efd 100644
--- a/libc/sysdeps/linux/common/lutimes.c
+++ b/libc/sysdeps/linux/common/lutimes.c
@@ -12,7 +12,7 @@
#ifdef __NR_lutimes
_syscall2(int, lutimes, const char *, file, const struct timeval *, tvp)
-#else
+#elif defined __NR_utimensat
#include <sys/time.h>
#include <fcntl.h>
diff --git a/libc/sysdeps/linux/common/nanosleep.c b/libc/sysdeps/linux/common/nanosleep.c
index 0be59c511..26ce4a6c5 100644
--- a/libc/sysdeps/linux/common/nanosleep.c
+++ b/libc/sysdeps/linux/common/nanosleep.c
@@ -36,6 +36,5 @@ int __libc_nanosleep(const struct timespec *req, struct timespec *rem)
#endif
}
-libc_hidden_proto(nanosleep)
weak_alias(__libc_nanosleep,nanosleep)
libc_hidden_weak(nanosleep)
diff --git a/libc/sysdeps/linux/common/pivot_root.c b/libc/sysdeps/linux/common/pivot_root.c
index 3e9705903..0e738d53f 100644
--- a/libc/sysdeps/linux/common/pivot_root.c
+++ b/libc/sysdeps/linux/common/pivot_root.c
@@ -12,10 +12,4 @@
int pivot_root(const char *new_root, const char *put_old);
#ifdef __NR_pivot_root
_syscall2(int, pivot_root, const char *, new_root, const char *, put_old)
-#else
-int pivot_root(const char *new_root, const char *put_old)
-{
- __set_errno(ENOSYS);
- return -1;
-}
#endif
diff --git a/libc/sysdeps/linux/common/posix_fadvise.c b/libc/sysdeps/linux/common/posix_fadvise.c
index 7c43be959..17831c201 100644
--- a/libc/sysdeps/linux/common/posix_fadvise.c
+++ b/libc/sysdeps/linux/common/posix_fadvise.c
@@ -27,10 +27,9 @@ int posix_fadvise(int fd, off_t offset, off_t len, int advice)
strong_alias(posix_fadvise,posix_fadvise64)
#endif
-#else
+#elif defined __UCLIBC_HAS_STUBS__
int posix_fadvise(int fd attribute_unused, off_t offset attribute_unused, off_t len attribute_unused, int advice attribute_unused)
{
-#warning This is not correct as far as SUSv3 is concerned.
return ENOSYS;
}
#endif
diff --git a/libc/sysdeps/linux/common/posix_fadvise64.c b/libc/sysdeps/linux/common/posix_fadvise64.c
index b53e64321..e8a530fdf 100644
--- a/libc/sysdeps/linux/common/posix_fadvise64.c
+++ b/libc/sysdeps/linux/common/posix_fadvise64.c
@@ -58,13 +58,12 @@ int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advice)
#error your machine is neither 32 bit or 64 bit ... it must be magical
#endif
-#elif !defined __NR_fadvise64
+#elif !defined __NR_fadvise64 && defined __UCLIBC_HAS_STUBS__
/* This is declared as a strong alias in posix_fadvise.c if __NR_fadvise64
* is defined.
*/
int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advice)
{
-#warning This is not correct as far as SUSv3 is concerned.
return ENOSYS;
}
#endif /* __NR_fadvise64_64 */
diff --git a/libc/sysdeps/linux/common/query_module.c b/libc/sysdeps/linux/common/query_module.c
index 0f3d4700c..7c168df45 100644
--- a/libc/sysdeps/linux/common/query_module.c
+++ b/libc/sysdeps/linux/common/query_module.c
@@ -13,11 +13,4 @@ int query_module(const char *name attribute_unused, int which attribute_unused,
#ifdef __NR_query_module
_syscall5(int, query_module, const char *, name, int, which,
void *, buf, size_t, bufsize, size_t *, ret)
-#elif defined __UCLIBC_HAS_STUBS__
-int query_module(const char *name attribute_unused, int which attribute_unused,
- void *buf attribute_unused, size_t bufsize attribute_unused, size_t * ret attribute_unused)
-{
- __set_errno(ENOSYS);
- return -1;
-}
#endif
diff --git a/libc/sysdeps/linux/common/sched_getaffinity.c b/libc/sysdeps/linux/common/sched_getaffinity.c
index 5d5e5b2c4..8982582cc 100644
--- a/libc/sysdeps/linux/common/sched_getaffinity.c
+++ b/libc/sysdeps/linux/common/sched_getaffinity.c
@@ -44,11 +44,5 @@ int sched_getaffinity(pid_t pid, size_t cpusetsize, cpu_set_t *cpuset)
}
return res;
}
-#elif defined __UCLIBC_HAS_STUBS__
-int sched_getaffinity(pid_t pid, size_t cpusetsize, cpu_set_t *cpuset)
-{
- __set_errno(ENOSYS);
- return -1;
-}
#endif
#endif
diff --git a/libc/sysdeps/linux/common/sched_setaffinity.c b/libc/sysdeps/linux/common/sched_setaffinity.c
index 1a0f55f75..980c44199 100644
--- a/libc/sysdeps/linux/common/sched_setaffinity.c
+++ b/libc/sysdeps/linux/common/sched_setaffinity.c
@@ -70,16 +70,5 @@ int sched_setaffinity(pid_t pid, size_t cpusetsize, const cpu_set_t *cpuset)
return INLINE_SYSCALL (sched_setaffinity, 3, pid, cpusetsize, cpuset);
}
-#else
-#define ___HAVE_NO_sched_setaffinity
#endif
-
-#if defined ___HAVE_NO_sched_setaffinity && defined __UCLIBC_HAS_STUBS__
-int sched_setaffinity(pid_t pid, size_t cpusetsize, const cpu_set_t *cpuset)
-{
- __set_errno(ENOSYS);
- return -1;
-}
-#endif
-
#endif /* __USE_GNU */
diff --git a/libc/sysdeps/linux/common/signalfd.c b/libc/sysdeps/linux/common/signalfd.c
index 3d76e04c4..a0c995a89 100644
--- a/libc/sysdeps/linux/common/signalfd.c
+++ b/libc/sysdeps/linux/common/signalfd.c
@@ -21,8 +21,7 @@ static __inline__ _syscall3(int, __syscall_signalfd, int, fd,
const sigset_t *, mask, size_t, sizemask)
#endif
-#if defined __NR_signalfd4 || defined __NR_signalfd \
- || defined __UCLIBC_HAS_STUBS__
+#if defined __NR_signalfd4 || defined __NR_signalfd
int signalfd (int fd, const sigset_t *mask, int flags)
{
#if defined __NR___syscall_signalfd4
@@ -33,9 +32,6 @@ int signalfd (int fd, const sigset_t *mask, int flags)
return -1;
}
return __syscall_signalfd(fd, mask, _NSIG / 8);
-#elif defined __UCLIBC_HAS_STUBS__
- __set_errno(ENOSYS);
- return -1;
#endif
}
#endif
diff --git a/libc/sysdeps/linux/common/sigsuspend.c b/libc/sysdeps/linux/common/sigsuspend.c
index 789eeda89..ded2aad5b 100644
--- a/libc/sysdeps/linux/common/sigsuspend.c
+++ b/libc/sysdeps/linux/common/sigsuspend.c
@@ -38,7 +38,7 @@ int sigsuspend (const sigset_t *set)
return result;
}
# else
-static inline _syscall2(int, __rt_sigsuspend, const sigset_t *, mask, size_t, size);
+static inline _syscall2(int, __rt_sigsuspend, const sigset_t *, mask, size_t, size)
int sigsuspend(const sigset_t * mask)
{
diff --git a/libc/sysdeps/linux/common/splice.c b/libc/sysdeps/linux/common/splice.c
index b21d10336..83f348a48 100644
--- a/libc/sysdeps/linux/common/splice.c
+++ b/libc/sysdeps/linux/common/splice.c
@@ -13,11 +13,4 @@
#ifdef __NR_splice
_syscall6(ssize_t, splice, int, __fdin, __off64_t *, __offin, int, __fdout,
__off64_t *, __offout, size_t, __len, unsigned int, __flags)
-#else
-ssize_t splice(int __fdin, __off64_t *__offin, int __fdout,
- __off64_t *__offout, size_t __len, unsigned int __flags)
-{
- __set_errno(ENOSYS);
- return -1;
-}
#endif
diff --git a/libc/sysdeps/linux/common/ssp.c b/libc/sysdeps/linux/common/ssp.c
index a2d7ff2ca..df242cc69 100644
--- a/libc/sysdeps/linux/common/ssp.c
+++ b/libc/sysdeps/linux/common/ssp.c
@@ -71,6 +71,7 @@ static attribute_noreturn void terminate(void)
_exit(127);
}
+#ifdef __UCLIBC_HAS_SSP_COMPAT__
void __stack_smash_handler(char func[], int damaged __attribute__ ((unused))) attribute_noreturn __cold;
void __stack_smash_handler(char func[], int damaged)
{
@@ -84,7 +85,9 @@ void __stack_smash_handler(char func[], int damaged)
while(1)
terminate();
}
+#endif
+#ifdef __UCLIBC_HAS_SSP__
void __stack_chk_fail(void) attribute_noreturn __cold;
void __stack_chk_fail(void)
{
@@ -99,8 +102,9 @@ void __stack_chk_fail(void)
while(1)
terminate();
}
+#endif
-void __chk_fail(void) attribute_noreturn;
+#ifdef __UCLIBC_HAS_FORTIFY__
void __chk_fail(void)
{
static const char msg1[] = "buffer overflow detected: ";
@@ -114,4 +118,5 @@ void __chk_fail(void)
while(1)
terminate();
}
-
+libc_hidden_def(__chk_fail)
+#endif
diff --git a/libc/sysdeps/linux/common/stubs.c b/libc/sysdeps/linux/common/stubs.c
new file mode 100644
index 000000000..655c64001
--- /dev/null
+++ b/libc/sysdeps/linux/common/stubs.c
@@ -0,0 +1,187 @@
+/*
+ * system call not available stub
+ *
+ * Copyright (C) 2009 Analog Devices Inc.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <errno.h>
+#include <sys/syscall.h>
+
+#ifdef __UCLIBC_HAS_STUBS__
+
+static int enosys_stub(void)
+{
+ __set_errno(ENOSYS);
+ return -1;
+}
+
+#define make_stub(stub) \
+ link_warning(stub, #stub ": this function is not implemented") \
+ strong_alias(enosys_stub, stub)
+
+#ifndef __ARCH_USE_MMU__
+# undef __NR_fork
+#endif
+
+#ifndef __UCLIBC_HAS_LFS__
+# undef __NR_fadvise64
+# undef __NR_fadvise64_64
+# undef __NR_sync_file_range
+#endif
+
+#ifndef __NR_bdflush
+make_stub(bdflush)
+#endif
+
+#ifndef __NR_capget
+make_stub(capget)
+#endif
+
+#ifndef __NR_capset
+make_stub(capset)
+#endif
+
+#ifndef __NR_create_module
+make_stub(create_module)
+#endif
+
+#ifndef __NR_delete_module
+make_stub(delete_module)
+#endif
+
+#ifndef __NR_epoll_create
+make_stub(epoll_create)
+#endif
+
+#ifndef __NR_epoll_ctl
+make_stub(epoll_ctl)
+#endif
+
+#ifndef __NR_epoll_wait
+make_stub(epoll_wait)
+#endif
+
+#ifndef __NR_fdatasync
+make_stub(fdatasync)
+#endif
+
+#ifndef __NR_flistxattr
+make_stub(flistxattr)
+#endif
+
+#ifndef __NR_fork
+make_stub(fork)
+#endif
+
+#ifndef __NR_fgetxattr
+make_stub(fgetxattr)
+#endif
+
+#ifndef __NR_fremovexattr
+make_stub(fremovexattr)
+#endif
+
+#ifndef __NR_fsetxattr
+make_stub(fsetxattr)
+#endif
+
+#ifndef __NR_get_kernel_syms
+make_stub(get_kernel_syms)
+#endif
+
+#if !defined(__NR_getpgrp) && (defined(__NR_getpgid) && (defined(__NR_getpid) || defined(__NR_getxpid)))
+make_stub(getpgrp)
+#endif
+
+#ifndef __NR_getxattr
+make_stub(getxattr)
+#endif
+
+#ifndef __NR_init_module
+make_stub(init_module)
+#endif
+
+#ifndef __NR_lgetxattr
+make_stub(lgetxattr)
+#endif
+
+#ifndef __NR_listxattr
+make_stub(listxattr)
+#endif
+
+#ifndef __NR_llistxattr
+make_stub(llistxattr)
+#endif
+
+#ifndef __NR_lremovexattr
+make_stub(lremovexattr)
+#endif
+
+#ifndef __NR_lsetxattr
+make_stub(lsetxattr)
+#endif
+
+#ifndef __NR_pivot_root
+make_stub(pivot_root)
+#endif
+
+#ifndef __NR_query_module
+make_stub(query_module)
+#endif
+
+#ifndef __NR_removexattr
+make_stub(removexattr)
+#endif
+
+#ifndef __NR_sched_getaffinity
+make_stub(sched_getaffinity)
+#endif
+
+#ifndef __NR_sched_setaffinity
+make_stub(sched_setaffinity)
+#endif
+
+#ifndef __NR_setxattr
+make_stub(setxattr)
+#endif
+
+#if !defined(__NR_signalfd4) && !defined(__NR_signalfd)
+make_stub(signalfd)
+#endif
+
+#ifndef __NR_rt_sigtimedwait
+make_stub(sigtimedwait)
+make_stub(sigwaitinfo)
+#endif
+
+#ifndef __NR_splice
+make_stub(splice)
+#endif
+
+#ifndef __NR_sync_file_range
+make_stub(sync_file_range)
+#endif
+
+#if !defined(__NR_umount) && !defined(__NR_umount2)
+make_stub(umount)
+#endif
+
+#ifndef __NR_umount2
+make_stub(umount2)
+#endif
+
+#ifndef __NR_utimensat
+make_stub(futimens)
+make_stub(utimensat)
+# ifndef __NR_lutimes
+make_stub(lutimes)
+# endif
+#endif
+
+#ifndef __NR_vmsplice
+make_stub(vmsplice)
+#endif
+
+#endif
diff --git a/libc/sysdeps/linux/common/sync_file_range.c b/libc/sysdeps/linux/common/sync_file_range.c
index 7e2deff41..d24403e1b 100644
--- a/libc/sysdeps/linux/common/sync_file_range.c
+++ b/libc/sysdeps/linux/common/sync_file_range.c
@@ -23,11 +23,5 @@ int sync_file_range(int fd, off64_t offset, off64_t nbytes, unsigned int flags)
__LONG_LONG_PAIR((long)(nbytes >> 32), (long)(nbytes & 0xffffffff)),
flags);
}
-#elif defined __UCLIBC_HAS_STUBS__
-int sync_file_range(int fd, __off64_t offset, __off64_t nbytes, unsigned int flags)
-{
- __set_errno(ENOSYS);
- return -1;
-}
#endif
#endif
diff --git a/libc/sysdeps/linux/common/sysdep.h b/libc/sysdeps/linux/common/sysdep.h
index a7ec95480..156e5711a 100644
--- a/libc/sysdeps/linux/common/sysdep.h
+++ b/libc/sysdeps/linux/common/sysdep.h
@@ -51,6 +51,7 @@
/* Macros to generate eh_frame unwind information. */
# ifdef HAVE_ASM_CFI_DIRECTIVES
+# define cfi_sections(sect...) .cfi_sections sect
# define cfi_startproc .cfi_startproc
# define cfi_endproc .cfi_endproc
# define cfi_def_cfa(reg, off) .cfi_def_cfa reg, off
@@ -71,6 +72,7 @@
# define cfi_lsda(enc, exp) .cfi_lsda enc, exp
# else
+# define cfi_sections(sect...)
# define cfi_startproc
# define cfi_endproc
# define cfi_def_cfa(reg, off)
@@ -95,6 +97,8 @@
# ifdef HAVE_ASM_CFI_DIRECTIVES
# define CFI_STRINGIFY(Name) CFI_STRINGIFY2 (Name)
# define CFI_STRINGIFY2(Name) #Name
+# define CFI_SECTIONS(sect...) \
+ ".cfi_sections " CFI_STRINGIFY(sect)
# define CFI_STARTPROC ".cfi_startproc"
# define CFI_ENDPROC ".cfi_endproc"
# define CFI_DEF_CFA(reg, off) \
@@ -128,6 +132,7 @@
# define CFI_LSDA(enc, exp) \
".cfi_lsda " CFI_STRINGIFY(enc) "," CFI_STRINGIFY(exp)
# else
+# define CFI_SECTIONS(sect...)
# define CFI_STARTPROC
# define CFI_ENDPROC
# define CFI_DEF_CFA(reg, off)
diff --git a/libc/sysdeps/linux/common/umask.c b/libc/sysdeps/linux/common/umask.c
index ef9860e31..b838e1731 100644
--- a/libc/sysdeps/linux/common/umask.c
+++ b/libc/sysdeps/linux/common/umask.c
@@ -15,5 +15,5 @@ static __inline__ _syscall1(__kernel_mode_t, __syscall_umask, __kernel_mode_t, m
mode_t umask(mode_t mode)
{
- return (__syscall_umask(mode));
+ return __syscall_umask(mode);
}
diff --git a/libc/sysdeps/linux/common/umount.c b/libc/sysdeps/linux/common/umount.c
index 453ecd27b..a084d29bd 100644
--- a/libc/sysdeps/linux/common/umount.c
+++ b/libc/sysdeps/linux/common/umount.c
@@ -28,14 +28,5 @@ int umount(const char *special_file)
return (__syscall_umount2(special_file, 0));
}
-/* arch doesn't provide any umount syscall !? */
-#else
-
-int umount(const char *special_file)
-{
- __set_errno(ENOSYS);
- return -1;
-}
-
#endif
#endif
diff --git a/libc/sysdeps/linux/common/umount2.c b/libc/sysdeps/linux/common/umount2.c
index bd44717d4..2cc4a2338 100644
--- a/libc/sysdeps/linux/common/umount2.c
+++ b/libc/sysdeps/linux/common/umount2.c
@@ -13,11 +13,5 @@
#include <sys/mount.h>
#ifdef __NR_umount2 /* Old kernels don't have umount2 */
_syscall2(int, umount2, const char *, special_file, int, flags)
-#else
-int umount2(const char *special_file, int flags)
-{
- __set_errno(ENOSYS);
- return -1;
-}
#endif
#endif
diff --git a/libc/sysdeps/linux/common/vmsplice.c b/libc/sysdeps/linux/common/vmsplice.c
index c5fd6c7ed..dd0640e1e 100644
--- a/libc/sysdeps/linux/common/vmsplice.c
+++ b/libc/sysdeps/linux/common/vmsplice.c
@@ -13,11 +13,4 @@
#ifdef __NR_vmsplice
_syscall4(ssize_t, vmsplice, int, __fdout, const struct iovec *, __iov,
size_t, __count, unsigned int, __flags)
-#else
-ssize_t vmsplice(int __fdout, const struct iovec *__iov, size_t __count,
- unsigned int __flags)
-{
- __set_errno(ENOSYS);
- return -1;
-}
#endif
diff --git a/libc/sysdeps/linux/common/xattr.c b/libc/sysdeps/linux/common/xattr.c
index 8a4e3be29..dea471ad6 100644
--- a/libc/sysdeps/linux/common/xattr.c
+++ b/libc/sysdeps/linux/common/xattr.c
@@ -29,136 +29,58 @@
#ifdef __NR_setxattr
_syscall5(int, setxattr, const char *, path, const char *, name,
const void *, value, size_t, size, int, flags)
-#else
-int setxattr(__const char *__path, __const char *__name,
- __const void *__value, size_t __size, int __flags)
-{
- __set_errno(ENOSYS);
- return -1;
-}
#endif
#ifdef __NR_lsetxattr
_syscall5(int, lsetxattr, const char *, path, const char *, name,
const void *, value, size_t, size, int, flags)
-#else
-int lsetxattr(__const char *__path, __const char *__name,
- __const void *__value, size_t __size, int __flags)
-{
- __set_errno(ENOSYS);
- return -1;
-}
#endif
#ifdef __NR_fsetxattr
_syscall5(int, fsetxattr, int, filedes, const char *, name, const void *,
value, size_t, size, int, flags)
-#else
-int fsetxattr(int __fd, __const char *__name, __const void *__value,
- size_t __size, int __flags)
-{
- __set_errno(ENOSYS);
- return -1;
-}
#endif
/* gets */
#ifdef __NR_getxattr
_syscall4(ssize_t, getxattr, const char *, path, const char *, name,
void *, value, size_t, size)
-#else
-ssize_t getxattr(__const char *__path, __const char *__name, void *__value,
- size_t __size)
-{
- __set_errno(ENOSYS);
- return -1;
-}
#endif
#ifdef __NR_lgetxattr
_syscall4(ssize_t, lgetxattr, const char *, path, const char *, name,
void *, value, size_t, size)
-#else
-ssize_t lgetxattr(__const char *__path, __const char *__name,
- void *__value, size_t __size)
-{
- __set_errno(ENOSYS);
- return -1;
-}
#endif
#ifdef __NR_fgetxattr
_syscall4(ssize_t, fgetxattr, int, filedes, const char *, name, void *,
value, size_t, size)
-#else
-ssize_t fgetxattr(int __fd, __const char *__name, void *__value,
- size_t __size)
-{
- __set_errno(ENOSYS);
- return -1;
-}
#endif
/* list */
#ifdef __NR_listxattr
_syscall3(ssize_t, listxattr, const char *, path, char *, list, size_t,
size)
-#else
-ssize_t listxattr(__const char *__path, char *__list, size_t __size)
-{
- __set_errno(ENOSYS);
- return -1;
-}
#endif
#ifdef __NR_llistxattr
_syscall3(ssize_t, llistxattr, const char *, path, char *, list, size_t,
size)
-#else
-ssize_t llistxattr(__const char *__path, char *__list, size_t __size)
-{
- __set_errno(ENOSYS);
- return -1;
-}
#endif
#ifdef __NR_flistxattr
_syscall3(ssize_t, flistxattr, int, filedes, char *, list, size_t, size)
-#else
-ssize_t flistxattr(int __fd, char *__list, size_t __size)
-{
- __set_errno(ENOSYS);
- return -1;
-}
#endif
/* remove */
#ifdef __NR_removexattr
_syscall2(int, removexattr, const char *, path, const char *, name)
-#else
-int removexattr(__const char *__path, __const char *__name)
-{
- __set_errno(ENOSYS);
- return -1;
-}
#endif
#ifdef __NR_lremovexattr
_syscall2(int, lremovexattr, const char *, path, const char *, name)
-#else
-int lremovexattr(__const char *__path, __const char *__name)
-{
- __set_errno(ENOSYS);
- return -1;
-}
#endif
#ifdef __NR_fremovexattr
_syscall2(int, fremovexattr, int, filedes, const char *, name)
-#else
-int fremovexattr(int __fd, __const char *__name)
-{
- __set_errno(ENOSYS);
- return -1;
-}
#endif
diff --git a/libc/sysdeps/linux/cris/Makefile.arch b/libc/sysdeps/linux/cris/Makefile.arch
index 43e191205..8a682b0b6 100644
--- a/libc/sysdeps/linux/cris/Makefile.arch
+++ b/libc/sysdeps/linux/cris/Makefile.arch
@@ -7,7 +7,7 @@
CSRC := __init_brk.c brk.c sbrk.c
-SSRC := setjmp.S __longjmp.S clone.S sysdep.S syscall.S
+SSRC := setjmp.S __longjmp.S clone.S sysdep.S syscall.S vfork.S
ifeq ($(UNIFIED_SYSCALL),y)
SSRC += __uClibc_syscall.S
endif
diff --git a/libc/sysdeps/linux/cris/bits/kernel_stat.h b/libc/sysdeps/linux/cris/bits/kernel_stat.h
index b54f29210..619f35e9e 100644
--- a/libc/sysdeps/linux/cris/bits/kernel_stat.h
+++ b/libc/sysdeps/linux/cris/bits/kernel_stat.h
@@ -1,11 +1,7 @@
/* Taken from linux/include/asm-cris/stat.h */
-#ifndef _CRIS_STAT_H
-#define _CRIS_STAT_H
-
-#ifndef _LIBC
-#error bits/kernel_stat.h is for internal uClibc use only!
-#endif
+#ifndef _BITS_STAT_STRUCT_H
+#define _BITS_STAT_STRUCT_H
struct kernel_stat {
unsigned short st_dev;
diff --git a/libc/sysdeps/linux/cris/vfork.S b/libc/sysdeps/linux/cris/vfork.S
new file mode 100644
index 000000000..ea8a81d82
--- /dev/null
+++ b/libc/sysdeps/linux/cris/vfork.S
@@ -0,0 +1,30 @@
+/*-
+ * Copyright (c) 2011
+ * Thorsten Glaser <tg@freewrt.org>
+ *
+ * This file is available either under the terms and conditions of
+ * the MirOS Licence, or the same terms as klibc or uClibc.
+ */
+
+#include "sysdep.h"
+
+ .syntax no_register_prefix
+
+/*
+ * vfork is special, but PSEUDO() would probably work were it not broken;
+ * there must be nothing at all on the stack above the stack frame of the
+ * enclosing function
+ */
+
+ENTRY(__vfork)
+ movu.w __NR_vfork,$r9
+ break 13
+ cmps.w -4096,$r10
+ bhs 0f
+ nop
+ Ret
+ nop
+PSEUDO_END(__vfork)
+
+weak_alias(__vfork,vfork)
+libc_hidden_weak(vfork)
diff --git a/libc/sysdeps/linux/e1/bits/kernel_stat.h b/libc/sysdeps/linux/e1/bits/kernel_stat.h
index 2b432cf52..99a6cba97 100644
--- a/libc/sysdeps/linux/e1/bits/kernel_stat.h
+++ b/libc/sysdeps/linux/e1/bits/kernel_stat.h
@@ -1,10 +1,6 @@
#ifndef _BITS_STAT_STRUCT_H
#define _BITS_STAT_STRUCT_H
-#ifndef _LIBC
-#error bits/kernel_stat.h is for internal uClibc use only!
-#endif
-
/* This file provides whatever this particular arch's kernel thinks
* struct kernel_stat should look like... It turns out each arch has a
* different opinion on the subject... */
diff --git a/libc/sysdeps/linux/frv/bits/kernel_stat.h b/libc/sysdeps/linux/frv/bits/kernel_stat.h
index 634066df6..1cf521044 100644
--- a/libc/sysdeps/linux/frv/bits/kernel_stat.h
+++ b/libc/sysdeps/linux/frv/bits/kernel_stat.h
@@ -1,10 +1,6 @@
#ifndef _BITS_STAT_STRUCT_H
#define _BITS_STAT_STRUCT_H
-#ifndef _LIBC
-#error bits/kernel_stat.h is for internal uClibc use only!
-#endif
-
/* This file provides whatever this particular arch's kernel thinks
* struct kernel_stat should look like... It turns out each arch has a
* different opinion on the subject... */
diff --git a/libc/sysdeps/linux/h8300/bits/kernel_stat.h b/libc/sysdeps/linux/h8300/bits/kernel_stat.h
index 2b95465b7..5f6c8ae50 100644
--- a/libc/sysdeps/linux/h8300/bits/kernel_stat.h
+++ b/libc/sysdeps/linux/h8300/bits/kernel_stat.h
@@ -1,10 +1,6 @@
#ifndef _BITS_STAT_STRUCT_H
#define _BITS_STAT_STRUCT_H
-#ifndef _LIBC
-#error bits/kernel_stat.h is for internal uClibc use only!
-#endif
-
/* This file provides whatever this particular arch's kernel thinks
* struct kernel_stat should look like... It turns out each arch has a
* different opinion on the subject... */
diff --git a/libc/sysdeps/linux/hppa/bits/atomic.h b/libc/sysdeps/linux/hppa/bits/atomic.h
new file mode 100644
index 000000000..87aeb84a0
--- /dev/null
+++ b/libc/sysdeps/linux/hppa/bits/atomic.h
@@ -0,0 +1,103 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Carlos O'Donell <carlos@baldric.uwo.ca>, 2005.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stdint.h>
+#include <bits/kernel-features.h>
+
+#define ABORT_INSTRUCTION __asm__(__UCLIBC_ABORT_INSTRUCTION__)
+
+/* We need EFAULT, ENOSYS */
+#if !defined EFAULT && !defined ENOSYS
+#define EFAULT 14
+#define ENOSYS 251
+#endif
+
+#ifndef _BITS_ATOMIC_H
+#define _BITS_ATOMIC_H 1
+
+typedef int8_t atomic8_t;
+typedef uint8_t uatomic8_t;
+typedef int_fast8_t atomic_fast8_t;
+typedef uint_fast8_t uatomic_fast8_t;
+
+typedef int32_t atomic32_t;
+typedef uint32_t uatomic32_t;
+typedef int_fast32_t atomic_fast32_t;
+typedef uint_fast32_t uatomic_fast32_t;
+
+typedef intptr_t atomicptr_t;
+typedef uintptr_t uatomicptr_t;
+typedef intmax_t atomic_max_t;
+typedef uintmax_t uatomic_max_t;
+
+/* prev = *addr;
+ if (prev == old)
+ *addr = new;
+ return prev; */
+
+/* Use the kernel atomic light weight syscalls on hppa */
+#define LWS "0xb0"
+#define LWS_CAS "0"
+/* Note r31 is the link register */
+#define LWS_CLOBBER "r1", "r26", "r25", "r24", "r23", "r22", "r21", "r20", "r28", "r31", "memory"
+#define ASM_EAGAIN "11"
+
+#if __ASSUME_LWS_CAS
+/* The only basic operation needed is compare and exchange. */
+# define atomic_compare_and_exchange_val_acq(mem, newval, oldval) \
+ ({ \
+ volatile int lws_errno = EFAULT; \
+ volatile int lws_ret = 0xdeadbeef; \
+ __asm__ volatile( \
+ "0: \n\t" \
+ "copy %3, %%r26 \n\t" \
+ "copy %4, %%r25 \n\t" \
+ "copy %5, %%r24 \n\t" \
+ "ble " LWS "(%%sr2, %%r0) \n\t" \
+ "ldi " LWS_CAS ", %%r20 \n\t" \
+ "cmpib,=,n " ASM_EAGAIN ",%%r21,0b \n\t" \
+ "nop \n\t" \
+ "stw %%r28, %0 \n\t" \
+ "sub %%r0, %%r21, %%r21 \n\t" \
+ "stw %%r21, %1 \n\t" \
+ : "=m" (lws_ret), "=m" (lws_errno), "=m" (*mem) \
+ : "r" (mem), "r" (oldval), "r" (newval) \
+ : LWS_CLOBBER \
+ ); \
+ \
+ if(lws_errno == EFAULT || lws_errno == ENOSYS) \
+ ABORT_INSTRUCTION; \
+ \
+ lws_ret; \
+ })
+
+# define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \
+ ({ \
+ int ret; \
+ ret = atomic_compare_and_exchange_val_acq(mem, newval, oldval); \
+ /* Return 1 if it was already acquired */ \
+ (ret != oldval); \
+ })
+#else
+# error __ASSUME_LWS_CAS is required to build uClibc.
+#endif
+/* __ASSUME_LWS_CAS */
+
+#endif
+/* _BITS_ATOMIC_H */
diff --git a/libc/sysdeps/linux/hppa/bits/kernel_stat.h b/libc/sysdeps/linux/hppa/bits/kernel_stat.h
index d33a7e720..097abfb40 100644
--- a/libc/sysdeps/linux/hppa/bits/kernel_stat.h
+++ b/libc/sysdeps/linux/hppa/bits/kernel_stat.h
@@ -1,12 +1,8 @@
/* Ripped from linux/include/asm-parisc/stat.h
* and renamed 'struct stat' to 'struct kernel_stat' */
-#ifndef _PARISC_STAT_H
-#define _PARISC_STAT_H
-
-#ifndef _LIBC
-#error bits/kernel_stat.h is for internal uClibc use only!
-#endif
+#ifndef _BITS_STAT_STRUCT_H
+#define _BITS_STAT_STRUCT_H
struct kernel_stat {
unsigned int st_dev; /* dev_t is 32 bits on parisc */
diff --git a/libc/sysdeps/linux/i386/bits/kernel_stat.h b/libc/sysdeps/linux/i386/bits/kernel_stat.h
index decbeb915..231a984b4 100644
--- a/libc/sysdeps/linux/i386/bits/kernel_stat.h
+++ b/libc/sysdeps/linux/i386/bits/kernel_stat.h
@@ -1,10 +1,6 @@
#ifndef _BITS_STAT_STRUCT_H
#define _BITS_STAT_STRUCT_H
-#ifndef _LIBC
-#error bits/kernel_stat.h is for internal uClibc use only!
-#endif
-
/* This file provides whatever this particular arch's kernel thinks
* struct stat should look like... It turns out each arch has a
* different opinion on the subject... */
diff --git a/libc/sysdeps/linux/i386/bits/syscalls.h b/libc/sysdeps/linux/i386/bits/syscalls.h
index 9184bd6c3..eeafb3a48 100644
--- a/libc/sysdeps/linux/i386/bits/syscalls.h
+++ b/libc/sysdeps/linux/i386/bits/syscalls.h
@@ -43,9 +43,12 @@
/* We need some help from the assembler to generate optimal code.
* We define some macros here which later will be used. */
+/* gcc>=4.6 with LTO need the same guards as IMA (a.k.a --combine) did.
+ * See gcc.gnu.org/PR47577 */
+/* FIXME: drop these b* macros! */
__asm__ (
-#ifdef __DOMULTI__
+#if defined __DOMULTI__ || __GNUC_PREREQ (4, 6)
/* Protect against asm macro redefinition (happens in __DOMULTI__ mode).
* Unfortunately, it ends up visible in .o files. */
".ifndef _BITS_SYSCALLS_ASM\n\t"
@@ -92,7 +95,7 @@ __asm__ (
".endif\n\t"
".endm\n\t"
-#ifdef __DOMULTI__
+#if defined __DOMULTI__ || __GNUC_PREREQ (4, 6)
".endif\n\t" /* _BITS_SYSCALLS_ASM */
#endif
);
diff --git a/libc/sysdeps/linux/i386/posix_fadvise64.S b/libc/sysdeps/linux/i386/posix_fadvise64.S
index 17f006aa8..b4aeff1f4 100644
--- a/libc/sysdeps/linux/i386/posix_fadvise64.S
+++ b/libc/sysdeps/linux/i386/posix_fadvise64.S
@@ -22,6 +22,8 @@
#include <bits/errno.h>
#include <sys/syscall.h>
+#if defined __NR_fadvise64_64
+
/* Was named __libc_posix_fadvise64 for some inexplicable reason.
** google says only uclibc has *__libc*_posix_fadviseXXX,
** so it cannot be compat with anything.
@@ -33,7 +35,6 @@
.global posix_fadvise64
.type posix_fadvise64,%function
posix_fadvise64:
-#if defined __NR_fadvise64_64
/* Save regs */
pushl %ebp
pushl %ebx
@@ -91,10 +92,6 @@ overflow:
/* Returns 0 on success, else an error code. */
negl %eax
-#elif defined __UCLIBC_HAS_STUBS__
- movl $-ENOSYS, %eax
- jmp __syscall_error
-#endif
/* Successful; return the syscall's value. */
ret
@@ -106,3 +103,5 @@ overflow:
** weak_alias(__libc_posix_fadvise64,posix_fadvise64)
** #endif
*/
+
+#endif
diff --git a/libc/sysdeps/linux/ia64/bits/kernel_stat.h b/libc/sysdeps/linux/ia64/bits/kernel_stat.h
index 5af7e93a8..28abc4bf5 100644
--- a/libc/sysdeps/linux/ia64/bits/kernel_stat.h
+++ b/libc/sysdeps/linux/ia64/bits/kernel_stat.h
@@ -1,12 +1,8 @@
/* Ripped from linux/include/asm-ia64/stat.h
* and renamed 'struct stat' to 'struct kernel_stat' */
-#ifndef _ASM_IA64_STAT_H
-#define _ASM_IA64_STAT_H
-
-#ifndef _LIBC
-#error bits/kernel_stat.h is for internal uClibc use only!
-#endif
+#ifndef _BITS_STAT_STRUCT_H
+#define _BITS_STAT_STRUCT_H
/*
* Modified 1998, 1999
@@ -34,4 +30,4 @@ struct kernel_stat {
/* ia64 stat64 is same as stat */
#define kernel_stat64 kernel_stat
-#endif /* _ASM_IA64_STAT_H */
+#endif /* _BITS_STAT_STRUCT_H */
diff --git a/libc/sysdeps/linux/ia64/bits/sigstack.h b/libc/sysdeps/linux/ia64/bits/sigstack.h
index c9c9d2fed..ea27a77bc 100644
--- a/libc/sysdeps/linux/ia64/bits/sigstack.h
+++ b/libc/sysdeps/linux/ia64/bits/sigstack.h
@@ -24,12 +24,14 @@
#ifndef _SIGSTACK_H
#define _SIGSTACK_H 1
+#if defined __UCLIBC_SUSV4_LEGACY__ || !defined __UCLIBC_STRICT_HEADERS__
/* Structure describing a signal stack (obsolete). */
struct sigstack
{
__ptr_t ss_sp; /* Signal stack pointer. */
int ss_onstack; /* Nonzero if executing on this stack. */
};
+#endif
/* Possible values for `ss_flags.'. */
diff --git a/libc/sysdeps/linux/m68k/bits/kernel_stat.h b/libc/sysdeps/linux/m68k/bits/kernel_stat.h
index 4cb06cc97..3911c9bbf 100644
--- a/libc/sysdeps/linux/m68k/bits/kernel_stat.h
+++ b/libc/sysdeps/linux/m68k/bits/kernel_stat.h
@@ -1,10 +1,6 @@
#ifndef _BITS_STAT_STRUCT_H
#define _BITS_STAT_STRUCT_H
-#ifndef _LIBC
-#error bits/kernel_stat.h is for internal uClibc use only!
-#endif
-
/* This file provides whatever this particular arch's kernel thinks
* struct kernel_stat should look like... It turns out each arch has a
* different opinion on the subject... */
diff --git a/libc/sysdeps/linux/microblaze/bits/kernel_stat.h b/libc/sysdeps/linux/microblaze/bits/kernel_stat.h
index 2c5eb28af..c2695098d 100644
--- a/libc/sysdeps/linux/microblaze/bits/kernel_stat.h
+++ b/libc/sysdeps/linux/microblaze/bits/kernel_stat.h
@@ -3,10 +3,6 @@
#ifndef _BITS_STAT_STRUCT_H
#define _BITS_STAT_STRUCT_H
-#ifndef _LIBC
-#error bits/kernel_stat.h is for internal uClibc use only!
-#endif
-
struct kernel_stat
{
unsigned long st_dev; /* Device. */
diff --git a/libc/sysdeps/linux/mips/bits/kernel_stat.h b/libc/sysdeps/linux/mips/bits/kernel_stat.h
index dc3565acc..655c089e0 100644
--- a/libc/sysdeps/linux/mips/bits/kernel_stat.h
+++ b/libc/sysdeps/linux/mips/bits/kernel_stat.h
@@ -1,10 +1,6 @@
#ifndef _BITS_STAT_STRUCT_H
#define _BITS_STAT_STRUCT_H
-#ifndef _LIBC
-#error bits/kernel_stat.h is for internal uClibc use only!
-#endif
-
/* This file provides whatever this particular arch's kernel thinks
* struct kernel_stat should look like... It turns out each arch has a
* different opinion on the subject... */
diff --git a/libc/sysdeps/linux/mips/bits/sigstack.h b/libc/sysdeps/linux/mips/bits/sigstack.h
index d2c855220..64643d1c5 100644
--- a/libc/sysdeps/linux/mips/bits/sigstack.h
+++ b/libc/sysdeps/linux/mips/bits/sigstack.h
@@ -22,12 +22,14 @@
#endif
+#if defined __UCLIBC_SUSV4_LEGACY__ || !defined __UCLIBC_STRICT_HEADERS__
/* Structure describing a signal stack (obsolete). */
struct sigstack
{
void *ss_sp; /* Signal stack pointer. */
int ss_onstack; /* Nonzero if executing on this stack. */
};
+#endif
/* Possible values for `ss_flags.'. */
diff --git a/libc/sysdeps/linux/mips/bits/socket.h b/libc/sysdeps/linux/mips/bits/socket.h
index b46e7be28..27ceafafe 100644
--- a/libc/sysdeps/linux/mips/bits/socket.h
+++ b/libc/sysdeps/linux/mips/bits/socket.h
@@ -100,8 +100,18 @@ enum __socket_type
#define PF_IRDA 23 /* IRDA sockets. */
#define PF_PPPOX 24 /* PPPoX sockets. */
#define PF_WANPIPE 25 /* Wanpipe API sockets. */
+#define PF_LLC 26 /* Linux LLC. */
+#define PF_CAN 29 /* Controller Area Network. */
+#define PF_TIPC 30 /* TIPC sockets. */
#define PF_BLUETOOTH 31 /* Bluetooth sockets. */
-#define PF_MAX 32 /* For now.. */
+#define PF_IUCV 32 /* IUCV sockets. */
+#define PF_RXRPC 33 /* RxRPC sockets. */
+#define PF_ISDN 34 /* mISDN sockets. */
+#define PF_PHONET 35 /* Phonet sockets. */
+#define PF_IEEE802154 36 /* IEEE 802.15.4 sockets. */
+#define PF_CAIF 37 /* CAIF sockets. */
+#define PF_ALG 38 /* Algorithm sockets. */
+#define PF_MAX 39 /* For now.. */
/* Address families. */
#define AF_UNSPEC PF_UNSPEC
@@ -132,7 +142,17 @@ enum __socket_type
#define AF_IRDA PF_IRDA
#define AF_PPPOX PF_PPPOX
#define AF_WANPIPE PF_WANPIPE
+#define AF_LLC PF_LLC
+#define AF_CAN PF_CAN
+#define AF_TIPC PF_TIPC
#define AF_BLUETOOTH PF_BLUETOOTH
+#define AF_IUCV PF_IUCV
+#define AF_RXRPC PF_RXRPC
+#define AF_ISDN PF_ISDN
+#define AF_PHONET PF_PHONET
+#define AF_IEEE802154 PF_IEEE802154
+#define AF_CAIF PF_CAIF
+#define AF_ALG PF_ALG
#define AF_MAX PF_MAX
/* Socket level values. Others are defined in the appropriate headers.
diff --git a/libc/sysdeps/linux/nios2/bits/kernel_stat.h b/libc/sysdeps/linux/nios2/bits/kernel_stat.h
index 2b432cf52..99a6cba97 100644
--- a/libc/sysdeps/linux/nios2/bits/kernel_stat.h
+++ b/libc/sysdeps/linux/nios2/bits/kernel_stat.h
@@ -1,10 +1,6 @@
#ifndef _BITS_STAT_STRUCT_H
#define _BITS_STAT_STRUCT_H
-#ifndef _LIBC
-#error bits/kernel_stat.h is for internal uClibc use only!
-#endif
-
/* This file provides whatever this particular arch's kernel thinks
* struct kernel_stat should look like... It turns out each arch has a
* different opinion on the subject... */
diff --git a/libc/sysdeps/linux/nios2/bits/kernel_types.h b/libc/sysdeps/linux/nios2/bits/kernel_types.h
index 3fcd1af05..8b86d796f 100644
--- a/libc/sysdeps/linux/nios2/bits/kernel_types.h
+++ b/libc/sysdeps/linux/nios2/bits/kernel_types.h
@@ -4,8 +4,8 @@
* our private content, and not the kernel header, will win.
* -Erik
*/
-#ifndef __ARCH_NIOS2_POSIX_TYPES_H
-#define __ARCH_NIOS2_POSIX_TYPES_H
+#ifndef _ASM_NIOS2_POSIX_TYPES_H
+#define _ASM_NIOS2_POSIX_TYPES_H
typedef unsigned long __kernel_dev_t;
typedef unsigned long __kernel_ino_t;
@@ -41,4 +41,4 @@ typedef struct {
#endif
} __kernel_fsid_t;
-#endif /* __ARCH_NIOS2_POSIX_TYPES_H */
+#endif /* _ASM_NIOS2_POSIX_TYPES_H */
diff --git a/libc/sysdeps/linux/powerpc/bits/kernel_stat.h b/libc/sysdeps/linux/powerpc/bits/kernel_stat.h
index d8a9bc2e2..579b5b4e2 100644
--- a/libc/sysdeps/linux/powerpc/bits/kernel_stat.h
+++ b/libc/sysdeps/linux/powerpc/bits/kernel_stat.h
@@ -1,10 +1,6 @@
#ifndef _BITS_STAT_STRUCT_H
#define _BITS_STAT_STRUCT_H
-#ifndef _LIBC
-#error bits/kernel_stat.h is for internal uClibc use only!
-#endif
-
/* This file provides whatever this particular arch's kernel thinks
* struct kernel_stat should look like... It turns out each arch has a
* different opinion on the subject... */
diff --git a/libc/sysdeps/linux/powerpc/bits/termios.h b/libc/sysdeps/linux/powerpc/bits/termios.h
index 7aac02dc5..12513e3ea 100644
--- a/libc/sysdeps/linux/powerpc/bits/termios.h
+++ b/libc/sysdeps/linux/powerpc/bits/termios.h
@@ -220,6 +220,7 @@ struct termios {
#define TCSADRAIN 1
#define TCSAFLUSH 2
+#ifndef __UCLIBC_STRICT_HEADERS__
struct sgttyb {
char sg_ispeed;
char sg_ospeed;
@@ -227,6 +228,7 @@ struct sgttyb {
char sg_kill;
short sg_flags;
};
+#endif
struct tchars {
char t_intrc;
diff --git a/libc/sysdeps/linux/sh/bits/kernel_stat.h b/libc/sysdeps/linux/sh/bits/kernel_stat.h
index 8e6ffb498..5b51b3cd3 100644
--- a/libc/sysdeps/linux/sh/bits/kernel_stat.h
+++ b/libc/sysdeps/linux/sh/bits/kernel_stat.h
@@ -1,10 +1,6 @@
#ifndef _BITS_STAT_STRUCT_H
#define _BITS_STAT_STRUCT_H
-#ifndef _LIBC
-#error bits/kernel_stat.h is for internal uClibc use only!
-#endif
-
/* This file provides whatever this particular arch's kernel thinks
* struct kernel_stat should look like... It turns out each arch has a
* different opinion on the subject... */
diff --git a/libc/sysdeps/linux/sh64/bits/kernel_stat.h b/libc/sysdeps/linux/sh64/bits/kernel_stat.h
index 57c16f473..1a29433e1 100644
--- a/libc/sysdeps/linux/sh64/bits/kernel_stat.h
+++ b/libc/sysdeps/linux/sh64/bits/kernel_stat.h
@@ -3,10 +3,6 @@
#ifndef _BITS_STAT_STRUCT_H
#define _BITS_STAT_STRUCT_H
-#ifndef _LIBC
-#error bits/kernel_stat.h is for internal uClibc use only!
-#endif
-
struct kernel_stat {
unsigned short st_dev;
unsigned short __pad1;
diff --git a/libc/sysdeps/linux/sparc/bits/kernel_stat.h b/libc/sysdeps/linux/sparc/bits/kernel_stat.h
index a9b5b534f..f09ae3734 100644
--- a/libc/sysdeps/linux/sparc/bits/kernel_stat.h
+++ b/libc/sysdeps/linux/sparc/bits/kernel_stat.h
@@ -1,10 +1,6 @@
#ifndef _BITS_STAT_STRUCT_H
#define _BITS_STAT_STRUCT_H
-#ifndef _LIBC
-#error bits/kernel_stat.h is for internal uClibc use only!
-#endif
-
/* This file provides whatever this particular arch's kernel thinks
* struct kernel_stat should look like... It turns out each arch has a
* different opinion on the subject... */
diff --git a/libc/sysdeps/linux/sparc/bits/sigstack.h b/libc/sysdeps/linux/sparc/bits/sigstack.h
index df4653949..432ec83b7 100644
--- a/libc/sysdeps/linux/sparc/bits/sigstack.h
+++ b/libc/sysdeps/linux/sparc/bits/sigstack.h
@@ -22,12 +22,14 @@
#endif
+#if defined __UCLIBC_SUSV4_LEGACY__ || !defined __STRICT_HEADERS__
/* Structure describing a signal stack (obsolete). */
struct sigstack
{
void *ss_sp; /* Signal stack pointer. */
int ss_onstack; /* Nonzero if executing on this stack. */
};
+#endif
/* Possible values for `ss_flags.'. */
diff --git a/libc/sysdeps/linux/sparc/bits/socket.h b/libc/sysdeps/linux/sparc/bits/socket.h
index e41527fd3..64973e2cf 100644
--- a/libc/sysdeps/linux/sparc/bits/socket.h
+++ b/libc/sysdeps/linux/sparc/bits/socket.h
@@ -88,8 +88,18 @@ enum __socket_type
#define PF_IRDA 23 /* IRDA sockets. */
#define PF_PPPOX 24 /* PPPoX sockets. */
#define PF_WANPIPE 25 /* Wanpipe API sockets. */
+#define PF_LLC 26 /* Linux LLC. */
+#define PF_CAN 29 /* Controller Area Network. */
+#define PF_TIPC 30 /* TIPC sockets. */
#define PF_BLUETOOTH 31 /* Bluetooth sockets. */
-#define PF_MAX 32 /* For now.. */
+#define PF_IUCV 32 /* IUCV sockets. */
+#define PF_RXRPC 33 /* RxRPC sockets. */
+#define PF_ISDN 34 /* mISDN sockets. */
+#define PF_PHONET 35 /* Phonet sockets. */
+#define PF_IEEE802154 36 /* IEEE 802.15.4 sockets. */
+#define PF_CAIF 37 /* CAIF sockets. */
+#define PF_ALG 38 /* Algorithm sockets. */
+#define PF_MAX 39 /* For now.. */
/* Address families. */
#define AF_UNSPEC PF_UNSPEC
@@ -120,7 +130,17 @@ enum __socket_type
#define AF_IRDA PF_IRDA
#define AF_PPPOX PF_PPPOX
#define AF_WANPIPE PF_WANPIPE
+#define AF_LLC PF_LLC
+#define AF_CAN PF_CAN
+#define AF_TIPC PF_TIPC
#define AF_BLUETOOTH PF_BLUETOOTH
+#define AF_IUCV PF_IUCV
+#define AF_RXRPC PF_RXRPC
+#define AF_ISDN PF_ISDN
+#define AF_PHONET PF_PHONET
+#define AF_IEEE802154 PF_IEEE802154
+#define AF_CAIF PF_CAIF
+#define AF_ALG PF_ALG
#define AF_MAX PF_MAX
/* Socket level values. Others are defined in the appropriate headers.
diff --git a/libc/sysdeps/linux/sparc/bits/statvfs.h b/libc/sysdeps/linux/sparc/bits/statvfs.h
deleted file mode 100644
index 3dafcebf0..000000000
--- a/libc/sysdeps/linux/sparc/bits/statvfs.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/* Copyright (C) 1997, 1998, 2000, 2001 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
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#ifndef _SYS_STATVFS_H
-# error "Never include <bits/statvfs.h> directly; use <sys/statvfs.h> instead."
-#endif
-
-#include <bits/types.h> /* For __fsblkcnt_t and __fsfilcnt_t. */
-
-#if __WORDSIZE == 32
-#define _STATVFSBUF_F_UNUSED
-#endif
-
-struct statvfs
- {
- unsigned long int f_bsize;
- unsigned long int f_frsize;
-#ifndef __USE_FILE_OFFSET64
- __fsblkcnt_t f_blocks;
- __fsblkcnt_t f_bfree;
- __fsblkcnt_t f_bavail;
- __fsfilcnt_t f_files;
- __fsfilcnt_t f_ffree;
- __fsfilcnt_t f_favail;
-#else
- __fsblkcnt64_t f_blocks;
- __fsblkcnt64_t f_bfree;
- __fsblkcnt64_t f_bavail;
- __fsfilcnt64_t f_files;
- __fsfilcnt64_t f_ffree;
- __fsfilcnt64_t f_favail;
-#endif
- unsigned long int f_fsid;
-#ifdef _STATVFSBUF_F_UNUSED
- int __f_unused;
-#endif
- unsigned long int f_flag;
- unsigned long int f_namemax;
- int __f_spare[6];
- };
-
-#ifdef __USE_LARGEFILE64
-struct statvfs64
- {
- unsigned long int f_bsize;
- unsigned long int f_frsize;
- __fsblkcnt64_t f_blocks;
- __fsblkcnt64_t f_bfree;
- __fsblkcnt64_t f_bavail;
- __fsfilcnt64_t f_files;
- __fsfilcnt64_t f_ffree;
- __fsfilcnt64_t f_favail;
- unsigned long int f_fsid;
-#ifdef _STATVFSBUF_F_UNUSED
- int __f_unused;
-#endif
- unsigned long int f_flag;
- unsigned long int f_namemax;
- int __f_spare[6];
- };
-#endif
-
-/* Definitions for the flag in `f_flag'. These definitions should be
- kept in sync which the definitions in <sys/mount.h>. */
-enum
-{
- ST_RDONLY = 1, /* Mount read-only. */
-#define ST_RDONLY ST_RDONLY
- ST_NOSUID = 2, /* Ignore suid and sgid bits. */
-#define ST_NOSUID ST_NOSUID
-#ifdef __USE_GNU
- ST_NODEV = 4, /* Disallow access to device special files. */
-# define ST_NODEV ST_NODEV
- ST_NOEXEC = 8, /* Disallow program execution. */
-# define ST_NOEXEC ST_NOEXEC
- ST_SYNCHRONOUS = 16, /* Writes are synced at once. */
-# define ST_SYNCHRONOUS ST_SYNCHRONOUS
- ST_MANDLOCK = 64, /* Allow mandatory locks on an FS. */
-# define ST_MANDLOCK ST_MANDLOCK
- ST_WRITE = 128, /* Write on file/directory/symlink. */
-# define ST_WRITE ST_WRITE
- ST_APPEND = 256, /* Append-only file. */
-# define ST_APPEND ST_APPEND
- ST_IMMUTABLE = 512, /* Immutable file. */
-# define ST_IMMUTABLE ST_IMMUTABLE
- ST_NOATIME = 1024, /* Do not update access times. */
-# define ST_NOATIME ST_NOATIME
- ST_NODIRATIME /* Do not update directory access times. */
-# define ST_NODIRATIME ST_NODIRATIME
-#endif /* Use GNU. */
-};
diff --git a/libc/sysdeps/linux/sparc/sigaction.c b/libc/sysdeps/linux/sparc/sigaction.c
index a22ac40af..3e6f7e408 100644
--- a/libc/sysdeps/linux/sparc/sigaction.c
+++ b/libc/sysdeps/linux/sparc/sigaction.c
@@ -30,7 +30,7 @@
#include <bits/kernel_sigaction.h>
-_syscall5(int, rt_sigaction, int, a, int, b, int, c, int, d, int, e);
+_syscall5(int, rt_sigaction, int, a, int, b, int, c, int, d, int, e)
static void __rt_sigreturn_stub(void);
static void __sigreturn_stub(void);
diff --git a/libc/sysdeps/linux/v850/bits/kernel_stat.h b/libc/sysdeps/linux/v850/bits/kernel_stat.h
index a7c9a73bf..1b925ca77 100644
--- a/libc/sysdeps/linux/v850/bits/kernel_stat.h
+++ b/libc/sysdeps/linux/v850/bits/kernel_stat.h
@@ -3,10 +3,6 @@
#ifndef _BITS_STAT_STRUCT_H
#define _BITS_STAT_STRUCT_H
-#ifndef _LIBC
-#error bits/kernel_stat.h is for internal uClibc use only!
-#endif
-
struct kernel_stat
{
__kernel_dev_t st_dev;
diff --git a/libc/sysdeps/linux/vax/bits/kernel_stat.h b/libc/sysdeps/linux/vax/bits/kernel_stat.h
index 4636a139c..a6da833c4 100644
--- a/libc/sysdeps/linux/vax/bits/kernel_stat.h
+++ b/libc/sysdeps/linux/vax/bits/kernel_stat.h
@@ -1,10 +1,6 @@
#ifndef _BITS_STAT_STRUCT_H
#define _BITS_STAT_STRUCT_H
-#ifndef _LIBC
-#error bits/kernel_stat.h is for internal uClibc use only!
-#endif
-
/* This file provides whatever this particular arch's kernel thinks
* struct stat should look like... It turns out each arch has a
* different opinion on the subject... */
diff --git a/libc/sysdeps/linux/vax/bits/shm.h b/libc/sysdeps/linux/vax/bits/shm.h
index 191709f0e..f1a44c982 100644
--- a/libc/sysdeps/linux/vax/bits/shm.h
+++ b/libc/sysdeps/linux/vax/bits/shm.h
@@ -40,6 +40,10 @@ __BEGIN_DECLS
#define SHMLBA (__getpagesize ())
extern int __getpagesize (void) __THROW __attribute__ ((__const__));
+
+/* Type to count number of attaches. */
+typedef unsigned short int shmatt_t;
+
/* Data structure describing a set of semaphores. */
struct shmid_ds
{
@@ -48,9 +52,9 @@ struct shmid_ds
__time_t shm_atime; /* time of last shmat() */
__time_t shm_dtime; /* time of last shmdt() */
__time_t shm_ctime; /* time of last change by shmctl() */
- __ipc_pid_t shm_cpid; /* pid of creator */
- __ipc_pid_t shm_lpid; /* pid of last shmop */
- unsigned short int shm_nattch; /* number of current attaches */
+ __pid_t shm_cpid; /* pid of creator */
+ __pid_t shm_lpid; /* pid of last shmop */
+ shmatt_t shm_nattch; /* number of current attaches */
unsigned short int __shm_npages; /* size of segment (pages) */
unsigned long int *__shm_pages; /* array of ptrs to frames -> SHMMAX */
struct vm_area_struct *__attaches; /* descriptors for attaches */
@@ -86,3 +90,5 @@ struct shm_info
};
#endif /* __USE_MISC */
+
+__END_DECLS
diff --git a/libc/sysdeps/linux/x86_64/bits/kernel_stat.h b/libc/sysdeps/linux/x86_64/bits/kernel_stat.h
index 2c1deb0d9..e194a7f76 100644
--- a/libc/sysdeps/linux/x86_64/bits/kernel_stat.h
+++ b/libc/sysdeps/linux/x86_64/bits/kernel_stat.h
@@ -1,12 +1,8 @@
/* Ripped from linux/include/asm-x86_64/stat.h
* and renamed 'struct stat' to 'struct kernel_stat' */
-#ifndef _ASM_X86_64_STAT_H
-#define _ASM_X86_64_STAT_H
-
-#ifndef _LIBC
-#error bits/kernel_stat.h is for internal uClibc use only!
-#endif
+#ifndef _BITS_STAT_STRUCT_H
+#define _BITS_STAT_STRUCT_H
struct kernel_stat {
unsigned long st_dev;
diff --git a/libc/sysdeps/linux/xtensa/bits/kernel_stat.h b/libc/sysdeps/linux/xtensa/bits/kernel_stat.h
index 10a35a23a..5e4f5c4e5 100644
--- a/libc/sysdeps/linux/xtensa/bits/kernel_stat.h
+++ b/libc/sysdeps/linux/xtensa/bits/kernel_stat.h
@@ -1,10 +1,6 @@
#ifndef _BITS_STAT_STRUCT_H
#define _BITS_STAT_STRUCT_H
-#ifndef _LIBC
-#error bits/kernel_stat.h is for internal uClibc use only!
-#endif
-
/* This file provides whatever this particular arch's kernel thinks
* struct kernel_stat should look like... It turns out each arch has a
* different opinion on the subject... */
diff --git a/libcrypt/Makefile.in b/libcrypt/Makefile.in
index 3cbf9d04b..1d1fb55ad 100644
--- a/libcrypt/Makefile.in
+++ b/libcrypt/Makefile.in
@@ -9,6 +9,7 @@ subdirs += libcrypt
CFLAGS-libcrypt := -DNOT_IN_libc -DIS_IN_libcrypt $(SSP_ALL_CFLAGS)
+LDFLAGS-$(UCLIBC_FORMAT_DSBT_ELF)-libcrypt.so := -Wl,--dsbt-index=4
LDFLAGS-libcrypt.so := $(LDFLAGS)
LIBS-libcrypt.so := $(LIBS)
diff --git a/libm/Makefile.in b/libm/Makefile.in
index 384365cac..223593304 100644
--- a/libm/Makefile.in
+++ b/libm/Makefile.in
@@ -25,6 +25,7 @@ subdirs += libm
CFLAGS-libm := -DNOT_IN_libc -DIS_IN_libm $(SSP_ALL_CFLAGS)
CFLAGS-libm += -D_IEEE_LIBM
+LDFLAGS-$(UCLIBC_FORMAT_DSBT_ELF)-libm.so := -Wl,--dsbt-index=5
LDFLAGS-libm.so := $(LDFLAGS)
LIBS-libm.so := $(LIBS)
diff --git a/libnsl/Makefile.in b/libnsl/Makefile.in
index 3aa05a0f7..333c4907b 100644
--- a/libnsl/Makefile.in
+++ b/libnsl/Makefile.in
@@ -9,6 +9,7 @@ subdirs += libnsl
CFLAGS-libnsl := -DNOT_IN_libc -DIS_IN_libnsl $(SSP_ALL_CFLAGS)
+LDFLAGS-$(UCLIBC_FORMAT_DSBT_ELF)-libnsl.so := -Wl,--dsbt-index=6
LDFLAGS-libnsl.so := $(LDFLAGS) $(call link.asneeded,-lc)
LIBS-libnsl.so := $(LIBS)
diff --git a/libpthread/linuxthreads.old/Makefile.in b/libpthread/linuxthreads.old/Makefile.in
index d2e29c72d..f599b1697 100644
--- a/libpthread/linuxthreads.old/Makefile.in
+++ b/libpthread/linuxthreads.old/Makefile.in
@@ -18,6 +18,7 @@ LDFLAGS-libpthread.so := $(LDFLAGS_NOSTRIP) -Wl,-z,defs
else
LDFLAGS-libpthread.so := $(LDFLAGS)
endif
+LDFLAGS-$(UCLIBC_FORMAT_DSBT_ELF)-libpthread.so := -Wl,--dsbt-index=10
LIBS-libpthread.so := $(LIBS) $(ldso)
diff --git a/libpthread/linuxthreads.old/internals.h b/libpthread/linuxthreads.old/internals.h
index 637fcea62..110dd9d56 100644
--- a/libpthread/linuxthreads.old/internals.h
+++ b/libpthread/linuxthreads.old/internals.h
@@ -252,17 +252,25 @@ extern pthread_descr __pthread_main_thread;
Initially 0, meaning that the current thread is (by definition)
the initial thread. */
-/* For non-MMU systems also remember to stack top of the initial thread.
- * This is adapted when other stacks are malloc'ed since we don't know
- * the bounds a-priori. -StS */
-
extern char *__pthread_initial_thread_bos;
#ifndef __ARCH_USE_MMU__
-extern char *__pthread_initial_thread_tos;
+/* For non-MMU systems, we have no idea the bounds of the initial thread
+ * stack, so we have to track it on the fly relative to other stacks. Do
+ * so by scaling back our assumptions on the limits of the bos/tos relative
+ * to the known mid point. See also the comments in pthread_initialize(). */
+extern char *__pthread_initial_thread_tos, *__pthread_initial_thread_mid;
#define NOMMU_INITIAL_THREAD_BOUNDS(tos,bos) \
- if ((tos)>=__pthread_initial_thread_bos \
- && (bos)<__pthread_initial_thread_tos) \
- __pthread_initial_thread_bos = (tos)+1
+ do { \
+ char *__tos = (tos); \
+ char *__bos = (bos); \
+ if (__tos >= __pthread_initial_thread_bos && \
+ __bos < __pthread_initial_thread_tos) { \
+ if (__bos < __pthread_initial_thread_mid) \
+ __pthread_initial_thread_bos = __tos; \
+ else \
+ __pthread_initial_thread_tos = __bos; \
+ } \
+ } while (0)
#else
#define NOMMU_INITIAL_THREAD_BOUNDS(tos,bos) /* empty */
#endif /* __ARCH_USE_MMU__ */
diff --git a/libpthread/linuxthreads.old/manager.c b/libpthread/linuxthreads.old/manager.c
index 52c1ea9b6..85fee5ec5 100644
--- a/libpthread/linuxthreads.old/manager.c
+++ b/libpthread/linuxthreads.old/manager.c
@@ -35,6 +35,9 @@
#include "semaphore.h"
#include "debug.h" /* PDEBUG, added by StS */
+#ifndef THREAD_STACK_OFFSET
+#define THREAD_STACK_OFFSET 0
+#endif
/* poll() is not supported in kernel <= 2.0, therefore is __NR_poll is
* not available, we assume an old Linux kernel is in use and we will
@@ -476,6 +479,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
int pid;
pthread_descr new_thread;
char * new_thread_bottom;
+ char * new_thread_top;
pthread_t new_thread_id;
char *guardaddr = NULL;
size_t guardsize = 0;
@@ -561,7 +565,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
/* Do the cloning. We have to use two different functions depending
on whether we are debugging or not. */
pid = 0; /* Note that the thread never can have PID zero. */
-
+ new_thread_top = ((char *)new_thread - THREAD_STACK_OFFSET);
/* ******************************************************** */
/* This code was moved from below to cope with running threads
@@ -588,12 +592,12 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
/* We have to report this event. */
#ifdef __ia64__
- pid = __clone2(pthread_start_thread_event, (void **) new_thread,
- (char *)new_thread - new_thread_bottom,
+ pid = __clone2(pthread_start_thread_event, new_thread_top,
+ new_thread_top - new_thread_bottom,
CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
__pthread_sig_cancel, new_thread);
#else
- pid = clone(pthread_start_thread_event, (void **) new_thread,
+ pid = clone(pthread_start_thread_event, new_thread_top,
CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
__pthread_sig_cancel, new_thread);
#endif
@@ -626,12 +630,12 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
{
PDEBUG("cloning new_thread = %p\n", new_thread);
#ifdef __ia64__
- pid = __clone2(pthread_start_thread, (void **) new_thread,
- (char *)new_thread - new_thread_bottom,
+ pid = __clone2(pthread_start_thread, new_thread_top,
+ new_thread_top - new_thread_bottom,
CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
__pthread_sig_cancel, new_thread);
#else
- pid = clone(pthread_start_thread, (void **) new_thread,
+ pid = clone(pthread_start_thread, new_thread_top,
CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
__pthread_sig_cancel, new_thread);
#endif
diff --git a/libpthread/linuxthreads.old/pthread.c b/libpthread/linuxthreads.old/pthread.c
index ad392e34e..a8830b1a4 100644
--- a/libpthread/linuxthreads.old/pthread.c
+++ b/libpthread/linuxthreads.old/pthread.c
@@ -168,12 +168,10 @@ pthread_descr __pthread_main_thread = &__pthread_initial_thread;
char *__pthread_initial_thread_bos = NULL;
-/* For non-MMU systems also remember to stack top of the initial thread.
- * This is adapted when other stacks are malloc'ed since we don't know
- * the bounds a-priori. -StS */
-
#ifndef __ARCH_USE_MMU__
+/* See nommu notes in internals.h and pthread_initialize() below. */
char *__pthread_initial_thread_tos = NULL;
+char *__pthread_initial_thread_mid = NULL;
#endif /* __ARCH_USE_MMU__ */
/* File descriptor for sending requests to the thread manager. */
@@ -457,12 +455,19 @@ static void pthread_initialize(void)
setrlimit(RLIMIT_STACK, &limit);
}
#else
- /* For non-MMU assume __pthread_initial_thread_tos at upper page boundary, and
- * __pthread_initial_thread_bos at address 0. These bounds are refined as we
- * malloc other stack frames such that they don't overlap. -StS
+ /* For non-MMU, the initial thread stack can reside anywhere in memory.
+ * We don't have a way of knowing where the kernel started things -- top
+ * or bottom (well, that isn't exactly true, but the solution is fairly
+ * complex and error prone). All we can determine here is an address
+ * that lies within that stack. Save that address as a reference so that
+ * as other thread stacks are created, we can adjust the estimated bounds
+ * of the initial thread's stack appropriately.
+ *
+ * This checking is handled in NOMMU_INITIAL_THREAD_BOUNDS(), so see that
+ * for a few more details.
*/
- __pthread_initial_thread_tos =
- (char *)(((long)CURRENT_STACK_FRAME + getpagesize()) & ~(getpagesize() - 1));
+ __pthread_initial_thread_mid = CURRENT_STACK_FRAME;
+ __pthread_initial_thread_tos = (char *) -1;
__pthread_initial_thread_bos = (char *) 1; /* set it non-zero so we know we have been here */
PDEBUG("initial thread stack bounds: bos=%p, tos=%p\n",
__pthread_initial_thread_bos, __pthread_initial_thread_tos);
diff --git a/libpthread/linuxthreads.old/signals.c b/libpthread/linuxthreads.old/signals.c
index 2a451f3d2..23d838eb8 100644
--- a/libpthread/linuxthreads.old/signals.c
+++ b/libpthread/linuxthreads.old/signals.c
@@ -20,7 +20,6 @@
#include "pthread.h"
#include "internals.h"
#include "spinlock.h"
-#include <ucontext.h>
#include <bits/sigcontextinfo.h>
/* mods for uClibc: __libc_sigaction is not in any standard headers */
diff --git a/libpthread/linuxthreads.old/sysdeps/c6x/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/c6x/pt-machine.h
new file mode 100644
index 000000000..cabd4e33c
--- /dev/null
+++ b/libpthread/linuxthreads.old/sysdeps/c6x/pt-machine.h
@@ -0,0 +1,64 @@
+/* Machine-dependent pthreads configuration and inline functions.
+ C6x version.
+ Copyright (C) 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Aurelien Jacquiot <aurelien.jacquiot@jaluna.com>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifndef _PT_MACHINE_H
+#define _PT_MACHINE_H 1
+
+#ifndef PT_EI
+# define PT_EI extern inline
+#endif
+
+extern int __compare_and_swap (long int *p, long int oldval, long int newval);
+
+/* Spinlock implementation; required. */
+static inline long int
+testandset (int *spinlock)
+{
+ register unsigned int ret = 1;
+ int dummy;
+ __asm__ __volatile__ ("mvc .s2 CSR, %0\n\tand .s2 -2, %0, %0\n\tmvc .s2 %0, CSR\n"
+ : "=b" (dummy));
+
+ if (*spinlock == 0) {
+ *spinlock = 1;
+ ret = 0;
+ }
+ __asm__ __volatile__ ("mvc .s2 CSR, %0\n\tor .s2 1, %0, %0\n\tmvc .s2 %0, CSR\n"
+ : "=b" (dummy));
+ return ret;
+}
+
+#define WRITE_MEMORY_BARRIER()
+#define READ_MEMORY_BARRIER()
+
+/* Get some notion of the current stack. Need not be exactly the top
+ of the stack, just something somewhere in the current frame. */
+#define CURRENT_STACK_FRAME get_stack_pointer()
+static inline char * get_stack_pointer(void)
+{
+ char *sp;
+ __asm__ __volatile__ ("mv .d2 B15, %0" : "=b" (sp));
+ return sp;
+}
+
+#define THREAD_STACK_OFFSET 8
+
+#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads/cancel.c b/libpthread/linuxthreads/cancel.c
index 34356801a..43f04457b 100644
--- a/libpthread/linuxthreads/cancel.c
+++ b/libpthread/linuxthreads/cancel.c
@@ -23,7 +23,7 @@
#ifdef _STACK_GROWS_DOWN
# define FRAME_LEFT(frame, other) ((char *) frame >= (char *) other)
-#elif _STACK_GROWS_UP
+#elif defined _STACK_GROWS_UP
# define FRAME_LEFT(frame, other) ((char *) frame <= (char *) other)
#else
# error "Define either _STACK_GROWS_DOWN or _STACK_GROWS_UP"
diff --git a/libpthread/linuxthreads/manager.c b/libpthread/linuxthreads/manager.c
index 4293741ac..1dd626e23 100644
--- a/libpthread/linuxthreads/manager.c
+++ b/libpthread/linuxthreads/manager.c
@@ -445,7 +445,7 @@ static int pthread_allocate_stack(const pthread_attr_t *attr,
new_thread = ((pthread_descr) (new_thread_bottom + stacksize
+ guardsize)) - 1;
# endif
-# elif _STACK_GROWS_DOWN
+# elif defined _STACK_GROWS_DOWN
guardaddr = map_addr;
if (guardsize > 0)
mprotect (guardaddr, guardsize, PROT_NONE);
@@ -456,7 +456,7 @@ static int pthread_allocate_stack(const pthread_attr_t *attr,
# else
new_thread = ((pthread_descr) (new_thread_bottom + stacksize)) - 1;
# endif
-# elif _STACK_GROWS_UP
+# elif defined _STACK_GROWS_UP
guardaddr = map_addr + stacksize;
if (guardsize > 0)
mprotect (guardaddr, guardsize, PROT_NONE);
@@ -744,7 +744,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
(char *)stack_addr - new_thread_bottom,
CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_SYSVSEM |
__pthread_sig_cancel, new_thread);
-#elif _STACK_GROWS_UP
+#elif defined _STACK_GROWS_UP
pid = __clone(pthread_start_thread_event, (void *) new_thread_bottom,
CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_SYSVSEM |
__pthread_sig_cancel, new_thread);
@@ -785,7 +785,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
(char *)stack_addr - new_thread_bottom,
CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_SYSVSEM |
__pthread_sig_cancel, new_thread);
-#elif _STACK_GROWS_UP
+#elif defined _STACK_GROWS_UP
pid = __clone(pthread_start_thread, (void *) new_thread_bottom,
CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_SYSVSEM |
__pthread_sig_cancel, new_thread);
@@ -806,7 +806,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
- new_thread_bottom);
munmap((caddr_t)new_thread_bottom,
2 * stacksize + new_thread->p_guardsize);
-#elif _STACK_GROWS_UP
+#elif defined _STACK_GROWS_UP
# ifdef USE_TLS
size_t stacksize = guardaddr - stack_addr;
munmap(stack_addr, stacksize + guardsize);
diff --git a/libpthread/linuxthreads/ptcleanup.c b/libpthread/linuxthreads/ptcleanup.c
index 6213b56f3..75bb7d599 100644
--- a/libpthread/linuxthreads/ptcleanup.c
+++ b/libpthread/linuxthreads/ptcleanup.c
@@ -49,13 +49,13 @@ void __pthread_cleanup_upto (__jmp_buf target, char *targetframe)
c != NULL && __JMPBUF_UNWINDS(target, c, demangle_ptr);
c = c->__prev)
{
-#if _STACK_GROWS_DOWN
+#ifdef _STACK_GROWS_DOWN
if ((char *) c <= targetframe)
{
c = NULL;
break;
}
-#elif _STACK_GROWS_UP
+#elif defined _STACK_GROWS_UP
if ((char *) c >= targetframe)
{
c = NULL;
diff --git a/libpthread/linuxthreads/pthread.c b/libpthread/linuxthreads/pthread.c
index db436342f..c3e28c6ac 100644
--- a/libpthread/linuxthreads/pthread.c
+++ b/libpthread/linuxthreads/pthread.c
@@ -750,7 +750,7 @@ int __pthread_initialize_manager(void)
THREAD_MANAGER_STACK_SIZE,
CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_SYSVSEM,
mgr);
-#elif _STACK_GROWS_UP
+#elif defined _STACK_GROWS_UP
pid = __clone(__pthread_manager_event,
(void **) __pthread_manager_thread_bos,
CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_SYSVSEM,
@@ -789,7 +789,7 @@ int __pthread_initialize_manager(void)
pid = __clone2(__pthread_manager, (void **) __pthread_manager_thread_bos,
THREAD_MANAGER_STACK_SIZE,
CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_SYSVSEM, mgr);
-#elif _STACK_GROWS_UP
+#elif defined _STACK_GROWS_UP
pid = __clone(__pthread_manager, (void **) __pthread_manager_thread_bos,
CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_SYSVSEM, mgr);
#else
diff --git a/libpthread/linuxthreads/signals.c b/libpthread/linuxthreads/signals.c
index 02bf1c64b..c08125579 100644
--- a/libpthread/linuxthreads/signals.c
+++ b/libpthread/linuxthreads/signals.c
@@ -19,7 +19,6 @@
#include "pthread.h"
#include "internals.h"
#include "spinlock.h"
-#include <ucontext.h>
/* mods for uClibc: __libc_sigaction is not in any standard headers */
extern __typeof(sigaction) __libc_sigaction;
diff --git a/libpthread/nptl/allocatestack.c b/libpthread/nptl/allocatestack.c
index 1c549cee1..e30fe41a2 100644
--- a/libpthread/nptl/allocatestack.c
+++ b/libpthread/nptl/allocatestack.c
@@ -122,7 +122,7 @@ static uintptr_t in_flight_stack;
list_t __stack_user __attribute__ ((nocommon));
hidden_data_def (__stack_user)
-#if COLORING_INCREMENT != 0
+#if defined COLORING_INCREMENT && COLORING_INCREMENT != 0
/* Number of threads created. */
static unsigned int nptl_ncreated;
#endif
@@ -316,10 +316,10 @@ change_stack_perm (struct pthread *pd
+ (((((pd->stackblock_size - pd->guardsize) / 2)
& pagemask) + pd->guardsize) & pagemask));
size_t len = pd->stackblock + pd->stackblock_size - stack;
-#elif _STACK_GROWS_DOWN
+#elif defined _STACK_GROWS_DOWN
void *stack = pd->stackblock + pd->guardsize;
size_t len = pd->stackblock_size - pd->guardsize;
-#elif _STACK_GROWS_UP
+#elif defined _STACK_GROWS_UP
void *stack = pd->stackblock;
size_t len = (uintptr_t) pd - pd->guardsize - (uintptr_t) pd->stackblock;
#else
@@ -443,7 +443,7 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
void *mem = 0;
const int prot = (PROT_READ | PROT_WRITE);
-#if COLORING_INCREMENT != 0
+#if defined COLORING_INCREMENT && COLORING_INCREMENT != 0
/* Add one more page for stack coloring. Don't do it for stacks
with 16 times pagesize or larger. This might just cause
unnecessary misalignment. */
@@ -474,7 +474,7 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
adjust the allocated stack size if necessary. This way
allocations directly following each other will not have
aliasing problems. */
-#if MULTI_PAGE_ALIASING != 0
+#if defined MULTI_PAGE_ALIASING && MULTI_PAGE_ALIASING != 0
if ((size % MULTI_PAGE_ALIASING) == 0)
size += pagesize_m1 + 1;
#endif
@@ -494,7 +494,7 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
So we can never get a null pointer back from mmap. */
assert (mem != NULL);
-#if COLORING_INCREMENT != 0
+#if defined COLORING_INCREMENT && COLORING_INCREMENT != 0
/* Atomically increment NCREATED. */
unsigned int ncreated = atomic_increment_val (&nptl_ncreated);
@@ -591,9 +591,9 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
{
#ifdef NEED_SEPARATE_REGISTER_STACK
char *guard = mem + (((size - guardsize) / 2) & ~pagesize_m1);
-#elif _STACK_GROWS_DOWN
+#elif defined _STACK_GROWS_DOWN
char *guard = mem;
-# elif _STACK_GROWS_UP
+#elif defined _STACK_GROWS_UP
char *guard = (char *) (((uintptr_t) pd - guardsize) & ~pagesize_m1);
#endif
if (mprotect (guard, guardsize, PROT_NONE) != 0)
@@ -641,11 +641,11 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
oldguard + pd->guardsize - guard - guardsize,
prot) != 0)
goto mprot_error;
-#elif _STACK_GROWS_DOWN
+#elif defined _STACK_GROWS_DOWN
if (mprotect ((char *) mem + guardsize, pd->guardsize - guardsize,
prot) != 0)
goto mprot_error;
-#elif _STACK_GROWS_UP
+#elif defined _STACK_GROWS_UP
if (mprotect ((char *) pd - pd->guardsize,
pd->guardsize - guardsize, prot) != 0)
goto mprot_error;
@@ -688,9 +688,9 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
#ifdef NEED_SEPARATE_REGISTER_STACK
*stack = pd->stackblock;
*stacksize = stacktop - *stack;
-#elif _STACK_GROWS_DOWN
+#elif defined _STACK_GROWS_DOWN
*stack = stacktop;
-#elif _STACK_GROWS_UP
+#elif defined _STACK_GROWS_UP
*stack = pd->stackblock;
assert (*stack > 0);
#endif
diff --git a/libpthread/nptl/init.c b/libpthread/nptl/init.c
index 911293a65..c8ca09637 100644
--- a/libpthread/nptl/init.c
+++ b/libpthread/nptl/init.c
@@ -257,6 +257,7 @@ extern void **__libc_dl_error_tsd (void) __attribute__ ((const));
/* This can be set by the debugger before initialization is complete. */
static bool __nptl_initial_report_events __attribute_used__;
+void __pthread_initialize_minimal_internal (void) attribute_hidden;
void
__pthread_initialize_minimal_internal (void)
{
diff --git a/libpthread/nptl/pt-cleanup.c b/libpthread/nptl/pt-cleanup.c
index 97673b6c5..d7394ae44 100644
--- a/libpthread/nptl/pt-cleanup.c
+++ b/libpthread/nptl/pt-cleanup.c
@@ -39,13 +39,13 @@ __pthread_cleanup_upto (__jmp_buf target, char *targetframe)
cbuf != NULL && _JMPBUF_UNWINDS_ADJ (target, cbuf, adj);
cbuf = cbuf->__prev)
{
-#if _STACK_GROWS_DOWN
+#ifdef _STACK_GROWS_DOWN
if ((uintptr_t) cbuf - adj <= targetframe_adj)
{
cbuf = NULL;
break;
}
-#elif _STACK_GROWS_UP
+#elif defined _STACK_GROWS_UP
if ((uintptr_t) cbuf - adj >= targetframe_adj)
{
cbuf = NULL;
diff --git a/libpthread/nptl/pthreadP.h b/libpthread/nptl/pthreadP.h
index fbac7d08f..fb354eaa3 100644
--- a/libpthread/nptl/pthreadP.h
+++ b/libpthread/nptl/pthreadP.h
@@ -179,7 +179,13 @@ extern struct pthread_key_struct __pthread_keys[PTHREAD_KEYS_MAX];
hidden_proto (__pthread_keys)
/* Number of threads running. */
-extern unsigned int __nptl_nthreads attribute_hidden;
+extern unsigned int __nptl_nthreads
+#ifdef SHARED
+ attribute_hidden
+#else
+ __attribute ((weak))
+#endif
+ ;
#ifndef __ASSUME_SET_ROBUST_LIST
/* Negative if we do not have the system call and we can use it. */
@@ -563,7 +569,13 @@ extern void _pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *buffer,
extern void _pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *buffer,
int execute);
-extern void __nptl_deallocate_tsd (void) attribute_hidden;
+extern void __nptl_deallocate_tsd (void)
+#ifdef SHARED
+ attribute_hidden
+#else
+ __attribute ((weak))
+#endif
+ ;
extern int __nptl_setxid (struct xid_command *cmdp) attribute_hidden;
diff --git a/libpthread/nptl/sysdeps/generic/dl-tls.c b/libpthread/nptl/sysdeps/generic/dl-tls.c
index 4acfa4ba7..904da8b8d 100644
--- a/libpthread/nptl/sysdeps/generic/dl-tls.c
+++ b/libpthread/nptl/sysdeps/generic/dl-tls.c
@@ -66,6 +66,7 @@ oom (void)
# endif
+void *_dl_memalign(size_t alignment, size_t bytes);
void *_dl_memalign(size_t alignment, size_t bytes)
{
return _dl_malloc(bytes);
@@ -836,6 +837,7 @@ __tls_get_addr (GET_ADDR_ARGS)
+void _dl_add_to_slotinfo (struct link_map *l);
void
_dl_add_to_slotinfo (struct link_map *l)
{
diff --git a/libpthread/nptl/sysdeps/generic/libc-tls.c b/libpthread/nptl/sysdeps/generic/libc-tls.c
index b78d96483..e14fc26c6 100644
--- a/libpthread/nptl/sysdeps/generic/libc-tls.c
+++ b/libpthread/nptl/sysdeps/generic/libc-tls.c
@@ -110,6 +110,7 @@ init_static_tls (size_t memsz, size_t align)
GL(dl_tls_static_nelem) = GL(dl_tls_max_dtv_idx);
}
+void __libc_setup_tls (size_t tcbsize, size_t tcbalign);
void
__libc_setup_tls (size_t tcbsize, size_t tcbalign)
{
@@ -241,6 +242,7 @@ _dl_tls_setup (void)
return 0;
}
+extern void __pthread_initialize_minimal(void) __attribute__((weak));
/* This is the minimal initialization function used when libpthread is
not used. */
diff --git a/libpthread/nptl/sysdeps/pthread/bits/sigthread.h b/libpthread/nptl/sysdeps/pthread/bits/sigthread.h
index 9a524e57d..e69de29bb 100644
--- a/libpthread/nptl/sysdeps/pthread/bits/sigthread.h
+++ b/libpthread/nptl/sysdeps/pthread/bits/sigthread.h
@@ -1,44 +0,0 @@
-/* Signal handling function for threaded programs.
- Copyright (C) 1998, 1999, 2000, 2002, 2009 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
- modify it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of the
- License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-#ifndef _BITS_SIGTHREAD_H
-#define _BITS_SIGTHREAD_H 1
-
-#if !defined _SIGNAL_H && !defined _PTHREAD_H
-# error "Never include this file directly. Use <pthread.h> instead"
-#endif
-
-/* Functions for handling signals. */
-
-/* Modify the signal mask for the calling thread. The arguments have
- the same meaning as for sigprocmask(2). */
-extern int pthread_sigmask (int __how,
- __const __sigset_t *__restrict __newmask,
- __sigset_t *__restrict __oldmask)__THROW;
-
-/* Send signal SIGNO to the given thread. */
-extern int pthread_kill (pthread_t __threadid, int __signo) __THROW;
-
-#ifdef __USE_GNU
-/* Queue signal and data to a thread. */
-extern int pthread_sigqueue (pthread_t __threadid, int __signo,
- const union sigval __value) __THROW;
-#endif
-
-#endif /* bits/sigthread.h */
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/pt-gettimeofday.c b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/pt-gettimeofday.c
index 08710f1c8..79faf54bf 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/pt-gettimeofday.c
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/pt-gettimeofday.c
@@ -2,4 +2,4 @@
#include <sys/time.h>
int gettimeofday (struct timeval *, struct timezone *) attribute_hidden;
-_syscall2(int, gettimeofday, struct timeval *, tv, struct timezone *, tz);
+_syscall2(int, gettimeofday, struct timeval *, tv, struct timezone *, tz)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h
index 7ac9ca1e9..f0e5f6b37 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h
@@ -36,7 +36,7 @@
.type __##syscall_name##_nocancel,%function; \
.globl __##syscall_name##_nocancel; \
__##syscall_name##_nocancel: \
- .cfi_sections .debug_frame; \
+ cfi_sections(.debug_frame); \
cfi_startproc; \
DO_CALL (syscall_name, args); \
PSEUDO_RET; \
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-resume.c b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-resume.c
index e35374d34..15250157c 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-resume.c
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-resume.c
@@ -65,7 +65,7 @@ __asm__ (
" .globl _Unwind_Resume\n"
" .type _Unwind_Resume, %function\n"
"_Unwind_Resume:\n"
-" .cfi_sections .debug_frame\n"
+" " CFI_SECTIONS (.debug_frame) "\n"
" " CFI_STARTPROC "\n"
" stmfd sp!, {r4, r5, r6, lr}\n"
" " CFI_ADJUST_CFA_OFFSET (16)" \n"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/jmp-unwind.c b/libpthread/nptl/sysdeps/unix/sysv/linux/jmp-unwind.c
index f2795510a..642198bad 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/jmp-unwind.c
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/jmp-unwind.c
@@ -25,6 +25,7 @@ extern void __pthread_cleanup_upto (__jmp_buf env, char *targetframe);
#pragma weak __pthread_cleanup_upto
+void _longjmp_unwind (jmp_buf env, int val);
void
_longjmp_unwind (jmp_buf env, int val)
{
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
index f87532359..e59bdda44 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
@@ -163,7 +163,7 @@ __lll_timedlock_wait:
cfi_startproc
# ifndef __ASSUME_FUTEX_CLOCK_REALTIME
# ifdef __PIC__
- cmpl $0, __have_futex_clock_realtime(%rip)
+ cmpl $0, __have_futex_clock_realtime@GOTOFF(%rip)
# else
cmpl $0, __have_futex_clock_realtime
# endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
index 2eb8e29fa..5cc4256a5 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
@@ -118,7 +118,7 @@ __lll_robust_timedlock_wait:
cfi_startproc
# ifndef __ASSUME_FUTEX_CLOCK_REALTIME
# ifdef __PIC__
- cmpl $0, __have_futex_clock_realtime(%rip)
+ cmpl $0, __have_futex_clock_realtime@GOTOFF(%rip)
# else
cmpl $0, __have_futex_clock_realtime
# endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
index 3a965ad0b..645436f99 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
@@ -98,7 +98,7 @@ __pthread_cond_timedwait:
22:
#ifndef __ASSUME_FUTEX_CLOCK_REALTIME
# ifdef __PIC__
- cmpl $0, __have_futex_clock_realtime(%rip)
+ cmpl $0, __have_futex_clock_realtime@GOTOFF(%rip)
# else
cmpl $0, __have_futex_clock_realtime
# endif
@@ -437,14 +437,6 @@ __pthread_cond_timedwait:
/* Only clocks 0 and 1 are allowed so far. Both are handled in the
kernel. */
leaq 32(%rsp), %rsi
-# ifdef SHARED
- movq __vdso_clock_gettime@GOTPCREL(%rip), %rax
- movq (%rax), %rax
- PTR_DEMANGLE (%rax)
- jz 26f
- call *%rax
- jmp 27f
-# endif
26: movl $__NR_clock_gettime, %eax
syscall
27:
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
index 3629ffbe5..15edd6149 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
@@ -96,7 +96,7 @@ pthread_rwlock_timedrdlock:
11:
#ifndef __ASSUME_FUTEX_CLOCK_REALTIME
# ifdef __PIC__
- cmpl $0, __have_futex_clock_realtime(%rip)
+ cmpl $0, __have_futex_clock_realtime@GOTOFF(%rip)
# else
cmpl $0, __have_futex_clock_realtime
# endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
index 23e1ee155..3c4a27912 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
@@ -93,7 +93,7 @@ pthread_rwlock_timedwrlock:
11:
#ifndef __ASSUME_FUTEX_CLOCK_REALTIME
# ifdef __PIC__
- cmpl $0, __have_futex_clock_realtime(%rip)
+ cmpl $0, __have_futex_clock_realtime@GOTOFF(%rip)
# else
cmpl $0, __have_futex_clock_realtime
# endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
index 704a2223a..3ff34120c 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
@@ -61,7 +61,7 @@ sem_timedwait:
#ifndef __ASSUME_FUTEX_CLOCK_REALTIME
# ifdef __PIC__
- cmpl $0, __have_futex_clock_realtime(%rip)
+ cmpl $0, __have_futex_clock_realtime@GOTOFF(%rip)
# else
cmpl $0, __have_futex_clock_realtime
# endif
diff --git a/libpthread/nptl/unwind.c b/libpthread/nptl/unwind.c
index c7e01e764..671d70208 100644
--- a/libpthread/nptl/unwind.c
+++ b/libpthread/nptl/unwind.c
@@ -30,7 +30,7 @@
#ifdef _STACK_GROWS_DOWN
# define FRAME_LEFT(frame, other, adj) \
((uintptr_t) frame - adj >= (uintptr_t) other - adj)
-#elif _STACK_GROWS_UP
+#elif defined _STACK_GROWS_UP
# define FRAME_LEFT(frame, other, adj) \
((uintptr_t) frame - adj <= (uintptr_t) other - adj)
#else
@@ -117,6 +117,9 @@ unwind_cleanup (_Unwind_Reason_Code reason, struct _Unwind_Exception *exc)
void
attribute_protected
__cleanup_fct_attribute __attribute ((noreturn))
+#if !defined SHARED && !defined IS_IN_libpthread
+weak_function
+#endif
__pthread_unwind (__pthread_unwind_buf_t *buf)
{
struct pthread_unwind_buf *ibuf = (struct pthread_unwind_buf *) buf;
diff --git a/libresolv/Makefile.in b/libresolv/Makefile.in
index fb71b421e..fa3c34138 100644
--- a/libresolv/Makefile.in
+++ b/libresolv/Makefile.in
@@ -9,6 +9,7 @@ subdirs += libresolv
CFLAGS-libresolv := -DNOT_IN_libc -DIS_IN_libresolv $(SSP_ALL_CFLAGS)
+LDFLAGS-$(UCLIBC_FORMAT_DSBT_ELF)-libresolv.so := -Wl,--dsbt-index=7
LDFLAGS-libresolv.so := $(LDFLAGS) $(call link.asneeded,-lc)
LIBS-libresolv.so := $(LIBS)
diff --git a/librt/Makefile.in b/librt/Makefile.in
index 6eb508cb2..7d295d4a6 100644
--- a/librt/Makefile.in
+++ b/librt/Makefile.in
@@ -9,6 +9,7 @@ subdirs += librt
CFLAGS-librt := -DNOT_IN_libc -DIS_IN_librt $(SSP_ALL_CFLAGS)
+LDFLAGS-$(UCLIBC_FORMAT_DSBT_ELF)-librt.so := -Wl,--dsbt-index=9
LDFLAGS-librt.so := $(LDFLAGS)
LIBS-librt.so := $(LIBS)
ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
diff --git a/librt/mq_receive.c b/librt/mq_receive.c
index 40447dfb9..26fc45194 100644
--- a/librt/mq_receive.c
+++ b/librt/mq_receive.c
@@ -2,22 +2,23 @@
* mq_receive.c - functions for receiving from message queue.
*/
-#include <errno.h>
-#include <stddef.h>
#include <sys/syscall.h>
+
+#ifdef __NR_mq_timedreceive
+
+#include <stddef.h>
#include <mqueue.h>
-#warning FIXME: hard dependency on ADVANCED REALTIME feature
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
librt_hidden_proto(mq_timedreceive)
+#else
-#ifndef __UCLIBC_HAS_THREADS_NATIVE__
-#ifdef __NR_mq_timedreceive
-#define __NR___syscall_mq_timedreceive __NR_mq_timedreceive
-static __inline__ _syscall5(int, __syscall_mq_timedreceive, int, mqdes,
- char *, msg_ptr, size_t, msg_len, unsigned int *,
- msg_prio, const void *, abs_timeout);
-#endif
+# define __NR___syscall_mq_timedreceive __NR_mq_timedreceive
+static _syscall5(int, __syscall_mq_timedreceive, int, mqdes,
+ char *, msg_ptr, size_t, msg_len, unsigned int *,
+ msg_prio, const void *, abs_timeout);
+# ifdef __UCLIBC_HAS_ADVANCED_REALTIME__
/*
* Receive the oldest from highest priority messages.
* Stop waiting if abs_timeout expires.
@@ -26,21 +27,22 @@ ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len,
unsigned int *msg_prio,
const struct timespec *abs_timeout)
{
-#ifdef __NR_mq_timedreceive
return __syscall_mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio,
abs_timeout);
-#else
- errno = ENOSYS;
- return -1;
-#endif
}
+# endif
-librt_hidden_def(mq_timedreceive)
#endif
/* Receive the oldest from highest priority messages */
ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len,
unsigned int *msg_prio)
{
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
return mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, NULL);
+#else
+ return __syscall_mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, NULL);
+#endif
}
+
+#endif
diff --git a/librt/mq_send.c b/librt/mq_send.c
index f0fcfa35a..78308d8d9 100644
--- a/librt/mq_send.c
+++ b/librt/mq_send.c
@@ -2,22 +2,23 @@
* mq_send.c - functions for sending to message queue.
*/
-#include <errno.h>
-#include <stddef.h>
#include <sys/syscall.h>
+
+#ifdef __NR_mq_timedsend
+
+#include <stddef.h>
#include <mqueue.h>
-#warning FIXME: hard dependency on ADVANCED REALTIME feature
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
librt_hidden_proto(mq_timedsend)
+#else
-#ifndef __UCLIBC_HAS_THREADS_NATIVE__
-#ifdef __NR_mq_timedsend
-#define __NR___syscall_mq_timedsend __NR_mq_timedsend
-static __inline__ _syscall5(int, __syscall_mq_timedsend, int, mqdes,
- const char *, msg_ptr, size_t, msg_len, unsigned int,
- msg_prio, const void *, abs_timeout);
-#endif
+# define __NR___syscall_mq_timedsend __NR_mq_timedsend
+static _syscall5(int, __syscall_mq_timedsend, int, mqdes,
+ const char *, msg_ptr, size_t, msg_len, unsigned int,
+ msg_prio, const void *, abs_timeout);
+# ifdef __UCLIBC_HAS_ADVANCED_REALTIME__
/*
* Add a message to queue. If O_NONBLOCK is set and queue is full, wait
* for sufficient room in the queue until abs_timeout expires.
@@ -25,21 +26,21 @@ static __inline__ _syscall5(int, __syscall_mq_timedsend, int, mqdes,
int mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
unsigned int msg_prio, const struct timespec *abs_timeout)
{
-#ifdef __NR_mq_timedsend
return __syscall_mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio,
abs_timeout);
-#else
- errno = ENOSYS;
- return -1;
-#endif
}
-
-librt_hidden_def(mq_timedsend)
+# endif
#endif
/* Add a message to queue */
int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
unsigned int msg_prio)
{
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
return mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, NULL);
+#else
+ return __syscall_mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, NULL);
+#endif
}
+
+#endif
diff --git a/librt/rt_stubs.c b/librt/rt_stubs.c
new file mode 100644
index 000000000..b2c09dea9
--- /dev/null
+++ b/librt/rt_stubs.c
@@ -0,0 +1,39 @@
+/*
+ * system call not available stub
+ * based on libc's stubs.c
+ *
+ * Copyright (C) 2009 Analog Devices Inc.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <errno.h>
+#include <sys/syscall.h>
+
+#ifdef __UCLIBC_HAS_STUBS__
+
+static int rt_enosys_stub(void)
+{
+ __set_errno(ENOSYS);
+ return -1;
+}
+
+#define make_stub(stub) \
+ link_warning(stub, #stub ": this function is not implemented") \
+ strong_alias(rt_enosys_stub, stub)
+
+#ifndef __NR_mq_timedreceive
+make_stub(mq_receive)
+# ifdef __UCLIBC_HAS_ADVANCED_REALTIME__
+make_stub(mq_timedreceive)
+# endif
+#endif
+
+#ifndef __NR_mq_timedsend
+make_stub(mq_send)
+# ifdef __UCLIBC_HAS_ADVANCED_REALTIME__
+make_stub(mq_timedsend)
+# endif
+#endif
+
+#endif
diff --git a/libutil/Makefile.in b/libutil/Makefile.in
index 057d02ded..f904fc7e1 100644
--- a/libutil/Makefile.in
+++ b/libutil/Makefile.in
@@ -9,6 +9,7 @@ subdirs += libutil
CFLAGS-libutil := -DNOT_IN_libc -DIS_IN_libutil $(SSP_ALL_CFLAGS)
+LDFLAGS-$(UCLIBC_FORMAT_DSBT_ELF)-libutil.so := -Wl,--dsbt-index=8
LDFLAGS-libutil.so := $(LDFLAGS)
LIBS-libutil.so := $(LIBS)
diff --git a/utils/getconf.c b/utils/getconf.c
index 812783ecf..5ff98e6fc 100644
--- a/utils/getconf.c
+++ b/utils/getconf.c
@@ -15,6 +15,7 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+#define _GNU_SOURCE 1
#include <unistd.h>
#include <errno.h>
#include <string.h>
diff --git a/utils/ldconfig.c b/utils/ldconfig.c
index a25de260a..024be7ca4 100644
--- a/utils/ldconfig.c
+++ b/utils/ldconfig.c
@@ -568,7 +568,7 @@ static char *get_extpath(void)
if ((file = fopen(realconffile, "r")) != NULL) {
fstat(fileno(file), &st);
res = xmalloc(st.st_size + 1);
- fread(res, 1, st.st_size, file);
+ (void)fread(res, 1, st.st_size, file);
fclose(file);
res[st.st_size] = '\0';
diff --git a/utils/ldd.c b/utils/ldd.c
index 3858c815c..904075c23 100644
--- a/utils/ldd.c
+++ b/utils/ldd.c
@@ -553,7 +553,7 @@ static struct library *find_elf_interpreter(ElfW(Ehdr) *ehdr)
interp_name = strdup(s);
interp_dir = strdup(s);
tmp = strrchr(interp_dir, '/');
- if (*tmp)
+ if (tmp)
*tmp = '\0';
else {
free(interp_dir);