summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux
diff options
context:
space:
mode:
Diffstat (limited to 'libc/sysdeps/linux')
-rw-r--r--libc/sysdeps/linux/Makefile.commonarch63
-rw-r--r--libc/sysdeps/linux/Makefile.in3
-rw-r--r--libc/sysdeps/linux/README5
-rw-r--r--libc/sysdeps/linux/alpha/Makefile.arch6
-rw-r--r--libc/sysdeps/linux/alpha/__longjmp.S12
-rw-r--r--libc/sysdeps/linux/alpha/__syscall_rt_sigaction.S8
-rw-r--r--libc/sysdeps/linux/alpha/bits/atomic.h13
-rw-r--r--libc/sysdeps/linux/alpha/bits/dirent.h5
-rw-r--r--libc/sysdeps/linux/alpha/bits/epoll.h29
-rw-r--r--libc/sysdeps/linux/alpha/bits/eventfd.h31
-rw-r--r--libc/sysdeps/linux/alpha/bits/fcntl.h21
-rw-r--r--libc/sysdeps/linux/alpha/bits/fenv.h11
-rw-r--r--libc/sysdeps/linux/alpha/bits/inotify.h29
-rw-r--r--libc/sysdeps/linux/alpha/bits/ioctls.h5
-rw-r--r--libc/sysdeps/linux/alpha/bits/ipc.h5
-rw-r--r--libc/sysdeps/linux/alpha/bits/kernel_sigaction.h11
-rw-r--r--libc/sysdeps/linux/alpha/bits/kernel_stat.h19
-rw-r--r--libc/sysdeps/linux/alpha/bits/kernel_types.h2
-rw-r--r--libc/sysdeps/linux/alpha/bits/local_lim.h91
-rw-r--r--libc/sysdeps/linux/alpha/bits/mathdef.h33
-rw-r--r--libc/sysdeps/linux/alpha/bits/mathinline.h7
-rw-r--r--libc/sysdeps/linux/alpha/bits/mman.h7
-rw-r--r--libc/sysdeps/linux/alpha/bits/msq.h5
-rw-r--r--libc/sysdeps/linux/alpha/bits/netdb.h5
-rw-r--r--libc/sysdeps/linux/alpha/bits/resource.h5
-rw-r--r--libc/sysdeps/linux/alpha/bits/sem.h5
-rw-r--r--libc/sysdeps/linux/alpha/bits/setjmp.h32
-rw-r--r--libc/sysdeps/linux/alpha/bits/shm.h5
-rw-r--r--libc/sysdeps/linux/alpha/bits/sigaction.h38
-rw-r--r--libc/sysdeps/linux/alpha/bits/sigcontextinfo.h5
-rw-r--r--libc/sysdeps/linux/alpha/bits/siginfo.h22
-rw-r--r--libc/sysdeps/linux/alpha/bits/signalfd.h29
-rw-r--r--libc/sysdeps/linux/alpha/bits/signum.h24
-rw-r--r--libc/sysdeps/linux/alpha/bits/sigstack.h7
-rw-r--r--libc/sysdeps/linux/alpha/bits/socket_type.h54
-rw-r--r--libc/sysdeps/linux/alpha/bits/stackinfo.h5
-rw-r--r--libc/sysdeps/linux/alpha/bits/stat.h12
-rw-r--r--libc/sysdeps/linux/alpha/bits/statfs.h5
-rw-r--r--libc/sysdeps/linux/alpha/bits/statvfs.h96
-rw-r--r--libc/sysdeps/linux/alpha/bits/syscalls.h403
-rw-r--r--libc/sysdeps/linux/alpha/bits/termios.h5
-rw-r--r--libc/sysdeps/linux/alpha/bits/timerfd.h29
-rw-r--r--libc/sysdeps/linux/alpha/bits/typesizes.h5
-rw-r--r--libc/sysdeps/linux/alpha/bits/uClibc_arch_features.h17
-rw-r--r--libc/sysdeps/linux/alpha/bits/uClibc_page.h4
-rw-r--r--libc/sysdeps/linux/alpha/bits/wordsize.h5
-rw-r--r--libc/sysdeps/linux/alpha/brk.S5
-rw-r--r--libc/sysdeps/linux/alpha/clone.S5
-rw-r--r--libc/sysdeps/linux/alpha/crt1.S5
-rw-r--r--libc/sysdeps/linux/alpha/crtn.S19
-rw-r--r--libc/sysdeps/linux/alpha/divrem.h5
-rw-r--r--libc/sysdeps/linux/alpha/fpu_control.h5
-rw-r--r--libc/sysdeps/linux/alpha/jmpbuf-offsets.h35
-rw-r--r--libc/sysdeps/linux/alpha/jmpbuf-unwind.h23
-rw-r--r--libc/sysdeps/linux/alpha/pipe.S5
-rw-r--r--libc/sysdeps/linux/alpha/setjmp.S40
-rw-r--r--libc/sysdeps/linux/alpha/sigprocmask.c18
-rw-r--r--libc/sysdeps/linux/alpha/sys/acct.h7
-rw-r--r--libc/sysdeps/linux/alpha/sys/io.h7
-rw-r--r--libc/sysdeps/linux/alpha/sys/procfs.h20
-rw-r--r--libc/sysdeps/linux/alpha/sys/ucontext.h5
-rw-r--r--libc/sysdeps/linux/alpha/sys/user.h5
-rw-r--r--libc/sysdeps/linux/alpha/syscall.S5
-rw-r--r--libc/sysdeps/linux/arc/Makefile13
-rw-r--r--libc/sysdeps/linux/arc/Makefile.arch10
-rw-r--r--libc/sysdeps/linux/arc/__longjmp.S38
-rw-r--r--libc/sysdeps/linux/arc/__syscall_error.c15
-rw-r--r--libc/sysdeps/linux/arc/bits/atomic.h60
-rw-r--r--libc/sysdeps/linux/arc/bits/byteswap.h23
-rwxr-xr-xlibc/sysdeps/linux/arc/bits/endian.h15
-rwxr-xr-x[-rw-r--r--]libc/sysdeps/linux/arc/bits/fcntl.h (renamed from libc/sysdeps/linux/nios/bits/fcntl.h)59
-rwxr-xr-xlibc/sysdeps/linux/arc/bits/kernel_types.h59
-rw-r--r--libc/sysdeps/linux/arc/bits/setjmp.h16
-rwxr-xr-xlibc/sysdeps/linux/arc/bits/sigcontextinfo.h15
-rwxr-xr-xlibc/sysdeps/linux/arc/bits/stackinfo.h13
-rw-r--r--libc/sysdeps/linux/arc/bits/syscalls.h191
-rwxr-xr-x[-rw-r--r--]libc/sysdeps/linux/arc/bits/uClibc_arch_features.h (renamed from libc/sysdeps/linux/sh64/bits/uClibc_arch_features.h)31
-rwxr-xr-xlibc/sysdeps/linux/arc/bits/uClibc_page.h35
-rwxr-xr-xlibc/sysdeps/linux/arc/bits/wordsize.h7
-rw-r--r--libc/sysdeps/linux/arc/bsd-_setjmp.S20
-rw-r--r--libc/sysdeps/linux/arc/bsd-setjmp.S20
-rw-r--r--libc/sysdeps/linux/arc/cacheflush.c11
-rw-r--r--libc/sysdeps/linux/arc/clone.S103
-rw-r--r--libc/sysdeps/linux/arc/crt1.S57
-rw-r--r--libc/sysdeps/linux/arc/crti.S27
-rw-r--r--libc/sysdeps/linux/arc/crtn.S29
-rw-r--r--libc/sysdeps/linux/arc/jmpbuf-offsets.h7
-rw-r--r--libc/sysdeps/linux/arc/jmpbuf-unwind.h30
-rw-r--r--libc/sysdeps/linux/arc/setjmp.S39
-rw-r--r--libc/sysdeps/linux/arc/sigaction.c57
-rw-r--r--libc/sysdeps/linux/arc/sys/cachectl.h21
-rwxr-xr-x[-rw-r--r--]libc/sysdeps/linux/arc/sys/procfs.h (renamed from libc/sysdeps/linux/nios/sys/procfs.h)71
-rwxr-xr-xlibc/sysdeps/linux/arc/sys/ucontext.h22
-rwxr-xr-xlibc/sysdeps/linux/arc/sys/user.h23
-rw-r--r--libc/sysdeps/linux/arc/syscall.c17
-rw-r--r--libc/sysdeps/linux/arc/sysdep.h26
-rw-r--r--libc/sysdeps/linux/arc/vfork.S44
-rw-r--r--libc/sysdeps/linux/arc/xstatconv.c1
-rw-r--r--libc/sysdeps/linux/arm/Makefile.arch55
-rw-r--r--libc/sysdeps/linux/arm/__longjmp.S17
-rw-r--r--libc/sysdeps/linux/arm/aeabi_assert.c11
-rw-r--r--libc/sysdeps/linux/arm/aeabi_atexit.c9
-rw-r--r--libc/sysdeps/linux/arm/aeabi_errno_addr.c9
-rw-r--r--libc/sysdeps/linux/arm/aeabi_lcsts.c22
-rw-r--r--libc/sysdeps/linux/arm/aeabi_localeconv.c10
-rw-r--r--libc/sysdeps/linux/arm/aeabi_math.c5
-rw-r--r--libc/sysdeps/linux/arm/aeabi_mb_cur_max.c17
-rw-r--r--libc/sysdeps/linux/arm/aeabi_memclr.c10
-rw-r--r--libc/sysdeps/linux/arm/aeabi_memcpy.c10
-rw-r--r--libc/sysdeps/linux/arm/aeabi_memmove.c10
-rw-r--r--libc/sysdeps/linux/arm/aeabi_memset.c10
-rw-r--r--libc/sysdeps/linux/arm/aeabi_sighandlers.S5
-rw-r--r--libc/sysdeps/linux/arm/aeabi_unwind_cpp_pr1.c20
-rw-r--r--libc/sysdeps/linux/arm/bits/arm_asm.h15
-rw-r--r--libc/sysdeps/linux/arm/bits/arm_bx.h40
-rw-r--r--libc/sysdeps/linux/arm/bits/armsigctx.h5
-rw-r--r--libc/sysdeps/linux/arm/bits/atomic.h135
-rw-r--r--libc/sysdeps/linux/arm/bits/fcntl.h14
-rw-r--r--libc/sysdeps/linux/arm/bits/fenv.h5
-rw-r--r--libc/sysdeps/linux/arm/bits/huge_val.h9
-rw-r--r--libc/sysdeps/linux/arm/bits/kernel_stat.h26
-rw-r--r--libc/sysdeps/linux/arm/bits/kernel_types.h2
-rw-r--r--libc/sysdeps/linux/arm/bits/mathdef.h5
-rw-r--r--libc/sysdeps/linux/arm/bits/setjmp.h24
-rw-r--r--libc/sysdeps/linux/arm/bits/shm.h5
-rw-r--r--libc/sysdeps/linux/arm/bits/sigcontextinfo.h5
-rw-r--r--libc/sysdeps/linux/arm/bits/stackinfo.h5
-rw-r--r--libc/sysdeps/linux/arm/bits/syscalls.h209
-rw-r--r--libc/sysdeps/linux/arm/bits/uClibc_arch_features.h58
-rw-r--r--libc/sysdeps/linux/arm/bits/wordsize.h5
-rw-r--r--libc/sysdeps/linux/arm/brk.c6
-rw-r--r--libc/sysdeps/linux/arm/bsd-_setjmp.S5
-rw-r--r--libc/sysdeps/linux/arm/bsd-setjmp.S5
-rw-r--r--libc/sysdeps/linux/arm/clone.S84
-rw-r--r--libc/sysdeps/linux/arm/crt1.S12
-rw-r--r--libc/sysdeps/linux/arm/crtn.S2
-rw-r--r--libc/sysdeps/linux/arm/find_exidx.c9
-rw-r--r--libc/sysdeps/linux/arm/fpu_control.h5
-rw-r--r--libc/sysdeps/linux/arm/getcontext.S80
-rw-r--r--libc/sysdeps/linux/arm/ioperm.c36
-rw-r--r--libc/sysdeps/linux/arm/iopl.c6
-rw-r--r--libc/sysdeps/linux/arm/jmpbuf-offsets.h19
-rw-r--r--libc/sysdeps/linux/arm/jmpbuf-unwind.h29
-rw-r--r--libc/sysdeps/linux/arm/libc-aeabi_read_tp.S1
-rw-r--r--libc/sysdeps/linux/arm/libc-thumb_atomics.S1
-rw-r--r--libc/sysdeps/linux/arm/makecontext.c73
-rw-r--r--libc/sysdeps/linux/arm/mmap.c74
-rw-r--r--libc/sysdeps/linux/arm/mmap64.S16
-rw-r--r--libc/sysdeps/linux/arm/posix_fadvise.c36
-rw-r--r--libc/sysdeps/linux/arm/posix_fadvise64.c46
-rw-r--r--libc/sysdeps/linux/arm/setcontext.S76
-rw-r--r--libc/sysdeps/linux/arm/setjmp.S7
-rw-r--r--libc/sysdeps/linux/arm/sigaction.c115
-rw-r--r--libc/sysdeps/linux/arm/sigrestorer.S5
-rw-r--r--libc/sysdeps/linux/arm/swapcontext.S63
-rw-r--r--libc/sysdeps/linux/arm/sys/elf.h5
-rw-r--r--libc/sysdeps/linux/arm/sys/io.h8
-rw-r--r--libc/sysdeps/linux/arm/sys/procfs.h5
-rw-r--r--libc/sysdeps/linux/arm/sys/ucontext.h5
-rw-r--r--libc/sysdeps/linux/arm/sys/user.h5
-rw-r--r--libc/sysdeps/linux/arm/syscall-eabi.S14
-rw-r--r--libc/sysdeps/linux/arm/sysdep.h396
-rw-r--r--libc/sysdeps/linux/arm/ucontext_i.sym30
-rw-r--r--libc/sysdeps/linux/arm/unwind.h278
-rw-r--r--libc/sysdeps/linux/arm/vfork.S28
-rw-r--r--libc/sysdeps/linux/avr32/Makefile3
-rw-r--r--libc/sysdeps/linux/avr32/Makefile.arch6
-rw-r--r--libc/sysdeps/linux/avr32/bits/atomic.h1
-rw-r--r--libc/sysdeps/linux/avr32/bits/byteswap.h70
-rw-r--r--libc/sysdeps/linux/avr32/bits/fcntl.h7
-rw-r--r--libc/sysdeps/linux/avr32/bits/kernel_stat.h26
-rw-r--r--libc/sysdeps/linux/avr32/bits/kernel_types.h2
-rw-r--r--libc/sysdeps/linux/avr32/bits/mman.h103
-rw-r--r--libc/sysdeps/linux/avr32/bits/setjmp.h9
-rw-r--r--libc/sysdeps/linux/avr32/bits/stackinfo.h5
-rw-r--r--libc/sysdeps/linux/avr32/bits/syscalls.h128
-rw-r--r--libc/sysdeps/linux/avr32/bits/uClibc_arch_features.h14
-rw-r--r--libc/sysdeps/linux/avr32/brk.c1
-rw-r--r--libc/sysdeps/linux/avr32/clone.c3
-rw-r--r--libc/sysdeps/linux/avr32/crtn.S2
-rw-r--r--libc/sysdeps/linux/avr32/jmpbuf-offsets.h9
-rw-r--r--libc/sysdeps/linux/avr32/jmpbuf-unwind.h14
-rw-r--r--libc/sysdeps/linux/avr32/mmap.c7
-rw-r--r--libc/sysdeps/linux/avr32/prctl.c36
-rw-r--r--libc/sysdeps/linux/avr32/setjmp.S3
-rw-r--r--libc/sysdeps/linux/avr32/sigaction.c45
-rw-r--r--libc/sysdeps/linux/avr32/sys/elf.h5
-rw-r--r--libc/sysdeps/linux/avr32/sys/procfs.h5
-rw-r--r--libc/sysdeps/linux/avr32/sys/ucontext.h5
-rw-r--r--libc/sysdeps/linux/avr32/vfork.S4
-rw-r--r--libc/sysdeps/linux/bfin/Makefile.arch8
-rw-r--r--libc/sysdeps/linux/bfin/__longjmp.S28
-rw-r--r--libc/sysdeps/linux/bfin/bfin_fixed_code.h155
-rw-r--r--libc/sysdeps/linux/bfin/bfin_sram.h1
-rw-r--r--libc/sysdeps/linux/bfin/bits/byteswap.h92
-rw-r--r--libc/sysdeps/linux/bfin/bits/elf-fdpic.h5
-rw-r--r--libc/sysdeps/linux/bfin/bits/fcntl.h15
-rw-r--r--libc/sysdeps/linux/bfin/bits/huge_val.h5
-rw-r--r--libc/sysdeps/linux/bfin/bits/kernel_stat.h22
-rw-r--r--libc/sysdeps/linux/bfin/bits/kernel_types.h2
-rw-r--r--libc/sysdeps/linux/bfin/bits/mman.h96
-rw-r--r--libc/sysdeps/linux/bfin/bits/setjmp.h15
-rw-r--r--libc/sysdeps/linux/bfin/bits/sigcontextinfo.h5
-rw-r--r--libc/sysdeps/linux/bfin/bits/stackinfo.h5
-rw-r--r--libc/sysdeps/linux/bfin/bits/syscalls.h163
-rw-r--r--libc/sysdeps/linux/bfin/bits/typesizes.h5
-rw-r--r--libc/sysdeps/linux/bfin/bits/uClibc_arch_features.h20
-rw-r--r--libc/sysdeps/linux/bfin/bits/wordsize.h5
-rw-r--r--libc/sysdeps/linux/bfin/bsd-_setjmp.S24
-rw-r--r--libc/sysdeps/linux/bfin/cacheflush.c15
-rw-r--r--libc/sysdeps/linux/bfin/clone.c30
-rw-r--r--libc/sysdeps/linux/bfin/crt1.S8
-rw-r--r--libc/sysdeps/linux/bfin/crti.S7
-rw-r--r--libc/sysdeps/linux/bfin/crtn.S7
-rw-r--r--libc/sysdeps/linux/bfin/crtreloc.c9
-rw-r--r--libc/sysdeps/linux/bfin/dma-memcpy.c4
-rw-r--r--libc/sysdeps/linux/bfin/jmpbuf-offsets.h8
-rw-r--r--libc/sysdeps/linux/bfin/jmpbuf-unwind.h11
-rw-r--r--libc/sysdeps/linux/bfin/setjmp.S2
-rw-r--r--libc/sysdeps/linux/bfin/sram-alloc.c4
-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/bfin/sys/elf.h5
-rw-r--r--libc/sysdeps/linux/bfin/sys/io.h7
-rw-r--r--libc/sysdeps/linux/bfin/sys/procfs.h5
-rw-r--r--libc/sysdeps/linux/bfin/sys/reg.h133
-rw-r--r--libc/sysdeps/linux/bfin/sys/ucontext.h11
-rw-r--r--libc/sysdeps/linux/bfin/sys/user.h57
-rw-r--r--libc/sysdeps/linux/bfin/syscall.c57
-rw-r--r--libc/sysdeps/linux/bfin/sysdep.h3
-rw-r--r--libc/sysdeps/linux/bfin/vfork.S10
-rw-r--r--libc/sysdeps/linux/c6x/Makefile (renamed from libc/sysdeps/linux/vax/Makefile)4
-rw-r--r--libc/sysdeps/linux/c6x/Makefile.arch10
-rw-r--r--libc/sysdeps/linux/c6x/__longjmp.S46
-rw-r--r--libc/sysdeps/linux/c6x/_vfork.S66
-rw-r--r--libc/sysdeps/linux/c6x/bits/byteswap.h34
-rw-r--r--libc/sysdeps/linux/c6x/bits/elf-dsbt.h117
-rw-r--r--libc/sysdeps/linux/c6x/bits/endian.h (renamed from libc/sysdeps/linux/vax/bits/endian.h)8
-rw-r--r--libc/sysdeps/linux/c6x/bits/fcntl.h (renamed from libc/sysdeps/linux/i960/bits/fcntl.h)27
-rw-r--r--libc/sysdeps/linux/c6x/bits/ipc.h (renamed from libc/sysdeps/linux/vax/bits/ipc.h)36
-rw-r--r--libc/sysdeps/linux/c6x/bits/kernel_stat.h49
-rw-r--r--libc/sysdeps/linux/c6x/bits/kernel_types.h (renamed from libc/sysdeps/linux/nios/bits/kernel_types.h)43
-rw-r--r--libc/sysdeps/linux/c6x/bits/mathdef.h (renamed from libc/sysdeps/linux/nios/bits/mathdef.h)20
-rw-r--r--libc/sysdeps/linux/c6x/bits/nan.h56
-rw-r--r--libc/sysdeps/linux/c6x/bits/poll.h (renamed from libc/sysdeps/linux/v850/bits/poll.h)5
-rw-r--r--libc/sysdeps/linux/c6x/bits/resource.h208
-rw-r--r--libc/sysdeps/linux/c6x/bits/setjmp.h33
-rw-r--r--libc/sysdeps/linux/c6x/bits/sigcontextinfo.h25
-rw-r--r--libc/sysdeps/linux/c6x/bits/stackinfo.h27
-rw-r--r--libc/sysdeps/linux/c6x/bits/syscalls.h184
-rw-r--r--libc/sysdeps/linux/c6x/bits/uClibc_arch_features.h (renamed from libc/sysdeps/linux/nios/bits/uClibc_arch_features.h)19
-rw-r--r--libc/sysdeps/linux/c6x/bits/wordsize.h (renamed from libc/sysdeps/linux/v850/bits/wordsize.h)5
-rw-r--r--libc/sysdeps/linux/c6x/brk.c53
-rw-r--r--libc/sysdeps/linux/c6x/bsd-_setjmp.s47
-rw-r--r--libc/sysdeps/linux/c6x/bsd-setjmp.S66
-rw-r--r--libc/sysdeps/linux/c6x/clone.S97
-rw-r--r--libc/sysdeps/linux/c6x/crt1.S66
-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/jmpbuf-offsets.h22
-rw-r--r--libc/sysdeps/linux/c6x/jmpbuf-unwind.h28
-rw-r--r--libc/sysdeps/linux/c6x/prctl.c43
-rw-r--r--libc/sysdeps/linux/c6x/setjmp.s42
-rw-r--r--libc/sysdeps/linux/c6x/sigaction.c121
-rw-r--r--libc/sysdeps/linux/c6x/sys/procfs.h (renamed from libc/sysdeps/linux/i960/sys/procfs.h)13
-rw-r--r--libc/sysdeps/linux/c6x/sys/ptrace.h (renamed from libc/sysdeps/linux/xtensa/sys/ptrace.h)46
-rw-r--r--libc/sysdeps/linux/c6x/sys/reg.h25
-rw-r--r--libc/sysdeps/linux/c6x/sys/ucontext.h38
-rw-r--r--libc/sysdeps/linux/c6x/sys/user.h27
-rw-r--r--libc/sysdeps/linux/c6x/syscall.c49
-rw-r--r--libc/sysdeps/linux/common-generic/bits/align64bit.h17
-rw-r--r--libc/sysdeps/linux/common-generic/bits/dirent.h53
-rw-r--r--libc/sysdeps/linux/common-generic/bits/kernel_stat.h28
-rw-r--r--libc/sysdeps/linux/common-generic/bits/stat.h195
-rw-r--r--libc/sysdeps/linux/common-generic/bits/statfs.h78
-rw-r--r--libc/sysdeps/linux/common/Makefile.in181
-rw-r--r--libc/sysdeps/linux/common/__rt_sigtimedwait.c96
-rw-r--r--libc/sysdeps/linux/common/__rt_sigwaitinfo.c25
-rw-r--r--libc/sysdeps/linux/common/__socketcall.c14
-rw-r--r--libc/sysdeps/linux/common/__syscall_fcntl.c77
-rw-r--r--libc/sysdeps/linux/common/__syscall_fcntl64.c34
-rw-r--r--libc/sysdeps/linux/common/__syscall_rt_sigaction.c5
-rw-r--r--libc/sysdeps/linux/common/__syscall_sigaction.c3
-rw-r--r--libc/sysdeps/linux/common/_exit.c30
-rw-r--r--libc/sysdeps/linux/common/access.c12
-rw-r--r--libc/sysdeps/linux/common/acct.c2
-rw-r--r--libc/sysdeps/linux/common/adjtimex.c4
-rw-r--r--libc/sysdeps/linux/common/alarm.c9
-rw-r--r--libc/sysdeps/linux/common/arch_prctl.c4
-rw-r--r--libc/sysdeps/linux/common/bdflush.c8
-rw-r--r--libc/sysdeps/linux/common/bits/atomic.h5
-rw-r--r--libc/sysdeps/linux/common/bits/byteswap-common.h107
-rw-r--r--libc/sysdeps/linux/common/bits/byteswap.h88
-rw-r--r--libc/sysdeps/linux/common/bits/cmathcalls.h28
-rw-r--r--libc/sysdeps/linux/common/bits/confname.h96
-rw-r--r--libc/sysdeps/linux/common/bits/dirent.h5
-rw-r--r--libc/sysdeps/linux/common/bits/dlfcn.h9
-rw-r--r--libc/sysdeps/linux/common/bits/environments.h33
-rw-r--r--libc/sysdeps/linux/common/bits/epoll.h29
-rw-r--r--libc/sysdeps/linux/common/bits/errno.h9
-rw-r--r--libc/sysdeps/linux/common/bits/eventfd.h31
-rw-r--r--libc/sysdeps/linux/common/bits/fenv.h7
-rw-r--r--libc/sysdeps/linux/common/bits/getopt.h47
-rw-r--r--libc/sysdeps/linux/common/bits/getopt_int.h136
-rw-r--r--libc/sysdeps/linux/common/bits/huge_val.h5
-rw-r--r--libc/sysdeps/linux/common/bits/huge_valf.h5
-rw-r--r--libc/sysdeps/linux/common/bits/huge_vall.h5
-rw-r--r--libc/sysdeps/linux/common/bits/in.h68
-rw-r--r--libc/sysdeps/linux/common/bits/inf.h5
-rw-r--r--libc/sysdeps/linux/common/bits/initspin.h5
-rw-r--r--libc/sysdeps/linux/common/bits/inotify.h29
-rw-r--r--libc/sysdeps/linux/common/bits/ioctl-types.h5
-rw-r--r--libc/sysdeps/linux/common/bits/ioctls.h13
-rw-r--r--libc/sysdeps/linux/common/bits/ipc.h5
-rw-r--r--libc/sysdeps/linux/common/bits/kernel-features.h514
-rw-r--r--libc/sysdeps/linux/common/bits/kernel_sigaction.h58
-rw-r--r--libc/sysdeps/linux/common/bits/local_lim.h20
-rw-r--r--libc/sysdeps/linux/common/bits/locale.h7
-rw-r--r--libc/sysdeps/linux/common/bits/mathcalls.h225
-rw-r--r--libc/sysdeps/linux/common/bits/mathdef.h5
-rw-r--r--libc/sysdeps/linux/common/bits/mathinline.h2
-rw-r--r--libc/sysdeps/linux/common/bits/mman-common.h (renamed from libc/sysdeps/linux/arm/bits/mman.h)31
-rw-r--r--libc/sysdeps/linux/common/bits/mman.h98
-rw-r--r--libc/sysdeps/linux/common/bits/mqueue.h5
-rw-r--r--libc/sysdeps/linux/common/bits/msq.h5
-rw-r--r--libc/sysdeps/linux/common/bits/nan.h5
-rw-r--r--libc/sysdeps/linux/common/bits/netdb.h5
-rw-r--r--libc/sysdeps/linux/common/bits/poll.h5
-rw-r--r--libc/sysdeps/linux/common/bits/posix1_lim.h5
-rw-r--r--libc/sysdeps/linux/common/bits/posix2_lim.h5
-rw-r--r--libc/sysdeps/linux/common/bits/posix_opt.h101
-rw-r--r--libc/sysdeps/linux/common/bits/resource.h5
-rw-r--r--libc/sysdeps/linux/common/bits/sched.h133
-rw-r--r--libc/sysdeps/linux/common/bits/select.h5
-rw-r--r--libc/sysdeps/linux/common/bits/sem.h5
-rw-r--r--libc/sysdeps/linux/common/bits/shm.h9
-rw-r--r--libc/sysdeps/linux/common/bits/sigaction.h47
-rw-r--r--libc/sysdeps/linux/common/bits/sigcontext.h8
-rw-r--r--libc/sysdeps/linux/common/bits/sigcontextinfo.h5
-rw-r--r--libc/sysdeps/linux/common/bits/siginfo.h16
-rw-r--r--libc/sysdeps/linux/common/bits/signalfd.h29
-rw-r--r--libc/sysdeps/linux/common/bits/signum.h27
-rw-r--r--libc/sysdeps/linux/common/bits/sigset.h220
-rw-r--r--libc/sysdeps/linux/common/bits/sigstack.h7
-rw-r--r--libc/sysdeps/linux/common/bits/sigthread.h15
-rw-r--r--libc/sysdeps/linux/common/bits/sockaddr.h5
-rw-r--r--libc/sysdeps/linux/common/bits/socket.h90
-rw-r--r--libc/sysdeps/linux/common/bits/socket_type.h54
-rw-r--r--libc/sysdeps/linux/common/bits/stab.def5
-rw-r--r--libc/sysdeps/linux/common/bits/stackinfo.h5
-rw-r--r--libc/sysdeps/linux/common/bits/stat.h16
-rw-r--r--libc/sysdeps/linux/common/bits/statfs.h5
-rw-r--r--libc/sysdeps/linux/common/bits/statvfs.h11
-rw-r--r--libc/sysdeps/linux/common/bits/stdio.h5
-rw-r--r--libc/sysdeps/linux/common/bits/stdio_lim.h9
-rw-r--r--libc/sysdeps/linux/common/bits/syscalls-common.h119
-rw-r--r--libc/sysdeps/linux/common/bits/syscalls.h3
-rw-r--r--libc/sysdeps/linux/common/bits/termios.h5
-rw-r--r--libc/sysdeps/linux/common/bits/time.h21
-rw-r--r--libc/sysdeps/linux/common/bits/timerfd.h29
-rw-r--r--libc/sysdeps/linux/common/bits/types.h29
-rw-r--r--libc/sysdeps/linux/common/bits/typesizes.h5
-rw-r--r--libc/sysdeps/linux/common/bits/uClibc_alloc.h26
-rw-r--r--libc/sysdeps/linux/common/bits/uClibc_arch_features.h14
-rw-r--r--libc/sysdeps/linux/common/bits/uClibc_charclass.h40
-rw-r--r--libc/sysdeps/linux/common/bits/uClibc_ctype.h259
-rw-r--r--libc/sysdeps/linux/common/bits/uClibc_errno.h43
-rw-r--r--libc/sysdeps/linux/common/bits/uClibc_fpmax.h8
-rw-r--r--libc/sysdeps/linux/common/bits/uClibc_local_lim.h13
-rw-r--r--libc/sysdeps/linux/common/bits/uClibc_locale.h147
-rw-r--r--libc/sysdeps/linux/common/bits/uClibc_mutex.h79
-rw-r--r--libc/sysdeps/linux/common/bits/uClibc_page.h5
-rw-r--r--libc/sysdeps/linux/common/bits/uClibc_posix_opt.h136
-rw-r--r--libc/sysdeps/linux/common/bits/uClibc_pthread.h15
-rw-r--r--libc/sysdeps/linux/common/bits/uClibc_stdio.h110
-rw-r--r--libc/sysdeps/linux/common/bits/uClibc_touplow.h9
-rw-r--r--libc/sysdeps/linux/common/bits/uClibc_uintmaxtostr.h15
-rw-r--r--libc/sysdeps/linux/common/bits/uClibc_uwchar.h5
-rw-r--r--libc/sysdeps/linux/common/bits/uClibc_va_copy.h5
-rw-r--r--libc/sysdeps/linux/common/bits/uio.h6
-rw-r--r--libc/sysdeps/linux/common/bits/ustat.h5
-rw-r--r--libc/sysdeps/linux/common/bits/utmp.h9
-rw-r--r--libc/sysdeps/linux/common/bits/utmpx.h7
-rw-r--r--libc/sysdeps/linux/common/bits/utsname.h5
-rw-r--r--libc/sysdeps/linux/common/bits/waitflags.h5
-rw-r--r--libc/sysdeps/linux/common/bits/waitstatus.h21
-rw-r--r--libc/sysdeps/linux/common/bits/wchar.h5
-rw-r--r--libc/sysdeps/linux/common/bits/xopen_lim.h5
-rw-r--r--libc/sysdeps/linux/common/brk.c (renamed from libc/sysdeps/linux/bfin/brk.c)26
-rw-r--r--libc/sysdeps/linux/common/capget.c11
-rw-r--r--libc/sysdeps/linux/common/capset.c11
-rw-r--r--libc/sysdeps/linux/common/chdir.c11
-rw-r--r--libc/sysdeps/linux/common/chmod.c14
-rw-r--r--libc/sysdeps/linux/common/chown.c30
-rw-r--r--libc/sysdeps/linux/common/chroot.c2
-rw-r--r--libc/sysdeps/linux/common/clock_adjtime.c15
-rw-r--r--libc/sysdeps/linux/common/clock_getres.c7
-rw-r--r--libc/sysdeps/linux/common/clock_gettime.c15
-rw-r--r--libc/sysdeps/linux/common/clock_settime.c5
-rw-r--r--libc/sysdeps/linux/common/close.c15
-rw-r--r--libc/sysdeps/linux/common/cmsg_nxthdr.c10
-rw-r--r--libc/sysdeps/linux/common/creat.c18
-rw-r--r--libc/sysdeps/linux/common/creat64.c21
-rw-r--r--libc/sysdeps/linux/common/create_module.c21
-rw-r--r--libc/sysdeps/linux/common/delete_module.c10
-rw-r--r--libc/sysdeps/linux/common/dl-osinfo.h9
-rw-r--r--libc/sysdeps/linux/common/dup.c2
-rw-r--r--libc/sysdeps/linux/common/dup2.c20
-rw-r--r--libc/sysdeps/linux/common/dup3.c16
-rw-r--r--libc/sysdeps/linux/common/epoll.c71
-rw-r--r--libc/sysdeps/linux/common/epoll_create.c8
-rw-r--r--libc/sysdeps/linux/common/epoll_ctl.c8
-rw-r--r--libc/sysdeps/linux/common/epoll_pwait.c8
-rw-r--r--libc/sysdeps/linux/common/epoll_wait.c8
-rw-r--r--libc/sysdeps/linux/common/euidaccess.c9
-rw-r--r--libc/sysdeps/linux/common/eventfd.c30
-rw-r--r--libc/sysdeps/linux/common/eventfd_read.c (renamed from libc/sysdeps/linux/e1/bits/wordsize.h)23
-rw-r--r--libc/sysdeps/linux/common/eventfd_write.c28
-rw-r--r--libc/sysdeps/linux/common/execve.c3
-rw-r--r--libc/sysdeps/linux/common/faccessat.c17
-rw-r--r--libc/sysdeps/linux/common/fallocate.c43
-rw-r--r--libc/sysdeps/linux/common/fallocate64.c45
-rw-r--r--libc/sysdeps/linux/common/fanotify.c32
-rw-r--r--libc/sysdeps/linux/common/fchdir.c6
-rw-r--r--libc/sysdeps/linux/common/fchmod.c2
-rw-r--r--libc/sysdeps/linux/common/fchmodat.c38
-rw-r--r--libc/sysdeps/linux/common/fchown.c4
-rw-r--r--libc/sysdeps/linux/common/fchownat.c17
-rw-r--r--libc/sysdeps/linux/common/fdatasync.c13
-rw-r--r--libc/sysdeps/linux/common/flock.c2
-rw-r--r--libc/sysdeps/linux/common/fork.c42
-rw-r--r--libc/sysdeps/linux/common/fpu_control.h5
-rw-r--r--libc/sysdeps/linux/common/fstat.c50
-rw-r--r--libc/sysdeps/linux/common/fstat64.c22
-rw-r--r--libc/sysdeps/linux/common/fstatat.c44
-rw-r--r--libc/sysdeps/linux/common/fstatat64.c47
-rw-r--r--libc/sysdeps/linux/common/fstatfs.c31
-rw-r--r--libc/sysdeps/linux/common/fsync.c9
-rw-r--r--libc/sysdeps/linux/common/ftruncate.c17
-rw-r--r--libc/sysdeps/linux/common/ftruncate64.c69
-rw-r--r--libc/sysdeps/linux/common/futimens.c29
-rw-r--r--libc/sysdeps/linux/common/futimesat.c16
-rw-r--r--libc/sysdeps/linux/common/get_kernel_syms.c12
-rw-r--r--libc/sysdeps/linux/common/getcwd.c21
-rw-r--r--libc/sysdeps/linux/common/getdents.c84
-rw-r--r--libc/sysdeps/linux/common/getdents64.c39
-rw-r--r--libc/sysdeps/linux/common/getdirname.c14
-rw-r--r--libc/sysdeps/linux/common/getdomainname.c22
-rw-r--r--libc/sysdeps/linux/common/getdtablesize.c2
-rw-r--r--libc/sysdeps/linux/common/getegid.c24
-rw-r--r--libc/sysdeps/linux/common/geteuid.c23
-rw-r--r--libc/sysdeps/linux/common/getgid.c9
-rw-r--r--libc/sysdeps/linux/common/getgroups.c22
-rw-r--r--libc/sysdeps/linux/common/gethostname.c4
-rw-r--r--libc/sysdeps/linux/common/getitimer.c2
-rw-r--r--libc/sysdeps/linux/common/getpagesize.c8
-rw-r--r--libc/sysdeps/linux/common/getpgid.c7
-rw-r--r--libc/sysdeps/linux/common/getpgrp.c9
-rw-r--r--libc/sysdeps/linux/common/getpid.c13
-rw-r--r--libc/sysdeps/linux/common/getppid.c9
-rw-r--r--libc/sysdeps/linux/common/getpriority.c3
-rw-r--r--libc/sysdeps/linux/common/getrandom.c14
-rw-r--r--libc/sysdeps/linux/common/getresgid.c2
-rw-r--r--libc/sysdeps/linux/common/getresuid.c2
-rw-r--r--libc/sysdeps/linux/common/getrlimit.c21
-rw-r--r--libc/sysdeps/linux/common/getrlimit64.c13
-rw-r--r--libc/sysdeps/linux/common/getrusage.c3
-rw-r--r--libc/sysdeps/linux/common/getsid.c3
-rw-r--r--libc/sysdeps/linux/common/gettimeofday.c7
-rw-r--r--libc/sysdeps/linux/common/getuid.c9
-rw-r--r--libc/sysdeps/linux/common/hp-timing.h5
-rw-r--r--libc/sysdeps/linux/common/init_module.c11
-rw-r--r--libc/sysdeps/linux/common/inotify.c17
-rw-r--r--libc/sysdeps/linux/common/ioctl.c29
-rw-r--r--libc/sysdeps/linux/common/ioperm.c5
-rw-r--r--libc/sysdeps/linux/common/iopl.c2
-rw-r--r--libc/sysdeps/linux/common/jmpbuf-offsets.h6
-rw-r--r--libc/sysdeps/linux/common/kill.c3
-rw-r--r--libc/sysdeps/linux/common/klogctl.c2
-rw-r--r--libc/sysdeps/linux/common/lchown.c29
-rw-r--r--libc/sysdeps/linux/common/libgcc_s.h2
-rw-r--r--libc/sysdeps/linux/common/link.c11
-rw-r--r--libc/sysdeps/linux/common/linkat.c17
-rw-r--r--libc/sysdeps/linux/common/llseek.c45
-rw-r--r--libc/sysdeps/linux/common/longjmp.c16
-rw-r--r--libc/sysdeps/linux/common/lseek.c58
-rw-r--r--libc/sysdeps/linux/common/lstat.c47
-rw-r--r--libc/sysdeps/linux/common/lstat64.c20
-rw-r--r--libc/sysdeps/linux/common/lutimes.c38
-rw-r--r--libc/sysdeps/linux/common/madvise.c2
-rw-r--r--libc/sysdeps/linux/common/makedev.c42
-rw-r--r--libc/sysdeps/linux/common/mincore.c2
-rw-r--r--libc/sysdeps/linux/common/mkdir.c13
-rw-r--r--libc/sysdeps/linux/common/mkdirat.c17
-rw-r--r--libc/sysdeps/linux/common/mkfifo.c6
-rw-r--r--libc/sysdeps/linux/common/mkfifoat.c19
-rw-r--r--libc/sysdeps/linux/common/mknod.c28
-rw-r--r--libc/sysdeps/linux/common/mknodat.c25
-rw-r--r--libc/sysdeps/linux/common/mlock.c2
-rw-r--r--libc/sysdeps/linux/common/mlockall.c2
-rw-r--r--libc/sysdeps/linux/common/mmap.c91
-rw-r--r--libc/sysdeps/linux/common/mmap64.c60
-rw-r--r--libc/sysdeps/linux/common/modify_ldt.c2
-rw-r--r--libc/sysdeps/linux/common/mount.c4
-rw-r--r--libc/sysdeps/linux/common/mprotect.c4
-rw-r--r--libc/sysdeps/linux/common/mremap.c6
-rw-r--r--libc/sysdeps/linux/common/msync.c13
-rw-r--r--libc/sysdeps/linux/common/munlock.c2
-rw-r--r--libc/sysdeps/linux/common/munlockall.c2
-rw-r--r--libc/sysdeps/linux/common/munmap.c5
-rw-r--r--libc/sysdeps/linux/common/nanosleep.c17
-rw-r--r--libc/sysdeps/linux/common/nice.c14
-rw-r--r--libc/sysdeps/linux/common/noophooks.c7
-rw-r--r--libc/sysdeps/linux/common/not-cancel.h152
-rw-r--r--libc/sysdeps/linux/common/ntp_gettime.c6
-rw-r--r--libc/sysdeps/linux/common/open.c68
-rw-r--r--libc/sysdeps/linux/common/open64.c51
-rw-r--r--libc/sysdeps/linux/common/openat.c32
-rw-r--r--libc/sysdeps/linux/common/openat64.c21
-rw-r--r--libc/sysdeps/linux/common/pause.c33
-rw-r--r--libc/sysdeps/linux/common/personality.c2
-rw-r--r--libc/sysdeps/linux/common/pipe.c11
-rw-r--r--libc/sysdeps/linux/common/pipe2.c16
-rw-r--r--libc/sysdeps/linux/common/pivot_root.c10
-rw-r--r--libc/sysdeps/linux/common/poll.c56
-rw-r--r--libc/sysdeps/linux/common/posix_fadvise.c94
-rw-r--r--libc/sysdeps/linux/common/posix_fadvise64.c113
-rw-r--r--libc/sysdeps/linux/common/posix_fallocate.c28
-rw-r--r--libc/sysdeps/linux/common/posix_fallocate64.c31
-rw-r--r--libc/sysdeps/linux/common/posix_madvise.c25
-rw-r--r--libc/sysdeps/linux/common/ppoll.c49
-rw-r--r--libc/sysdeps/linux/common/prctl.c6
-rw-r--r--libc/sysdeps/linux/common/pread_write.c238
-rw-r--r--libc/sysdeps/linux/common/pselect.c119
-rw-r--r--libc/sysdeps/linux/common/ptrace.c2
-rw-r--r--libc/sysdeps/linux/common/query_module.c9
-rw-r--r--libc/sysdeps/linux/common/quotactl.c2
-rw-r--r--libc/sysdeps/linux/common/read.c13
-rw-r--r--libc/sysdeps/linux/common/readahead.c39
-rw-r--r--libc/sysdeps/linux/common/readlink.c11
-rw-r--r--libc/sysdeps/linux/common/readlinkat.c17
-rw-r--r--libc/sysdeps/linux/common/readv.c24
-rw-r--r--libc/sysdeps/linux/common/reboot.c2
-rw-r--r--libc/sysdeps/linux/common/remap_file_pages.c2
-rw-r--r--libc/sysdeps/linux/common/rename.c18
-rw-r--r--libc/sysdeps/linux/common/renameat.c17
-rw-r--r--libc/sysdeps/linux/common/rmdir.c11
-rw-r--r--libc/sysdeps/linux/common/sbrk.c2
-rw-r--r--libc/sysdeps/linux/common/sched_cpucount.c59
-rw-r--r--libc/sysdeps/linux/common/sched_get_priority_max.c2
-rw-r--r--libc/sysdeps/linux/common/sched_get_priority_min.c2
-rw-r--r--libc/sysdeps/linux/common/sched_getaffinity.c27
-rw-r--r--libc/sysdeps/linux/common/sched_getcpu.c24
-rw-r--r--libc/sysdeps/linux/common/sched_getparam.c2
-rw-r--r--libc/sysdeps/linux/common/sched_getscheduler.c2
-rw-r--r--libc/sysdeps/linux/common/sched_rr_get_interval.c2
-rw-r--r--libc/sysdeps/linux/common/sched_setaffinity.c34
-rw-r--r--libc/sysdeps/linux/common/sched_setparam.c2
-rw-r--r--libc/sysdeps/linux/common/sched_setscheduler.c2
-rw-r--r--libc/sysdeps/linux/common/sched_yield.c2
-rw-r--r--libc/sysdeps/linux/common/select.c64
-rw-r--r--libc/sysdeps/linux/common/sendfile.c63
-rw-r--r--libc/sysdeps/linux/common/sendfile64.c13
-rw-r--r--libc/sysdeps/linux/common/setdomainname.c2
-rw-r--r--libc/sysdeps/linux/common/setegid.c7
-rw-r--r--libc/sysdeps/linux/common/seteuid.c7
-rw-r--r--libc/sysdeps/linux/common/setfsgid.c4
-rw-r--r--libc/sysdeps/linux/common/setfsuid.c4
-rw-r--r--libc/sysdeps/linux/common/setgid.c4
-rw-r--r--libc/sysdeps/linux/common/setgroups.c22
-rw-r--r--libc/sysdeps/linux/common/sethostname.c2
-rw-r--r--libc/sysdeps/linux/common/setitimer.c3
-rw-r--r--libc/sysdeps/linux/common/setns.c15
-rw-r--r--libc/sysdeps/linux/common/setpgid.c3
-rw-r--r--libc/sysdeps/linux/common/setpgrp.c3
-rw-r--r--libc/sysdeps/linux/common/setpriority.c3
-rw-r--r--libc/sysdeps/linux/common/setregid.c7
-rw-r--r--libc/sysdeps/linux/common/setresgid.c8
-rw-r--r--libc/sysdeps/linux/common/setresuid.c8
-rw-r--r--libc/sysdeps/linux/common/setreuid.c7
-rw-r--r--libc/sysdeps/linux/common/setrlimit.c34
-rw-r--r--libc/sysdeps/linux/common/setrlimit64.c13
-rw-r--r--libc/sysdeps/linux/common/setsid.c4
-rw-r--r--libc/sysdeps/linux/common/settimeofday.c31
-rw-r--r--libc/sysdeps/linux/common/setuid.c6
-rw-r--r--libc/sysdeps/linux/common/sigaltstack.c2
-rw-r--r--libc/sysdeps/linux/common/signalfd.c37
-rw-r--r--libc/sysdeps/linux/common/sigpending.c6
-rw-r--r--libc/sysdeps/linux/common/sigprocmask.c77
-rw-r--r--libc/sysdeps/linux/common/sigqueue.c51
-rw-r--r--libc/sysdeps/linux/common/sigsuspend.c30
-rw-r--r--libc/sysdeps/linux/common/splice.c19
-rw-r--r--libc/sysdeps/linux/common/ssp-local.c13
-rw-r--r--libc/sysdeps/linux/common/ssp.c147
-rw-r--r--libc/sysdeps/linux/common/stat.c44
-rw-r--r--libc/sysdeps/linux/common/stat64.c26
-rw-r--r--libc/sysdeps/linux/common/statfs.c47
-rw-r--r--libc/sysdeps/linux/common/stime.c22
-rw-r--r--libc/sysdeps/linux/common/stubs.c490
-rw-r--r--libc/sysdeps/linux/common/swapoff.c2
-rw-r--r--libc/sysdeps/linux/common/swapon.c2
-rw-r--r--libc/sysdeps/linux/common/symlink.c17
-rw-r--r--libc/sysdeps/linux/common/symlinkat.c17
-rw-r--r--libc/sysdeps/linux/common/sync.c16
-rw-r--r--libc/sysdeps/linux/common/sync_file_range.c54
-rw-r--r--libc/sysdeps/linux/common/syncfs.c13
-rw-r--r--libc/sysdeps/linux/common/sys/acct.h80
-rw-r--r--libc/sysdeps/linux/common/sys/epoll.h49
-rw-r--r--libc/sysdeps/linux/common/sys/eventfd.h44
-rw-r--r--libc/sysdeps/linux/common/sys/fanotify.h96
-rw-r--r--libc/sysdeps/linux/common/sys/inotify.h17
-rw-r--r--libc/sysdeps/linux/common/sys/prctl.h5
-rw-r--r--libc/sysdeps/linux/common/sys/ptrace.h78
-rw-r--r--libc/sysdeps/linux/common/sys/random.h33
-rw-r--r--libc/sysdeps/linux/common/sys/signalfd.h58
-rw-r--r--libc/sysdeps/linux/common/sys/timerfd.h52
-rw-r--r--libc/sysdeps/linux/common/sys/user.h2
-rw-r--r--libc/sysdeps/linux/common/syscall.c12
-rw-r--r--libc/sysdeps/linux/common/syscalls.h24
-rw-r--r--libc/sysdeps/linux/common/sysctl.c28
-rw-r--r--libc/sysdeps/linux/common/sysdep.h176
-rw-r--r--libc/sysdeps/linux/common/sysfs.c2
-rw-r--r--libc/sysdeps/linux/common/sysinfo.c7
-rw-r--r--libc/sysdeps/linux/common/tee.c7
-rw-r--r--libc/sysdeps/linux/common/time.c21
-rw-r--r--libc/sysdeps/linux/common/timerfd.c32
-rw-r--r--libc/sysdeps/linux/common/times.c4
-rw-r--r--libc/sysdeps/linux/common/truncate.c22
-rw-r--r--libc/sysdeps/linux/common/truncate64.c75
-rw-r--r--libc/sysdeps/linux/common/ulimit.c11
-rw-r--r--libc/sysdeps/linux/common/umask.c8
-rw-r--r--libc/sysdeps/linux/common/umount.c28
-rw-r--r--libc/sysdeps/linux/common/umount2.c16
-rw-r--r--libc/sysdeps/linux/common/uname.c4
-rw-r--r--libc/sysdeps/linux/common/unlink.c12
-rw-r--r--libc/sysdeps/linux/common/unlinkat.c17
-rw-r--r--libc/sysdeps/linux/common/unshare.c15
-rw-r--r--libc/sysdeps/linux/common/unwind.h219
-rw-r--r--libc/sysdeps/linux/common/uselib.c2
-rw-r--r--libc/sysdeps/linux/common/ustat.c19
-rw-r--r--libc/sysdeps/linux/common/utime.c41
-rw-r--r--libc/sysdeps/linux/common/utimensat.c18
-rw-r--r--libc/sysdeps/linux/common/utimes.c34
-rw-r--r--libc/sysdeps/linux/common/vfork.c35
-rw-r--r--libc/sysdeps/linux/common/vhangup.c2
-rw-r--r--libc/sysdeps/linux/common/vmsplice.c17
-rw-r--r--libc/sysdeps/linux/common/wait.c19
-rw-r--r--libc/sysdeps/linux/common/wait3.c17
-rw-r--r--libc/sysdeps/linux/common/wait4.c17
-rw-r--r--libc/sysdeps/linux/common/waitid.c49
-rw-r--r--libc/sysdeps/linux/common/waitpid.c21
-rw-r--r--libc/sysdeps/linux/common/write.c18
-rw-r--r--libc/sysdeps/linux/common/writev.c20
-rw-r--r--libc/sysdeps/linux/common/xattr.c102
-rw-r--r--libc/sysdeps/linux/common/xstatconv.c62
-rw-r--r--libc/sysdeps/linux/common/xstatconv.h9
-rw-r--r--libc/sysdeps/linux/cris/Makefile.arch10
-rw-r--r--libc/sysdeps/linux/cris/__longjmp.S7
-rw-r--r--libc/sysdeps/linux/cris/bits/byteswap.h79
-rw-r--r--libc/sysdeps/linux/cris/bits/fcntl.h13
-rw-r--r--libc/sysdeps/linux/cris/bits/kernel_stat.h42
-rw-r--r--libc/sysdeps/linux/cris/bits/kernel_types.h2
-rw-r--r--libc/sysdeps/linux/cris/bits/mathcalls.h333
-rw-r--r--libc/sysdeps/linux/cris/bits/mman.h98
-rw-r--r--libc/sysdeps/linux/cris/bits/setjmp.h32
-rw-r--r--libc/sysdeps/linux/cris/bits/stackinfo.h5
-rw-r--r--libc/sysdeps/linux/cris/bits/syscalls.h77
-rw-r--r--libc/sysdeps/linux/cris/bits/termios.h5
-rw-r--r--libc/sysdeps/linux/cris/bits/uClibc_arch_features.h16
-rw-r--r--libc/sysdeps/linux/cris/bits/uClibc_page.h4
-rw-r--r--libc/sysdeps/linux/cris/bits/wordsize.h3
-rw-r--r--libc/sysdeps/linux/cris/brk.c1
-rw-r--r--libc/sysdeps/linux/cris/clone.S3
-rw-r--r--libc/sysdeps/linux/cris/crti.S8
-rw-r--r--libc/sysdeps/linux/cris/crtn.S2
-rw-r--r--libc/sysdeps/linux/cris/fork.c19
-rw-r--r--libc/sysdeps/linux/cris/jmpbuf-offsets.h8
-rw-r--r--libc/sysdeps/linux/cris/jmpbuf-unwind.h12
-rw-r--r--libc/sysdeps/linux/cris/sbrk.c1
-rw-r--r--libc/sysdeps/linux/cris/setjmp.S6
-rw-r--r--libc/sysdeps/linux/cris/sys/procfs.h9
-rw-r--r--libc/sysdeps/linux/cris/sys/ucontext.h5
-rw-r--r--libc/sysdeps/linux/cris/sys/user.h81
-rw-r--r--libc/sysdeps/linux/cris/syscall.S3
-rw-r--r--libc/sysdeps/linux/cris/sysdep.S5
-rw-r--r--libc/sysdeps/linux/cris/sysdep.h15
-rw-r--r--libc/sysdeps/linux/cris/vfork.S30
-rw-r--r--libc/sysdeps/linux/e1/Makefile56
-rw-r--r--libc/sysdeps/linux/e1/bits/endian.h7
-rw-r--r--libc/sysdeps/linux/e1/bits/fenvinline.h298
-rw-r--r--libc/sysdeps/linux/e1/bits/kernel_stat.h60
-rw-r--r--libc/sysdeps/linux/e1/bits/mman.h76
-rw-r--r--libc/sysdeps/linux/e1/bits/proto.h5
-rw-r--r--libc/sysdeps/linux/e1/bits/setjmp.h22
-rw-r--r--libc/sysdeps/linux/e1/bits/syscalls.h17
-rw-r--r--libc/sysdeps/linux/e1/bits/unistd.h464
-rw-r--r--libc/sysdeps/linux/e1/crt0.S17
-rw-r--r--libc/sysdeps/linux/e1/crt1.c48
-rw-r--r--libc/sysdeps/linux/e1/longjmp.c77
-rw-r--r--libc/sysdeps/linux/e1/setjmp.c56
-rw-r--r--libc/sysdeps/linux/e1/sys/procfs.h31
-rw-r--r--libc/sysdeps/linux/e1/sys/ucontext.h109
-rw-r--r--libc/sysdeps/linux/e1/syscalls.c11
-rw-r--r--libc/sysdeps/linux/e1/vfork.c15
-rw-r--r--libc/sysdeps/linux/frv/Makefile59
-rw-r--r--libc/sysdeps/linux/frv/Makefile.arch11
-rw-r--r--libc/sysdeps/linux/frv/__init_brk.c2
-rw-r--r--libc/sysdeps/linux/frv/__longjmp.S4
-rw-r--r--libc/sysdeps/linux/frv/bits/elf-fdpic.h5
-rw-r--r--libc/sysdeps/linux/frv/bits/endian.h2
-rw-r--r--libc/sysdeps/linux/frv/bits/fcntl.h18
-rw-r--r--libc/sysdeps/linux/frv/bits/kernel_stat.h26
-rw-r--r--libc/sysdeps/linux/frv/bits/kernel_types.h3
-rw-r--r--libc/sysdeps/linux/frv/bits/mman.h76
-rw-r--r--libc/sysdeps/linux/frv/bits/setjmp.h12
-rw-r--r--libc/sysdeps/linux/frv/bits/stackinfo.h5
-rw-r--r--libc/sysdeps/linux/frv/bits/stat.h43
-rw-r--r--libc/sysdeps/linux/frv/bits/syscalls.h183
-rw-r--r--libc/sysdeps/linux/frv/bits/uClibc_arch_features.h17
-rw-r--r--libc/sysdeps/linux/frv/bits/uClibc_page.h4
-rw-r--r--libc/sysdeps/linux/frv/bits/wordsize.h5
-rw-r--r--libc/sysdeps/linux/frv/brk.c1
-rw-r--r--libc/sysdeps/linux/frv/clone.S5
-rw-r--r--libc/sysdeps/linux/frv/crt1.S (renamed from libc/sysdeps/linux/frv/crt0.S)12
-rw-r--r--libc/sysdeps/linux/frv/crti.S3
-rw-r--r--libc/sysdeps/linux/frv/crtn.S5
-rw-r--r--libc/sysdeps/linux/frv/crtreloc.c55
-rw-r--r--libc/sysdeps/linux/frv/dl-iterate-phdr.c3
-rw-r--r--libc/sysdeps/linux/frv/fstat.c3
-rw-r--r--libc/sysdeps/linux/frv/fstat64.c7
-rw-r--r--libc/sysdeps/linux/frv/jmpbuf-unwind.h12
-rw-r--r--libc/sysdeps/linux/frv/lstat.c3
-rw-r--r--libc/sysdeps/linux/frv/lstat64.c7
-rw-r--r--libc/sysdeps/linux/frv/mmap.c51
-rw-r--r--libc/sysdeps/linux/frv/sbrk.c1
-rw-r--r--libc/sysdeps/linux/frv/stat.c3
-rw-r--r--libc/sysdeps/linux/frv/stat64.c7
-rw-r--r--libc/sysdeps/linux/frv/sys/procfs.h5
-rw-r--r--libc/sysdeps/linux/frv/sys/ptrace.h5
-rw-r--r--libc/sysdeps/linux/frv/sys/ucontext.h3
-rw-r--r--libc/sysdeps/linux/frv/syscall.c6
-rw-r--r--libc/sysdeps/linux/frv/sysdep.c5
-rw-r--r--libc/sysdeps/linux/frv/vfork.S13
-rw-r--r--libc/sysdeps/linux/h8300/Makefile70
-rw-r--r--libc/sysdeps/linux/h8300/Makefile.arch10
-rw-r--r--libc/sysdeps/linux/h8300/__longjmp.S8
-rw-r--r--libc/sysdeps/linux/h8300/bits/byteswap.h51
-rw-r--r--libc/sysdeps/linux/h8300/bits/fcntl.h24
-rw-r--r--libc/sysdeps/linux/h8300/bits/kernel_stat.h61
-rw-r--r--libc/sysdeps/linux/h8300/bits/kernel_types.h27
-rw-r--r--libc/sysdeps/linux/h8300/bits/mman.h76
-rw-r--r--libc/sysdeps/linux/h8300/bits/setjmp.h14
-rw-r--r--libc/sysdeps/linux/h8300/bits/sigcontextinfo.h5
-rw-r--r--libc/sysdeps/linux/h8300/bits/stackinfo.h5
-rw-r--r--libc/sysdeps/linux/h8300/bits/syscalls.h214
-rw-r--r--libc/sysdeps/linux/h8300/bits/uClibc_arch_features.h17
-rw-r--r--libc/sysdeps/linux/h8300/brk.c1
-rw-r--r--libc/sysdeps/linux/h8300/bsd-_setjmp.S14
-rw-r--r--libc/sysdeps/linux/h8300/bsd-setjmp.S17
-rw-r--r--libc/sysdeps/linux/h8300/clone.S36
-rw-r--r--libc/sysdeps/linux/h8300/crt1.S (renamed from libc/sysdeps/linux/h8300/crt0.S)41
-rw-r--r--libc/sysdeps/linux/h8300/crti.S8
-rw-r--r--libc/sysdeps/linux/h8300/crtn.S6
-rw-r--r--libc/sysdeps/linux/h8300/jmpbuf-offsets.h9
-rw-r--r--libc/sysdeps/linux/h8300/jmpbuf-unwind.h12
-rw-r--r--libc/sysdeps/linux/h8300/setjmp.S8
-rw-r--r--libc/sysdeps/linux/h8300/sys/procfs.h5
-rw-r--r--libc/sysdeps/linux/h8300/sys/ucontext.h5
-rw-r--r--libc/sysdeps/linux/h8300/vfork.S59
-rw-r--r--libc/sysdeps/linux/hppa/Makefile.arch6
-rw-r--r--libc/sysdeps/linux/hppa/__longjmp.S10
-rw-r--r--libc/sysdeps/linux/hppa/add_n.s5
-rw-r--r--libc/sysdeps/linux/hppa/bits/atomic.h98
-rw-r--r--libc/sysdeps/linux/hppa/bits/eventfd.h32
-rw-r--r--libc/sysdeps/linux/hppa/bits/fcntl.h13
-rw-r--r--libc/sysdeps/linux/hppa/bits/fenv.h5
-rw-r--r--libc/sysdeps/linux/hppa/bits/ipc.h5
-rw-r--r--libc/sysdeps/linux/hppa/bits/kernel_sigaction.h11
-rw-r--r--libc/sysdeps/linux/hppa/bits/kernel_stat.h28
-rw-r--r--libc/sysdeps/linux/hppa/bits/kernel_types.h2
-rw-r--r--libc/sysdeps/linux/hppa/bits/mman.h123
-rw-r--r--libc/sysdeps/linux/hppa/bits/setjmp.h18
-rw-r--r--libc/sysdeps/linux/hppa/bits/sigaction.h38
-rw-r--r--libc/sysdeps/linux/hppa/bits/signum.h25
-rw-r--r--libc/sysdeps/linux/hppa/bits/socket_type.h54
-rw-r--r--libc/sysdeps/linux/hppa/bits/stackinfo.h5
-rw-r--r--libc/sysdeps/linux/hppa/bits/syscalls.h95
-rw-r--r--libc/sysdeps/linux/hppa/bits/uClibc_arch_features.h16
-rw-r--r--libc/sysdeps/linux/hppa/brk.c8
-rw-r--r--libc/sysdeps/linux/hppa/bsd-_setjmp.S5
-rw-r--r--libc/sysdeps/linux/hppa/bsd-setjmp.S5
-rw-r--r--libc/sysdeps/linux/hppa/clone.S5
-rw-r--r--libc/sysdeps/linux/hppa/crt1.S5
-rw-r--r--libc/sysdeps/linux/hppa/jmpbuf-offsets.h19
-rw-r--r--libc/sysdeps/linux/hppa/jmpbuf-unwind.h12
-rw-r--r--libc/sysdeps/linux/hppa/lshift.s5
-rw-r--r--libc/sysdeps/linux/hppa/mmap.c20
-rw-r--r--libc/sysdeps/linux/hppa/rshift.s5
-rw-r--r--libc/sysdeps/linux/hppa/setjmp.S5
-rw-r--r--libc/sysdeps/linux/hppa/sub_n.s5
-rw-r--r--libc/sysdeps/linux/hppa/sys/procfs.h19
-rw-r--r--libc/sysdeps/linux/hppa/sys/ucontext.h5
-rw-r--r--libc/sysdeps/linux/hppa/sys/user.h1
-rw-r--r--libc/sysdeps/linux/hppa/syscall.c5
-rw-r--r--libc/sysdeps/linux/hppa/udiv_qrnnd.s5
-rw-r--r--libc/sysdeps/linux/i386/Makefile.arch19
-rw-r--r--libc/sysdeps/linux/i386/__longjmp.S8
-rw-r--r--libc/sysdeps/linux/i386/__syscall_error.c7
-rw-r--r--libc/sysdeps/linux/i386/bits/atomic.h47
-rw-r--r--libc/sysdeps/linux/i386/bits/byteswap.h126
-rw-r--r--libc/sysdeps/linux/i386/bits/fcntl.h14
-rw-r--r--libc/sysdeps/linux/i386/bits/fenv.h9
-rw-r--r--libc/sysdeps/linux/i386/bits/huge_vall.h42
-rw-r--r--libc/sysdeps/linux/i386/bits/kernel_stat.h29
-rw-r--r--libc/sysdeps/linux/i386/bits/kernel_types.h11
-rw-r--r--libc/sysdeps/linux/i386/bits/mathdef.h5
-rw-r--r--libc/sysdeps/linux/i386/bits/mathinline.h34
-rw-r--r--libc/sysdeps/linux/i386/bits/mman.h103
-rw-r--r--libc/sysdeps/linux/i386/bits/select.h5
-rw-r--r--libc/sysdeps/linux/i386/bits/setjmp.h25
-rw-r--r--libc/sysdeps/linux/i386/bits/sigcontextinfo.h5
-rw-r--r--libc/sysdeps/linux/i386/bits/stackinfo.h5
-rw-r--r--libc/sysdeps/linux/i386/bits/syscalls.h344
-rw-r--r--libc/sysdeps/linux/i386/bits/uClibc_arch_features.h14
-rw-r--r--libc/sysdeps/linux/i386/bits/wchar.h5
-rw-r--r--libc/sysdeps/linux/i386/bits/wordsize.h7
-rw-r--r--libc/sysdeps/linux/i386/brk.c53
-rw-r--r--libc/sysdeps/linux/i386/bsd-_setjmp.S9
-rw-r--r--libc/sysdeps/linux/i386/bsd-setjmp.S9
-rw-r--r--libc/sysdeps/linux/i386/clone.S13
-rw-r--r--libc/sysdeps/linux/i386/copysign.S55
-rw-r--r--libc/sysdeps/linux/i386/crt1.S5
-rw-r--r--libc/sysdeps/linux/i386/crtn.S2
-rw-r--r--libc/sysdeps/linux/i386/fpu_control.h5
-rw-r--r--libc/sysdeps/linux/i386/getcontext.S84
-rw-r--r--libc/sysdeps/linux/i386/jmpbuf-offsets.h25
-rw-r--r--libc/sysdeps/linux/i386/jmpbuf-unwind.h23
-rw-r--r--libc/sysdeps/linux/i386/makecontext.S123
-rw-r--r--libc/sysdeps/linux/i386/mmap.S5
-rw-r--r--libc/sysdeps/linux/i386/mmap64.S10
-rw-r--r--libc/sysdeps/linux/i386/posix_fadvise.c34
-rw-r--r--libc/sysdeps/linux/i386/posix_fadvise64.S68
-rw-r--r--libc/sysdeps/linux/i386/setcontext.S96
-rw-r--r--libc/sysdeps/linux/i386/setjmp.S10
-rw-r--r--libc/sysdeps/linux/i386/sigaction.c174
-rw-r--r--libc/sysdeps/linux/i386/swapcontext.S110
-rw-r--r--libc/sysdeps/linux/i386/sync_file_range.S5
-rw-r--r--libc/sysdeps/linux/i386/sys/debugreg.h5
-rw-r--r--libc/sysdeps/linux/i386/sys/elf.h5
-rw-r--r--libc/sysdeps/linux/i386/sys/io.h5
-rw-r--r--libc/sysdeps/linux/i386/sys/perm.h5
-rw-r--r--libc/sysdeps/linux/i386/sys/procfs.h5
-rw-r--r--libc/sysdeps/linux/i386/sys/reg.h5
-rw-r--r--libc/sysdeps/linux/i386/sys/ucontext.h5
-rw-r--r--libc/sysdeps/linux/i386/sys/user.h5
-rw-r--r--libc/sysdeps/linux/i386/sys/vm86.h5
-rw-r--r--libc/sysdeps/linux/i386/sysdep.h429
-rw-r--r--libc/sysdeps/linux/i386/ucontext_i.sym30
-rw-r--r--libc/sysdeps/linux/i386/vfork.S12
-rw-r--r--libc/sysdeps/linux/i960/AUTHORS4
-rw-r--r--libc/sysdeps/linux/i960/Makefile55
-rw-r--r--libc/sysdeps/linux/i960/README71
-rw-r--r--libc/sysdeps/linux/i960/bits/mman.h94
-rw-r--r--libc/sysdeps/linux/i960/bits/setjmp.h38
-rw-r--r--libc/sysdeps/linux/i960/bits/syscalls.h15
-rw-r--r--libc/sysdeps/linux/i960/bits/uClibc_arch_features.h39
-rw-r--r--libc/sysdeps/linux/i960/clone.S62
-rw-r--r--libc/sysdeps/linux/i960/crt0.S58
-rw-r--r--libc/sysdeps/linux/i960/mmap.S52
-rw-r--r--libc/sysdeps/linux/i960/setjmp.S124
-rw-r--r--libc/sysdeps/linux/i960/specs.uclinux.gcc-2.95.i960-intel-coff64
-rw-r--r--libc/sysdeps/linux/i960/vfork.S33
-rw-r--r--libc/sysdeps/linux/ia64/Makefile.arch6
-rw-r--r--libc/sysdeps/linux/ia64/__longjmp.S79
-rw-r--r--libc/sysdeps/linux/ia64/bits/atomic.h11
-rw-r--r--libc/sysdeps/linux/ia64/bits/byteswap.h105
-rw-r--r--libc/sysdeps/linux/ia64/bits/fcntl.h15
-rw-r--r--libc/sysdeps/linux/ia64/bits/fenv.h11
-rw-r--r--libc/sysdeps/linux/ia64/bits/huge_vall.h41
-rw-r--r--libc/sysdeps/linux/ia64/bits/ipc.h5
-rw-r--r--libc/sysdeps/linux/ia64/bits/kernel_stat.h40
-rw-r--r--libc/sysdeps/linux/ia64/bits/kernel_types.h2
-rw-r--r--libc/sysdeps/linux/ia64/bits/local_lim.h99
-rw-r--r--libc/sysdeps/linux/ia64/bits/mathdef.h5
-rw-r--r--libc/sysdeps/linux/ia64/bits/mathinline.h7
-rw-r--r--libc/sysdeps/linux/ia64/bits/mman.h102
-rw-r--r--libc/sysdeps/linux/ia64/bits/msq.h5
-rw-r--r--libc/sysdeps/linux/ia64/bits/sem.h5
-rw-r--r--libc/sysdeps/linux/ia64/bits/setjmp.h12
-rw-r--r--libc/sysdeps/linux/ia64/bits/shm.h5
-rw-r--r--libc/sysdeps/linux/ia64/bits/sigaction.h38
-rw-r--r--libc/sysdeps/linux/ia64/bits/sigcontext.h7
-rw-r--r--libc/sysdeps/linux/ia64/bits/siginfo.h26
-rw-r--r--libc/sysdeps/linux/ia64/bits/sigstack.h7
-rw-r--r--libc/sysdeps/linux/ia64/bits/stackinfo.h5
-rw-r--r--libc/sysdeps/linux/ia64/bits/stat.h16
-rw-r--r--libc/sysdeps/linux/ia64/bits/syscalls.h141
-rw-r--r--libc/sysdeps/linux/ia64/bits/uClibc_arch_features.h17
-rw-r--r--libc/sysdeps/linux/ia64/bits/wordsize.h5
-rw-r--r--libc/sysdeps/linux/ia64/brk.S5
-rw-r--r--libc/sysdeps/linux/ia64/clone2.S5
-rw-r--r--libc/sysdeps/linux/ia64/crt1.S5
-rw-r--r--libc/sysdeps/linux/ia64/fork.S21
-rw-r--r--libc/sysdeps/linux/ia64/jmpbuf-unwind.h11
-rw-r--r--libc/sysdeps/linux/ia64/pipe.S5
-rw-r--r--libc/sysdeps/linux/ia64/setjmp.S49
-rw-r--r--libc/sysdeps/linux/ia64/sys/io.h7
-rw-r--r--libc/sysdeps/linux/ia64/sys/procfs.h5
-rw-r--r--libc/sysdeps/linux/ia64/sys/ptrace.h5
-rw-r--r--libc/sysdeps/linux/ia64/sys/ucontext.h7
-rw-r--r--libc/sysdeps/linux/ia64/sys/user.h5
-rw-r--r--libc/sysdeps/linux/ia64/syscall.S5
-rw-r--r--libc/sysdeps/linux/ia64/sysdep.h16
-rw-r--r--libc/sysdeps/linux/ia64/vfork.S9
-rw-r--r--libc/sysdeps/linux/lm32/Makefile (renamed from libc/sysdeps/linux/nios/Makefile)2
-rw-r--r--libc/sysdeps/linux/lm32/Makefile.arch9
-rw-r--r--libc/sysdeps/linux/lm32/__longjmp.S40
-rw-r--r--libc/sysdeps/linux/lm32/bits/endian.h (renamed from libc/sysdeps/linux/i960/bits/endian.h)4
-rw-r--r--libc/sysdeps/linux/lm32/bits/fcntl.h (renamed from libc/sysdeps/linux/v850/bits/fcntl.h)21
-rw-r--r--libc/sysdeps/linux/lm32/bits/kernel_stat.h50
-rw-r--r--libc/sysdeps/linux/lm32/bits/kernel_types.h39
-rw-r--r--libc/sysdeps/linux/lm32/bits/setjmp.h24
-rw-r--r--libc/sysdeps/linux/lm32/bits/stackinfo.h28
-rw-r--r--libc/sysdeps/linux/lm32/bits/syscalls.h59
-rw-r--r--libc/sysdeps/linux/lm32/bits/uClibc_arch_features.h (renamed from libc/sysdeps/linux/e1/bits/uClibc_arch_features.h)15
-rw-r--r--libc/sysdeps/linux/lm32/bits/uClibc_page.h (renamed from libc/sysdeps/linux/nios2/bits/uClibc_page.h)5
-rw-r--r--libc/sysdeps/linux/lm32/bits/wordsize.h1
-rw-r--r--libc/sysdeps/linux/lm32/clone.S52
-rw-r--r--libc/sysdeps/linux/lm32/crt1.S21
-rw-r--r--libc/sysdeps/linux/lm32/crti.S17
-rw-r--r--libc/sysdeps/linux/lm32/crtn.S11
-rw-r--r--libc/sysdeps/linux/lm32/setjmp.S53
-rw-r--r--libc/sysdeps/linux/lm32/sys/procfs.h (renamed from libc/sysdeps/linux/v850/sys/procfs.h)30
-rw-r--r--libc/sysdeps/linux/lm32/sys/ucontext.h (renamed from libc/sysdeps/linux/v850/sys/ucontext.h)2
-rw-r--r--libc/sysdeps/linux/lm32/sys/user.h (renamed from libc/sysdeps/linux/nios/brk.c)43
-rw-r--r--libc/sysdeps/linux/lm32/vfork.S42
-rw-r--r--libc/sysdeps/linux/m68k/Makefile.arch6
-rw-r--r--libc/sysdeps/linux/m68k/README.m68k6
-rw-r--r--libc/sysdeps/linux/m68k/__longjmp.S8
-rw-r--r--libc/sysdeps/linux/m68k/bits/byteswap.h55
-rw-r--r--libc/sysdeps/linux/m68k/bits/fcntl.h13
-rw-r--r--libc/sysdeps/linux/m68k/bits/fenv.h9
-rw-r--r--libc/sysdeps/linux/m68k/bits/huge_vall.h42
-rw-r--r--libc/sysdeps/linux/m68k/bits/kernel_stat.h22
-rw-r--r--libc/sysdeps/linux/m68k/bits/kernel_types.h2
-rw-r--r--libc/sysdeps/linux/m68k/bits/mathdef.h5
-rw-r--r--libc/sysdeps/linux/m68k/bits/mathinline.h11
-rw-r--r--libc/sysdeps/linux/m68k/bits/mman.h102
-rw-r--r--libc/sysdeps/linux/m68k/bits/poll.h5
-rw-r--r--libc/sysdeps/linux/m68k/bits/setjmp.h29
-rw-r--r--libc/sysdeps/linux/m68k/bits/sigcontextinfo.h5
-rw-r--r--libc/sysdeps/linux/m68k/bits/stackinfo.h5
-rw-r--r--libc/sysdeps/linux/m68k/bits/stat.h16
-rw-r--r--libc/sysdeps/linux/m68k/bits/syscalls.h226
-rw-r--r--libc/sysdeps/linux/m68k/bits/uClibc_arch_features.h14
-rw-r--r--libc/sysdeps/linux/m68k/bits/uClibc_page.h4
-rw-r--r--libc/sysdeps/linux/m68k/bits/wordsize.h5
-rw-r--r--libc/sysdeps/linux/m68k/brk.c1
-rw-r--r--libc/sysdeps/linux/m68k/bsd-_setjmp.S7
-rw-r--r--libc/sysdeps/linux/m68k/bsd-setjmp.S7
-rw-r--r--libc/sysdeps/linux/m68k/crt1.S5
-rw-r--r--libc/sysdeps/linux/m68k/fpu_control.h5
-rw-r--r--libc/sysdeps/linux/m68k/jmpbuf-offsets.h19
-rw-r--r--libc/sysdeps/linux/m68k/jmpbuf-unwind.h11
-rw-r--r--libc/sysdeps/linux/m68k/setjmp.S7
-rw-r--r--libc/sysdeps/linux/m68k/sys/procfs.h5
-rw-r--r--libc/sysdeps/linux/m68k/sys/reg.h89
-rw-r--r--libc/sysdeps/linux/m68k/sys/ucontext.h5
-rw-r--r--libc/sysdeps/linux/m68k/sys/user.h90
-rw-r--r--libc/sysdeps/linux/m68k/syscall.c47
-rw-r--r--libc/sysdeps/linux/m68k/vfork.S26
-rw-r--r--libc/sysdeps/linux/metag/Makefile13
-rw-r--r--libc/sysdeps/linux/metag/Makefile.arch12
-rw-r--r--libc/sysdeps/linux/metag/__syscall_error.c18
-rw-r--r--libc/sysdeps/linux/metag/_longjmp.S25
-rw-r--r--libc/sysdeps/linux/metag/bits/atomic.h66
-rw-r--r--libc/sysdeps/linux/metag/bits/endian.h12
-rw-r--r--libc/sysdeps/linux/metag/bits/fcntl.h (renamed from libc/sysdeps/linux/e1/bits/fcntl.h)31
-rw-r--r--libc/sysdeps/linux/metag/bits/fenv.h (renamed from libc/sysdeps/linux/e1/bits/fenv.h)63
-rw-r--r--libc/sysdeps/linux/metag/bits/ipc.h55
-rw-r--r--libc/sysdeps/linux/metag/bits/kernel_types.h (renamed from libc/sysdeps/linux/e1/bits/kernel_types.h)39
-rw-r--r--libc/sysdeps/linux/metag/bits/profil-counter.h17
-rw-r--r--libc/sysdeps/linux/metag/bits/setjmp.h44
-rw-r--r--libc/sysdeps/linux/metag/bits/sigcontextinfo.h14
-rw-r--r--libc/sysdeps/linux/metag/bits/stackinfo.h (renamed from libc/sysdeps/linux/sh64/bits/stackinfo.h)4
-rw-r--r--libc/sysdeps/linux/metag/bits/syscalls.h120
-rw-r--r--libc/sysdeps/linux/metag/bits/uClibc_arch_features.h (renamed from libc/sysdeps/linux/v850/bits/uClibc_arch_features.h)19
-rw-r--r--libc/sysdeps/linux/metag/bits/wordsize.h (renamed from libc/sysdeps/linux/i960/bits/wordsize.h)0
-rw-r--r--libc/sysdeps/linux/metag/brk.c38
-rw-r--r--libc/sysdeps/linux/metag/clone.S101
-rw-r--r--libc/sysdeps/linux/metag/crt1.S75
-rw-r--r--libc/sysdeps/linux/metag/crti.S19
-rw-r--r--libc/sysdeps/linux/metag/crtn.S19
-rw-r--r--libc/sysdeps/linux/metag/jmpbuf-unwind.h22
-rw-r--r--libc/sysdeps/linux/metag/libc-metag_load_tp.S7
-rw-r--r--libc/sysdeps/linux/metag/metag.c11
-rw-r--r--libc/sysdeps/linux/metag/setjmp.S52
-rw-r--r--libc/sysdeps/linux/metag/sys/io.h48
-rw-r--r--libc/sysdeps/linux/metag/sys/procfs.h (renamed from libc/sysdeps/linux/vax/sys/procfs.h)16
-rw-r--r--libc/sysdeps/linux/metag/sys/ucontext.h (renamed from libc/sysdeps/linux/i960/sys/ucontext.h)88
-rw-r--r--libc/sysdeps/linux/metag/sys/user.h7
-rw-r--r--libc/sysdeps/linux/metag/syscall.c40
-rw-r--r--libc/sysdeps/linux/metag/sysdep.h59
-rw-r--r--libc/sysdeps/linux/metag/vfork.S67
-rw-r--r--libc/sysdeps/linux/microblaze/Makefile81
-rw-r--r--libc/sysdeps/linux/microblaze/Makefile.arch12
-rw-r--r--libc/sysdeps/linux/microblaze/__longjmp.S50
-rw-r--r--libc/sysdeps/linux/microblaze/bits/byteswap.h41
-rw-r--r--libc/sysdeps/linux/microblaze/bits/endian.h9
-rw-r--r--libc/sysdeps/linux/microblaze/bits/fcntl.h26
-rw-r--r--libc/sysdeps/linux/microblaze/bits/kernel_stat.h86
-rw-r--r--libc/sysdeps/linux/microblaze/bits/kernel_types.h31
-rw-r--r--libc/sysdeps/linux/microblaze/bits/mman.h99
-rw-r--r--libc/sysdeps/linux/microblaze/bits/poll.h13
-rw-r--r--libc/sysdeps/linux/microblaze/bits/select.h58
-rw-r--r--libc/sysdeps/linux/microblaze/bits/setjmp.h17
-rw-r--r--libc/sysdeps/linux/microblaze/bits/stackinfo.h27
-rw-r--r--libc/sysdeps/linux/microblaze/bits/syscalls.h55
-rw-r--r--libc/sysdeps/linux/microblaze/bits/uClibc_arch_features.h21
-rw-r--r--libc/sysdeps/linux/microblaze/bits/uClibc_page.h27
-rw-r--r--libc/sysdeps/linux/microblaze/bits/wordsize.h5
-rw-r--r--libc/sysdeps/linux/microblaze/clinkage.h15
-rw-r--r--libc/sysdeps/linux/microblaze/clone.c71
-rw-r--r--libc/sysdeps/linux/microblaze/crt0.S20
-rw-r--r--libc/sysdeps/linux/microblaze/crt1.S57
-rw-r--r--libc/sysdeps/linux/microblaze/crti.S41
-rw-r--r--libc/sysdeps/linux/microblaze/crtn.S43
-rw-r--r--libc/sysdeps/linux/microblaze/fixdfsi.c85
-rw-r--r--libc/sysdeps/linux/microblaze/floatlib.h140
-rw-r--r--libc/sysdeps/linux/microblaze/jmpbuf-offsets.h6
-rw-r--r--libc/sysdeps/linux/microblaze/jmpbuf-unwind.h11
-rw-r--r--libc/sysdeps/linux/microblaze/mmap.c17
-rw-r--r--libc/sysdeps/linux/microblaze/setjmp.S76
-rw-r--r--libc/sysdeps/linux/microblaze/sys/procfs.h144
-rw-r--r--libc/sysdeps/linux/microblaze/sys/ptrace.h13
-rw-r--r--libc/sysdeps/linux/microblaze/sys/ucontext.h5
-rw-r--r--libc/sysdeps/linux/microblaze/sys/user.h76
-rw-r--r--libc/sysdeps/linux/microblaze/syscall.c51
-rw-r--r--libc/sysdeps/linux/microblaze/vfork.S51
-rw-r--r--libc/sysdeps/linux/mips/Makefile.arch20
-rw-r--r--libc/sysdeps/linux/mips/__longjmp.c11
-rw-r--r--libc/sysdeps/linux/mips/_test_and_set.c5
-rw-r--r--libc/sysdeps/linux/mips/bits/atomic.h139
-rw-r--r--libc/sysdeps/linux/mips/bits/dirent.h5
-rw-r--r--libc/sysdeps/linux/mips/bits/dlfcn.h7
-rw-r--r--libc/sysdeps/linux/mips/bits/epoll.h29
-rw-r--r--libc/sysdeps/linux/mips/bits/eventfd.h31
-rw-r--r--libc/sysdeps/linux/mips/bits/fcntl.h13
-rw-r--r--libc/sysdeps/linux/mips/bits/fenv.h9
-rw-r--r--libc/sysdeps/linux/mips/bits/inotify.h29
-rw-r--r--libc/sysdeps/linux/mips/bits/ioctl-types.h5
-rw-r--r--libc/sysdeps/linux/mips/bits/ipc.h5
-rw-r--r--libc/sysdeps/linux/mips/bits/kernel_sigaction.h21
-rw-r--r--libc/sysdeps/linux/mips/bits/kernel_stat.h54
-rw-r--r--libc/sysdeps/linux/mips/bits/kernel_types.h4
-rw-r--r--libc/sysdeps/linux/mips/bits/mathdef.h12
-rw-r--r--libc/sysdeps/linux/mips/bits/mman.h7
-rw-r--r--libc/sysdeps/linux/mips/bits/msq.h5
-rw-r--r--libc/sysdeps/linux/mips/bits/poll.h5
-rw-r--r--libc/sysdeps/linux/mips/bits/resource.h5
-rw-r--r--libc/sysdeps/linux/mips/bits/sem.h5
-rw-r--r--libc/sysdeps/linux/mips/bits/setjmp.h30
-rw-r--r--libc/sysdeps/linux/mips/bits/shm.h5
-rw-r--r--libc/sysdeps/linux/mips/bits/sigaction.h46
-rw-r--r--libc/sysdeps/linux/mips/bits/sigcontext.h5
-rw-r--r--libc/sysdeps/linux/mips/bits/sigcontextinfo.h5
-rw-r--r--libc/sysdeps/linux/mips/bits/siginfo.h72
-rw-r--r--libc/sysdeps/linux/mips/bits/signalfd.h29
-rw-r--r--libc/sysdeps/linux/mips/bits/signum.h41
-rw-r--r--libc/sysdeps/linux/mips/bits/sigstack.h7
-rw-r--r--libc/sysdeps/linux/mips/bits/socket.h328
-rw-r--r--libc/sysdeps/linux/mips/bits/socket_type.h55
-rw-r--r--libc/sysdeps/linux/mips/bits/stackinfo.h5
-rw-r--r--libc/sysdeps/linux/mips/bits/stat.h92
-rw-r--r--libc/sysdeps/linux/mips/bits/statfs.h5
-rw-r--r--libc/sysdeps/linux/mips/bits/syscalls.h75
-rw-r--r--libc/sysdeps/linux/mips/bits/termios.h6
-rw-r--r--libc/sysdeps/linux/mips/bits/timerfd.h29
-rw-r--r--libc/sysdeps/linux/mips/bits/uClibc_arch_features.h22
-rw-r--r--libc/sysdeps/linux/mips/bits/uClibc_page.h4
-rw-r--r--libc/sysdeps/linux/mips/bits/wordsize.h8
-rw-r--r--libc/sysdeps/linux/mips/brk.c6
-rw-r--r--libc/sysdeps/linux/mips/bsd-_setjmp.S5
-rw-r--r--libc/sysdeps/linux/mips/bsd-setjmp.S5
-rw-r--r--libc/sysdeps/linux/mips/cacheflush.c15
-rw-r--r--libc/sysdeps/linux/mips/clone.S169
-rw-r--r--libc/sysdeps/linux/mips/crt1.S52
-rw-r--r--libc/sysdeps/linux/mips/crtn.S15
-rw-r--r--libc/sysdeps/linux/mips/fpu_control.h5
-rw-r--r--libc/sysdeps/linux/mips/getcontext.S148
-rw-r--r--libc/sysdeps/linux/mips/jmpbuf-unwind.h22
-rw-r--r--libc/sysdeps/linux/mips/kernel_rt_sigframe.h10
-rw-r--r--libc/sysdeps/linux/mips/makecontext.S188
-rw-r--r--libc/sysdeps/linux/mips/mmap.c27
-rw-r--r--libc/sysdeps/linux/mips/posix_fadvise.c23
-rw-r--r--libc/sysdeps/linux/mips/posix_fadvise64.c32
-rw-r--r--libc/sysdeps/linux/mips/pread_write.c118
-rw-r--r--libc/sysdeps/linux/mips/readahead.c41
-rw-r--r--libc/sysdeps/linux/mips/setcontext.S191
-rw-r--r--libc/sysdeps/linux/mips/setjmp.S6
-rw-r--r--libc/sysdeps/linux/mips/setjmp_aux.c15
-rw-r--r--libc/sysdeps/linux/mips/sgidefs.h5
-rw-r--r--libc/sysdeps/linux/mips/sigaction.c154
-rw-r--r--libc/sysdeps/linux/mips/swapcontext.S211
-rw-r--r--libc/sysdeps/linux/mips/sys/asm.h37
-rw-r--r--libc/sysdeps/linux/mips/sys/cachectl.h15
-rw-r--r--libc/sysdeps/linux/mips/sys/fpregdef.h95
-rw-r--r--libc/sysdeps/linux/mips/sys/procfs.h5
-rw-r--r--libc/sysdeps/linux/mips/sys/regdef.h7
-rw-r--r--libc/sysdeps/linux/mips/sys/sysmips.h9
-rw-r--r--libc/sysdeps/linux/mips/sys/tas.h7
-rw-r--r--libc/sysdeps/linux/mips/sys/ucontext.h5
-rw-r--r--libc/sysdeps/linux/mips/sys/user.h5
-rw-r--r--libc/sysdeps/linux/mips/syscall.S8
-rw-r--r--libc/sysdeps/linux/mips/syscall_error.S83
-rw-r--r--libc/sysdeps/linux/mips/sysdep.h138
-rw-r--r--libc/sysdeps/linux/mips/sysmips.c2
-rw-r--r--libc/sysdeps/linux/mips/ucontext_i.sym52
-rw-r--r--libc/sysdeps/linux/mips/vfork.S102
-rw-r--r--libc/sysdeps/linux/nios/Makefile.arch14
-rw-r--r--libc/sysdeps/linux/nios/NM_Macros.S473
-rw-r--r--libc/sysdeps/linux/nios/NR_Math1.S63
-rw-r--r--libc/sysdeps/linux/nios/__longjmp.S103
-rw-r--r--libc/sysdeps/linux/nios/bits/endian.h8
-rw-r--r--libc/sysdeps/linux/nios/bits/mman.h76
-rw-r--r--libc/sysdeps/linux/nios/bits/setjmp.h76
-rw-r--r--libc/sysdeps/linux/nios/bits/stat.h134
-rw-r--r--libc/sysdeps/linux/nios/bits/syscalls.h13
-rw-r--r--libc/sysdeps/linux/nios/bsd-_setjmp.S1
-rw-r--r--libc/sysdeps/linux/nios/bsd-setjmp.S1
-rw-r--r--libc/sysdeps/linux/nios/clone.S88
-rw-r--r--libc/sysdeps/linux/nios/crt1.S59
-rw-r--r--libc/sysdeps/linux/nios/crtbegin.c37
-rw-r--r--libc/sysdeps/linux/nios/crtend.c44
-rw-r--r--libc/sysdeps/linux/nios/fpu_control.h99
-rw-r--r--libc/sysdeps/linux/nios/setjmp.S102
-rw-r--r--libc/sysdeps/linux/nios/sys/ucontext.h104
-rw-r--r--libc/sysdeps/linux/nios/vfork.S54
-rw-r--r--libc/sysdeps/linux/nios2/Makefile.arch6
-rw-r--r--libc/sysdeps/linux/nios2/__longjmp.S6
-rw-r--r--libc/sysdeps/linux/nios2/bits/endian.h2
-rw-r--r--libc/sysdeps/linux/nios2/bits/fcntl.h19
-rw-r--r--libc/sysdeps/linux/nios2/bits/kernel_stat.h22
-rw-r--r--libc/sysdeps/linux/nios2/bits/kernel_types.h18
-rw-r--r--libc/sysdeps/linux/nios2/bits/mathdef.h5
-rw-r--r--libc/sysdeps/linux/nios2/bits/mman.h85
-rw-r--r--libc/sysdeps/linux/nios2/bits/setjmp.h29
-rw-r--r--libc/sysdeps/linux/nios2/bits/sigcontextinfo.h5
-rw-r--r--libc/sysdeps/linux/nios2/bits/stackinfo.h5
-rw-r--r--libc/sysdeps/linux/nios2/bits/stat.h51
-rw-r--r--libc/sysdeps/linux/nios2/bits/syscalls.h364
-rw-r--r--libc/sysdeps/linux/nios2/bits/uClibc_arch_features.h17
-rw-r--r--libc/sysdeps/linux/nios2/bits/wordsize.h5
-rw-r--r--libc/sysdeps/linux/nios2/brk.c6
-rw-r--r--libc/sysdeps/linux/nios2/bsd-_setjmp.S7
-rw-r--r--libc/sysdeps/linux/nios2/bsd-setjmp.S7
-rw-r--r--libc/sysdeps/linux/nios2/crt1.S4
-rw-r--r--libc/sysdeps/linux/nios2/fpu_control.h5
-rw-r--r--libc/sysdeps/linux/nios2/jmpbuf-offsets.h20
-rw-r--r--libc/sysdeps/linux/nios2/jmpbuf-unwind.h11
-rw-r--r--libc/sysdeps/linux/nios2/setjmp.S6
-rw-r--r--libc/sysdeps/linux/nios2/sys/procfs.h5
-rw-r--r--libc/sysdeps/linux/nios2/sys/ucontext.h5
-rw-r--r--libc/sysdeps/linux/nios2/sys/user.h93
-rw-r--r--libc/sysdeps/linux/nios2/syscall.c4
-rw-r--r--libc/sysdeps/linux/nios2/vfork.S12
-rw-r--r--libc/sysdeps/linux/or1k/Makefile (renamed from libc/sysdeps/linux/sh64/Makefile)6
-rw-r--r--libc/sysdeps/linux/or1k/Makefile.arch9
-rw-r--r--libc/sysdeps/linux/or1k/__init_brk.c (renamed from libc/sysdeps/linux/sh64/__init_brk.c)14
-rw-r--r--libc/sysdeps/linux/or1k/__longjmp.S81
-rw-r--r--libc/sysdeps/linux/or1k/__syscall_error.c30
-rw-r--r--libc/sysdeps/linux/or1k/bits/endian.h25
-rw-r--r--libc/sysdeps/linux/or1k/bits/fcntl.h237
-rw-r--r--libc/sysdeps/linux/or1k/bits/kernel_stat.h59
-rw-r--r--libc/sysdeps/linux/or1k/bits/kernel_types.h1
-rw-r--r--libc/sysdeps/linux/or1k/bits/machine-gmon.h31
-rw-r--r--libc/sysdeps/linux/or1k/bits/setjmp.h32
-rw-r--r--libc/sysdeps/linux/or1k/bits/sigcontextinfo.h (renamed from libc/sysdeps/linux/nios/bits/sigcontextinfo.h)9
-rw-r--r--libc/sysdeps/linux/or1k/bits/stackinfo.h (renamed from libc/sysdeps/linux/nios/bits/stackinfo.h)2
-rw-r--r--libc/sysdeps/linux/or1k/bits/syscalls.h101
-rw-r--r--libc/sysdeps/linux/or1k/bits/uClibc_arch_features.h (renamed from libc/sysdeps/linux/vax/bits/uClibc_arch_features.h)16
-rw-r--r--libc/sysdeps/linux/or1k/bits/uClibc_page.h (renamed from libc/sysdeps/linux/xtensa/bits/uClibc_page.h)10
-rw-r--r--libc/sysdeps/linux/or1k/bits/wordsize.h (renamed from libc/sysdeps/linux/nios/bits/wordsize.h)0
-rw-r--r--libc/sysdeps/linux/or1k/brk.c23
-rw-r--r--libc/sysdeps/linux/or1k/clone.c88
-rw-r--r--libc/sysdeps/linux/or1k/crt1.S144
-rw-r--r--libc/sysdeps/linux/or1k/crti.S11
-rw-r--r--libc/sysdeps/linux/or1k/crtn.S9
-rw-r--r--libc/sysdeps/linux/or1k/jmpbuf-offsets.h8
-rw-r--r--libc/sysdeps/linux/or1k/jmpbuf-unwind.h24
-rw-r--r--libc/sysdeps/linux/or1k/sbrk.c (renamed from libc/sysdeps/linux/sh64/sbrk.c)15
-rw-r--r--libc/sysdeps/linux/or1k/setjmp.S96
-rw-r--r--libc/sysdeps/linux/or1k/spr_defs.h429
-rw-r--r--libc/sysdeps/linux/or1k/sys/procfs.h (renamed from libc/sysdeps/linux/sh64/sys/procfs.h)22
-rw-r--r--libc/sysdeps/linux/or1k/sys/ucontext.h (renamed from libc/sysdeps/linux/e1/sys/reg.h)13
-rw-r--r--libc/sysdeps/linux/powerpc/Makefile.arch10
-rw-r--r--libc/sysdeps/linux/powerpc/__longjmp.S9
-rw-r--r--libc/sysdeps/linux/powerpc/bits/atomic.h52
-rw-r--r--libc/sysdeps/linux/powerpc/bits/endian.h5
-rw-r--r--libc/sysdeps/linux/powerpc/bits/fcntl.h18
-rw-r--r--libc/sysdeps/linux/powerpc/bits/fenv.h5
-rw-r--r--libc/sysdeps/linux/powerpc/bits/fenvinline.h5
-rw-r--r--libc/sysdeps/linux/powerpc/bits/ipc.h5
-rw-r--r--libc/sysdeps/linux/powerpc/bits/kernel_stat.h23
-rw-r--r--libc/sysdeps/linux/powerpc/bits/kernel_types.h4
-rw-r--r--libc/sysdeps/linux/powerpc/bits/local_lim.h101
-rw-r--r--libc/sysdeps/linux/powerpc/bits/mathdef.h34
-rw-r--r--libc/sysdeps/linux/powerpc/bits/mathinline.h7
-rw-r--r--libc/sysdeps/linux/powerpc/bits/mman.h7
-rw-r--r--libc/sysdeps/linux/powerpc/bits/msq.h5
-rw-r--r--libc/sysdeps/linux/powerpc/bits/sem.h5
-rw-r--r--libc/sysdeps/linux/powerpc/bits/setjmp.h45
-rw-r--r--libc/sysdeps/linux/powerpc/bits/shm.h5
-rw-r--r--libc/sysdeps/linux/powerpc/bits/sigcontextinfo.h5
-rw-r--r--libc/sysdeps/linux/powerpc/bits/stackinfo.h5
-rw-r--r--libc/sysdeps/linux/powerpc/bits/stat.h20
-rw-r--r--libc/sysdeps/linux/powerpc/bits/syscalls.h125
-rw-r--r--libc/sysdeps/linux/powerpc/bits/sysdep.h301
-rw-r--r--libc/sysdeps/linux/powerpc/bits/termios.h7
-rw-r--r--libc/sysdeps/linux/powerpc/bits/uClibc_arch_features.h15
-rw-r--r--libc/sysdeps/linux/powerpc/bits/wordsize.h2
-rw-r--r--libc/sysdeps/linux/powerpc/brk.S5
-rw-r--r--libc/sysdeps/linux/powerpc/bsd-_setjmp.S5
-rw-r--r--libc/sysdeps/linux/powerpc/bsd-setjmp.S5
-rw-r--r--libc/sysdeps/linux/powerpc/clone.S80
-rw-r--r--libc/sysdeps/linux/powerpc/copysignl.c89
-rw-r--r--libc/sysdeps/linux/powerpc/crt1.S4
-rw-r--r--libc/sysdeps/linux/powerpc/crtn.S2
-rw-r--r--libc/sysdeps/linux/powerpc/fenv.h11
-rw-r--r--libc/sysdeps/linux/powerpc/fpu_control.h5
-rw-r--r--libc/sysdeps/linux/powerpc/ioctl.c12
-rw-r--r--libc/sysdeps/linux/powerpc/jmpbuf-offsets.h40
-rw-r--r--libc/sysdeps/linux/powerpc/jmpbuf-unwind.h23
-rw-r--r--libc/sysdeps/linux/powerpc/powerpc32/sysdep.h151
-rw-r--r--libc/sysdeps/linux/powerpc/powerpc64/sysdep.h243
-rw-r--r--libc/sysdeps/linux/powerpc/ppc_asm.h5
-rw-r--r--libc/sysdeps/linux/powerpc/pread_write.c183
-rw-r--r--libc/sysdeps/linux/powerpc/setjmp.S9
-rw-r--r--libc/sysdeps/linux/powerpc/sys/procfs.h5
-rw-r--r--libc/sysdeps/linux/powerpc/sys/ptrace.h98
-rw-r--r--libc/sysdeps/linux/powerpc/sys/ucontext.h5
-rw-r--r--libc/sysdeps/linux/powerpc/sys/user.h5
-rw-r--r--libc/sysdeps/linux/powerpc/syscall.S6
-rw-r--r--libc/sysdeps/linux/powerpc/sysdep.h195
-rw-r--r--libc/sysdeps/linux/powerpc/vfork.S3
-rw-r--r--libc/sysdeps/linux/sh/Makefile.arch9
-rw-r--r--libc/sysdeps/linux/sh/___fpscr_values.S5
-rw-r--r--libc/sysdeps/linux/sh/__init_brk.c2
-rw-r--r--libc/sysdeps/linux/sh/__longjmp.S6
-rw-r--r--libc/sysdeps/linux/sh/bits/atomic.h525
-rw-r--r--libc/sysdeps/linux/sh/bits/fcntl.h14
-rw-r--r--libc/sysdeps/linux/sh/bits/fenv.h5
-rw-r--r--libc/sysdeps/linux/sh/bits/huge_val.h5
-rw-r--r--libc/sysdeps/linux/sh/bits/kernel_stat.h24
-rw-r--r--libc/sysdeps/linux/sh/bits/kernel_types.h5
-rw-r--r--libc/sysdeps/linux/sh/bits/mathdef.h27
-rw-r--r--libc/sysdeps/linux/sh/bits/mman.h103
-rw-r--r--libc/sysdeps/linux/sh/bits/setjmp.h22
-rw-r--r--libc/sysdeps/linux/sh/bits/shm.h5
-rw-r--r--libc/sysdeps/linux/sh/bits/sigcontextinfo.h5
-rw-r--r--libc/sysdeps/linux/sh/bits/stackinfo.h5
-rw-r--r--libc/sysdeps/linux/sh/bits/syscalls.h199
-rw-r--r--libc/sysdeps/linux/sh/bits/uClibc_arch_features.h16
-rw-r--r--libc/sysdeps/linux/sh/bits/wordsize.h5
-rw-r--r--libc/sysdeps/linux/sh/brk.c1
-rw-r--r--libc/sysdeps/linux/sh/cacheflush.c14
-rw-r--r--libc/sysdeps/linux/sh/clone.S150
-rw-r--r--libc/sysdeps/linux/sh/crt1.S48
-rw-r--r--libc/sysdeps/linux/sh/crtn.S2
-rw-r--r--libc/sysdeps/linux/sh/fpu_control.h13
-rw-r--r--libc/sysdeps/linux/sh/jmpbuf-offsets.h19
-rw-r--r--libc/sysdeps/linux/sh/jmpbuf-unwind.h22
-rw-r--r--libc/sysdeps/linux/sh/mmap.c35
-rw-r--r--libc/sysdeps/linux/sh/pipe.c1
-rw-r--r--libc/sysdeps/linux/sh/pread_write.c80
-rw-r--r--libc/sysdeps/linux/sh/sbrk.c1
-rw-r--r--libc/sysdeps/linux/sh/setjmp.S9
-rw-r--r--libc/sysdeps/linux/sh/sys/io.h7
-rw-r--r--libc/sysdeps/linux/sh/sys/procfs.h5
-rw-r--r--libc/sysdeps/linux/sh/sys/ucontext.h11
-rw-r--r--libc/sysdeps/linux/sh/sys/user.h16
-rw-r--r--libc/sysdeps/linux/sh/syscall.c27
-rw-r--r--libc/sysdeps/linux/sh/syscall_error.S4
-rw-r--r--libc/sysdeps/linux/sh/sysdep.h293
-rw-r--r--libc/sysdeps/linux/sh/vfork.S27
-rw-r--r--libc/sysdeps/linux/sh64/Makefile.arch12
-rw-r--r--libc/sysdeps/linux/sh64/__longjmp.S141
-rw-r--r--libc/sysdeps/linux/sh64/bits/endian.h20
-rw-r--r--libc/sysdeps/linux/sh64/bits/fcntl.h216
-rw-r--r--libc/sysdeps/linux/sh64/bits/kernel_stat.h67
-rw-r--r--libc/sysdeps/linux/sh64/bits/kernel_types.h56
-rw-r--r--libc/sysdeps/linux/sh64/bits/mman.h97
-rw-r--r--libc/sysdeps/linux/sh64/bits/setjmp.h50
-rw-r--r--libc/sysdeps/linux/sh64/bits/shm.h103
-rw-r--r--libc/sysdeps/linux/sh64/bits/syscalls.h126
-rw-r--r--libc/sysdeps/linux/sh64/bits/wordsize.h12
-rw-r--r--libc/sysdeps/linux/sh64/brk.c28
-rw-r--r--libc/sysdeps/linux/sh64/crt1.S83
-rw-r--r--libc/sysdeps/linux/sh64/crti.S42
-rw-r--r--libc/sysdeps/linux/sh64/crtn.S33
-rw-r--r--libc/sysdeps/linux/sh64/setjmp.S140
-rw-r--r--libc/sysdeps/linux/sh64/sys/ucontext.h205
-rw-r--r--libc/sysdeps/linux/sh64/syscall.c24
-rw-r--r--libc/sysdeps/linux/sparc/Makefile.arch23
-rw-r--r--libc/sysdeps/linux/sparc/__longjmp.S11
-rw-r--r--libc/sysdeps/linux/sparc/bits/atomic.h328
-rw-r--r--libc/sysdeps/linux/sparc/bits/epoll.h29
-rw-r--r--libc/sysdeps/linux/sparc/bits/eventfd.h31
-rw-r--r--libc/sysdeps/linux/sparc/bits/fcntl.h20
-rw-r--r--libc/sysdeps/linux/sparc/bits/fenv.h9
-rw-r--r--libc/sysdeps/linux/sparc/bits/huge_vall.h48
-rw-r--r--libc/sysdeps/linux/sparc/bits/inotify.h29
-rw-r--r--libc/sysdeps/linux/sparc/bits/ioctls.h5
-rw-r--r--libc/sysdeps/linux/sparc/bits/ipc.h5
-rw-r--r--libc/sysdeps/linux/sparc/bits/kernel_stat.h23
-rw-r--r--libc/sysdeps/linux/sparc/bits/kernel_types.h7
-rw-r--r--libc/sysdeps/linux/sparc/bits/local_lim.h99
-rw-r--r--libc/sysdeps/linux/sparc/bits/mathdef.h25
-rw-r--r--libc/sysdeps/linux/sparc/bits/mathinline.h11
-rw-r--r--libc/sysdeps/linux/sparc/bits/mman.h7
-rw-r--r--libc/sysdeps/linux/sparc/bits/msq.h5
-rw-r--r--libc/sysdeps/linux/sparc/bits/poll.h5
-rw-r--r--libc/sysdeps/linux/sparc/bits/resource.h5
-rw-r--r--libc/sysdeps/linux/sparc/bits/sem.h5
-rw-r--r--libc/sysdeps/linux/sparc/bits/setjmp.h62
-rw-r--r--libc/sysdeps/linux/sparc/bits/shm.h5
-rw-r--r--libc/sysdeps/linux/sparc/bits/sigaction.h41
-rw-r--r--libc/sysdeps/linux/sparc/bits/sigcontext.h40
-rw-r--r--libc/sysdeps/linux/sparc/bits/sigcontextinfo.h5
-rw-r--r--libc/sysdeps/linux/sparc/bits/siginfo.h20
-rw-r--r--libc/sysdeps/linux/sparc/bits/signalfd.h29
-rw-r--r--libc/sysdeps/linux/sparc/bits/signum.h25
-rw-r--r--libc/sysdeps/linux/sparc/bits/sigstack.h7
-rw-r--r--libc/sysdeps/linux/sparc/bits/socket_type.h54
-rw-r--r--libc/sysdeps/linux/sparc/bits/stackinfo.h5
-rw-r--r--libc/sysdeps/linux/sparc/bits/stat.h17
-rw-r--r--libc/sysdeps/linux/sparc/bits/statvfs.h106
-rw-r--r--libc/sysdeps/linux/sparc/bits/syscalls.h202
-rw-r--r--libc/sysdeps/linux/sparc/bits/termios.h5
-rw-r--r--libc/sysdeps/linux/sparc/bits/timerfd.h29
-rw-r--r--libc/sysdeps/linux/sparc/bits/typesizes.h5
-rw-r--r--libc/sysdeps/linux/sparc/bits/uClibc_arch_features.h17
-rw-r--r--libc/sysdeps/linux/sparc/bits/wordsize.h1
-rw-r--r--libc/sysdeps/linux/sparc/brk.c6
-rw-r--r--libc/sysdeps/linux/sparc/clone.S106
-rw-r--r--libc/sysdeps/linux/sparc/crt1.S16
-rw-r--r--libc/sysdeps/linux/sparc/crtn.S2
-rw-r--r--libc/sysdeps/linux/sparc/fork.S22
-rw-r--r--libc/sysdeps/linux/sparc/fpu_control.h5
-rw-r--r--libc/sysdeps/linux/sparc/jmpbuf-offsets.h29
-rw-r--r--libc/sysdeps/linux/sparc/jmpbuf-unwind.h24
-rw-r--r--libc/sysdeps/linux/sparc/pipe.S59
-rw-r--r--libc/sysdeps/linux/sparc/qp_ops.c79
-rw-r--r--libc/sysdeps/linux/sparc/setjmp.S10
-rw-r--r--libc/sysdeps/linux/sparc/sigaction.c98
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/double.h263
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/extended.h430
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/longlong.h1396
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/mp_clz_tab.c36
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/op-1.h301
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/op-2.h616
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/op-4.h687
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/op-8.h110
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/op-common.h1358
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/q_add.c38
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/q_cmp.c40
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/q_cmpe.c41
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/q_div.c38
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/q_dtoq.c43
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/q_feq.c39
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/q_fge.c39
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/q_fgt.c39
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/q_fle.c39
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/q_flt.c39
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/q_fne.c39
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/q_itoq.c37
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/q_lltoq.c37
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/q_mul.c38
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/q_neg.c46
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/q_qtod.c44
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/q_qtoi.c37
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/q_qtoll.c37
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/q_qtos.c44
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/q_qtou.c37
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/q_qtoull.c37
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/q_sqrt.c38
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/q_stoq.c42
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/q_sub.c38
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/q_ulltoq.c37
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/q_util.c56
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/q_utoq.c37
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/quad.h270
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/sfp-machine.h214
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/single.h150
-rw-r--r--libc/sysdeps/linux/sparc/soft-fp/soft-fp.h204
-rw-r--r--libc/sysdeps/linux/sparc/sparcv9/rem.S20
-rw-r--r--libc/sysdeps/linux/sparc/sparcv9/sdiv.S18
-rw-r--r--libc/sysdeps/linux/sparc/sparcv9/udiv.S15
-rw-r--r--libc/sysdeps/linux/sparc/sparcv9/umul.S15
-rw-r--r--libc/sysdeps/linux/sparc/sparcv9/urem.S17
-rw-r--r--libc/sysdeps/linux/sparc/sys/procfs.h93
-rw-r--r--libc/sysdeps/linux/sparc/sys/ptrace.h102
-rw-r--r--libc/sysdeps/linux/sparc/sys/ucontext.h5
-rw-r--r--libc/sysdeps/linux/sparc/sys/user.h5
-rw-r--r--libc/sysdeps/linux/sparc/syscall.S5
-rw-r--r--libc/sysdeps/linux/sparc/sysdep.h69
-rw-r--r--libc/sysdeps/linux/sparc/vfork.S7
-rw-r--r--libc/sysdeps/linux/v850/Makefile64
-rw-r--r--libc/sysdeps/linux/v850/__longjmp.S41
-rw-r--r--libc/sysdeps/linux/v850/bits/byteswap.h63
-rw-r--r--libc/sysdeps/linux/v850/bits/endian.h18
-rw-r--r--libc/sysdeps/linux/v850/bits/kernel_stat.h66
-rw-r--r--libc/sysdeps/linux/v850/bits/kernel_types.h53
-rw-r--r--libc/sysdeps/linux/v850/bits/mman.h99
-rw-r--r--libc/sysdeps/linux/v850/bits/select.h64
-rw-r--r--libc/sysdeps/linux/v850/bits/setjmp.h42
-rw-r--r--libc/sysdeps/linux/v850/bits/sigcontextinfo.h17
-rw-r--r--libc/sysdeps/linux/v850/bits/stackinfo.h23
-rw-r--r--libc/sysdeps/linux/v850/bits/syscalls.h15
-rw-r--r--libc/sysdeps/linux/v850/clinkage.h14
-rw-r--r--libc/sysdeps/linux/v850/clone.c50
-rw-r--r--libc/sysdeps/linux/v850/crt0.S57
-rw-r--r--libc/sysdeps/linux/v850/crti.S27
-rw-r--r--libc/sysdeps/linux/v850/crtn.S24
-rw-r--r--libc/sysdeps/linux/v850/mmap.c17
-rw-r--r--libc/sysdeps/linux/v850/setjmp.S48
-rw-r--r--libc/sysdeps/linux/v850/sys/ptrace.h98
-rw-r--r--libc/sysdeps/linux/v850/syscall.c43
-rw-r--r--libc/sysdeps/linux/v850/vfork.S42
-rw-r--r--libc/sysdeps/linux/vax/Makefile.arch12
-rw-r--r--libc/sysdeps/linux/vax/__longjmp.S47
-rw-r--r--libc/sysdeps/linux/vax/_setjmp.S53
-rw-r--r--libc/sysdeps/linux/vax/bits/byteswap.h64
-rw-r--r--libc/sysdeps/linux/vax/bits/fcntl.h214
-rw-r--r--libc/sysdeps/linux/vax/bits/kernel_stat.h60
-rw-r--r--libc/sysdeps/linux/vax/bits/kernel_types.h45
-rw-r--r--libc/sysdeps/linux/vax/bits/machine-gmon.h41
-rw-r--r--libc/sysdeps/linux/vax/bits/mman.h94
-rw-r--r--libc/sysdeps/linux/vax/bits/sem.h87
-rw-r--r--libc/sysdeps/linux/vax/bits/setjmp.h37
-rw-r--r--libc/sysdeps/linux/vax/bits/shm.h88
-rw-r--r--libc/sysdeps/linux/vax/bits/sigcontext.h29
-rw-r--r--libc/sysdeps/linux/vax/bits/stackinfo.h7
-rw-r--r--libc/sysdeps/linux/vax/bits/statfs.h61
-rw-r--r--libc/sysdeps/linux/vax/bits/syscalls.h258
-rw-r--r--libc/sysdeps/linux/vax/bits/wordsize.h19
-rw-r--r--libc/sysdeps/linux/vax/brk.c54
-rw-r--r--libc/sysdeps/linux/vax/clone.S85
-rw-r--r--libc/sysdeps/linux/vax/crt1.S73
-rw-r--r--libc/sysdeps/linux/vax/crti.S21
-rw-r--r--libc/sysdeps/linux/vax/crtn.S21
-rw-r--r--libc/sysdeps/linux/vax/mmap.c11
-rw-r--r--libc/sysdeps/linux/vax/setjmp.S39
-rw-r--r--libc/sysdeps/linux/vax/sys/ucontext.h80
-rw-r--r--libc/sysdeps/linux/x86_64/Makefile.arch14
-rw-r--r--libc/sysdeps/linux/x86_64/__longjmp.S10
-rw-r--r--libc/sysdeps/linux/x86_64/__start_context.S49
-rw-r--r--libc/sysdeps/linux/x86_64/bits/atomic.h55
-rw-r--r--libc/sysdeps/linux/x86_64/bits/byteswap.h132
-rw-r--r--libc/sysdeps/linux/x86_64/bits/environments.h5
-rw-r--r--libc/sysdeps/linux/x86_64/bits/epoll.h31
-rw-r--r--libc/sysdeps/linux/x86_64/bits/fcntl.h14
-rw-r--r--libc/sysdeps/linux/x86_64/bits/fenv.h9
-rw-r--r--libc/sysdeps/linux/x86_64/bits/kernel_stat.h34
-rw-r--r--libc/sysdeps/linux/x86_64/bits/kernel_types.h15
-rw-r--r--libc/sysdeps/linux/x86_64/bits/mathdef.h5
-rw-r--r--libc/sysdeps/linux/x86_64/bits/mathinline.h7
-rw-r--r--libc/sysdeps/linux/x86_64/bits/mman.h102
-rw-r--r--libc/sysdeps/linux/x86_64/bits/msq.h5
-rw-r--r--libc/sysdeps/linux/x86_64/bits/sem.h5
-rw-r--r--libc/sysdeps/linux/x86_64/bits/setjmp.h56
-rw-r--r--libc/sysdeps/linux/x86_64/bits/shm.h5
-rw-r--r--libc/sysdeps/linux/x86_64/bits/sigcontext.h5
-rw-r--r--libc/sysdeps/linux/x86_64/bits/sigcontextinfo.h5
-rw-r--r--libc/sysdeps/linux/x86_64/bits/stackinfo.h5
-rw-r--r--libc/sysdeps/linux/x86_64/bits/stat.h20
-rw-r--r--libc/sysdeps/linux/x86_64/bits/syscalls.h112
-rw-r--r--libc/sysdeps/linux/x86_64/bits/uClibc_arch_features.h17
-rw-r--r--libc/sysdeps/linux/x86_64/bits/wordsize.h8
-rw-r--r--libc/sysdeps/linux/x86_64/brk.c19
-rw-r--r--libc/sysdeps/linux/x86_64/bsd-_setjmp.S9
-rw-r--r--libc/sysdeps/linux/x86_64/bsd-setjmp.S11
-rw-r--r--libc/sysdeps/linux/x86_64/clone.S9
-rw-r--r--libc/sysdeps/linux/x86_64/crt1.S9
-rw-r--r--libc/sysdeps/linux/x86_64/crtn.S2
-rw-r--r--libc/sysdeps/linux/x86_64/fpu_control.h5
-rw-r--r--libc/sysdeps/linux/x86_64/getcontext.S88
-rw-r--r--libc/sysdeps/linux/x86_64/jmpbuf-offsets.h45
-rw-r--r--libc/sysdeps/linux/x86_64/jmpbuf-unwind.h28
-rw-r--r--libc/sysdeps/linux/x86_64/makecontext.c121
-rw-r--r--libc/sysdeps/linux/x86_64/mmap.c20
-rw-r--r--libc/sysdeps/linux/x86_64/sched_getcpu.S71
-rw-r--r--libc/sysdeps/linux/x86_64/setcontext.S103
-rw-r--r--libc/sysdeps/linux/x86_64/setjmp.S10
-rw-r--r--libc/sysdeps/linux/x86_64/sigaction.c113
-rw-r--r--libc/sysdeps/linux/x86_64/swapcontext.S121
-rw-r--r--libc/sysdeps/linux/x86_64/sys/debugreg.h5
-rw-r--r--libc/sysdeps/linux/x86_64/sys/epoll.h110
-rw-r--r--libc/sysdeps/linux/x86_64/sys/io.h7
-rw-r--r--libc/sysdeps/linux/x86_64/sys/perm.h5
-rw-r--r--libc/sysdeps/linux/x86_64/sys/procfs.h5
-rw-r--r--libc/sysdeps/linux/x86_64/sys/reg.h5
-rw-r--r--libc/sysdeps/linux/x86_64/sys/ucontext.h5
-rw-r--r--libc/sysdeps/linux/x86_64/sys/user.h5
-rw-r--r--libc/sysdeps/linux/x86_64/syscall.S5
-rw-r--r--libc/sysdeps/linux/x86_64/sysdep.h330
-rw-r--r--libc/sysdeps/linux/x86_64/ucontext_i.sym37
-rw-r--r--libc/sysdeps/linux/x86_64/vfork.S19
-rw-r--r--libc/sysdeps/linux/xtensa/Makefile.arch8
-rw-r--r--libc/sysdeps/linux/xtensa/__longjmp.S28
-rw-r--r--libc/sysdeps/linux/xtensa/bits/atomic.h232
-rw-r--r--libc/sysdeps/linux/xtensa/bits/fcntl.h13
-rw-r--r--libc/sysdeps/linux/xtensa/bits/ipc.h5
-rw-r--r--libc/sysdeps/linux/xtensa/bits/kernel_stat.h24
-rw-r--r--libc/sysdeps/linux/xtensa/bits/kernel_types.h2
-rw-r--r--libc/sysdeps/linux/xtensa/bits/mathdef.h5
-rw-r--r--libc/sysdeps/linux/xtensa/bits/mman.h7
-rw-r--r--libc/sysdeps/linux/xtensa/bits/msq.h5
-rw-r--r--libc/sysdeps/linux/xtensa/bits/setjmp.h23
-rw-r--r--libc/sysdeps/linux/xtensa/bits/shm.h5
-rw-r--r--libc/sysdeps/linux/xtensa/bits/sigcontext.h40
-rw-r--r--libc/sysdeps/linux/xtensa/bits/sigcontextinfo.h5
-rw-r--r--libc/sysdeps/linux/xtensa/bits/stackinfo.h5
-rw-r--r--libc/sysdeps/linux/xtensa/bits/stat.h14
-rw-r--r--libc/sysdeps/linux/xtensa/bits/syscalls.h61
-rw-r--r--libc/sysdeps/linux/xtensa/bits/uClibc_arch_features.h14
-rw-r--r--libc/sysdeps/linux/xtensa/bits/wordsize.h5
-rw-r--r--libc/sysdeps/linux/xtensa/bits/xtensa-config.h11
-rw-r--r--libc/sysdeps/linux/xtensa/brk.c6
-rw-r--r--libc/sysdeps/linux/xtensa/clone.S111
-rw-r--r--libc/sysdeps/linux/xtensa/crt1.S35
-rw-r--r--libc/sysdeps/linux/xtensa/crti.S15
-rw-r--r--libc/sysdeps/linux/xtensa/crtn.S17
-rw-r--r--libc/sysdeps/linux/xtensa/fork.c24
-rw-r--r--libc/sysdeps/linux/xtensa/jmpbuf-offsets.h20
-rw-r--r--libc/sysdeps/linux/xtensa/jmpbuf-unwind.h23
-rw-r--r--libc/sysdeps/linux/xtensa/mmap.S7
-rw-r--r--libc/sysdeps/linux/xtensa/posix_fadvise.c29
-rw-r--r--libc/sysdeps/linux/xtensa/posix_fadvise64.c39
-rw-r--r--libc/sysdeps/linux/xtensa/pread_write.c193
-rw-r--r--libc/sysdeps/linux/xtensa/setjmp.S174
-rw-r--r--libc/sysdeps/linux/xtensa/sigaction.c53
-rw-r--r--libc/sysdeps/linux/xtensa/sigrestorer.S6
-rw-r--r--libc/sysdeps/linux/xtensa/sys/procfs.h5
-rw-r--r--libc/sysdeps/linux/xtensa/sys/ucontext.h5
-rw-r--r--libc/sysdeps/linux/xtensa/sys/user.h20
-rw-r--r--libc/sysdeps/linux/xtensa/syscall.S9
-rw-r--r--libc/sysdeps/linux/xtensa/sysdep.h99
-rw-r--r--libc/sysdeps/linux/xtensa/vfork.S137
-rw-r--r--libc/sysdeps/linux/xtensa/windowspill.S34
1550 files changed, 36654 insertions, 24302 deletions
diff --git a/libc/sysdeps/linux/Makefile.commonarch b/libc/sysdeps/linux/Makefile.commonarch
index 1c616ec4a..f8dc17d8f 100644
--- a/libc/sysdeps/linux/Makefile.commonarch
+++ b/libc/sysdeps/linux/Makefile.commonarch
@@ -1,6 +1,6 @@
# Makefile template to be included by sysdeps/linux/<ARCH>/Makefile.arch
#
-# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2008 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
@@ -8,35 +8,56 @@
ARCH_DIR := $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)
ARCH_OUT := $(top_builddir)libc/sysdeps/linux/$(TARGET_ARCH)
-ARCH_CSRC := $(patsubst %.c,$(ARCH_DIR)/%.c,$(CSRC))
-ARCH_COBJ := $(patsubst %.c,$(ARCH_OUT)/%.o,$(CSRC))
-ARCH_SSRC := $(patsubst %.s,$(ARCH_DIR)/%.s,$(patsubst %.S,$(ARCH_DIR)/%.S,$(SSRC)))
-ARCH_SOBJ := $(patsubst %.s,$(ARCH_OUT)/%.o,$(patsubst %.S,$(ARCH_OUT)/%.o,$(SSRC)))
+ARCH_CSRC := $(addprefix $(ARCH_DIR)/,$(CSRC-y))
+ARCH_COBJ := $(addprefix $(ARCH_OUT)/,$(CSRC-y:.c=.o))
+ARCH_SSRC = $(addprefix $(ARCH_DIR)/,$(SSRC-y))
+ARCH_SOBJ = $(patsubst %.s,%.o,$(patsubst %.S,%.o,$(addprefix $(ARCH_OUT)/,$(SSRC-y))))
-ARCH_OBJS := $(ARCH_COBJ) $(ARCH_SOBJ)
+ARCH_OBJS-y = $(ARCH_COBJ) $(ARCH_SOBJ)
-crt-y := FORCE
-libc-y += $(ARCH_OBJS)
+libc-y += $(ARCH_OBJS-y)
libc-nomulti-y += $(ARCH_SOBJ)
-objclean-y += arch_objclean
-
-CFLAGS-crti.S+=$(PICFLAG)
-CFLAGS-crtn.S+=$(PICFLAG)
-
-arch_objclean:
- $(RM) $(ARCH_OUT)/*.{o,os} $(CTOR_TARGETS) $(CRTS)
+objclean-y += CLEAN_$(subst $(top_builddir),,$(ARCH_OUT))
+
+CFLAGS-OMIT-crt1.S := -D_LIBC_REENTRANT
+CFLAGS-OMIT-crti.S := -D_LIBC_REENTRANT
+CFLAGS-OMIT-crtn.S := -D_LIBC_REENTRANT
+CFLAGS-OMIT-crtreloc.c := -D_LIBC_REENTRANT
+CFLAGS-crti.S += $(PICFLAG)
+CFLAGS-crtn.S += $(PICFLAG)
+# Due to a "bug" in make these order_only prereqs inherit per-target flags.
+# Attempt to workaround this inconvenient behaviour:
+CFLAGS-OMIT-crt1.S += $(CFLAGS-rtld) -DIN_LIB=%
+CFLAGS-OMIT-crtreloc.c += $(CFLAGS-rtld) -DIN_LIB=%
+
+CLEAN_$(subst $(top_builddir),,$(ARCH_OUT)):
+ $(do_rm) $(addprefix $(ARCH_OUT)/*., o os oS) $(CTOR_TARGETS) $(CRTS)
ifneq ($(ARCH_HEADERS),)
-ARCH_HEADERS_IN := $(patsubst %,../libc/sysdeps/linux/$(TARGET_ARCH)/%,$(ARCH_HEADERS))
ARCH_HEADERS_OUT := $(patsubst %,$(top_builddir)include/%,$(ARCH_HEADERS))
$(ARCH_HEADERS_OUT):
- $(do_ln) -fs ../libc/sysdeps/linux/$(TARGET_ARCH)/$(@F) $@
+ $(do_ln) $(call rel_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/$(@F) $@
headers-y += $(ARCH_HEADERS_OUT)
-headers_clean-y += arch_headers_clean
-arch_headers_clean:
- $(RM) $(ARCH_HEADERS_OUT)
-
+headers_clean-y += HEADERCLEAN_$(subst $(top_builddir),,$(ARCH_OUT))
+HEADERCLEAN_$(subst $(top_builddir),,$(ARCH_OUT)):
+ $(do_rm) $(ARCH_HEADERS_OUT)
endif
+
+$(ARCH_OUT)/ucontext_i.h: $(top_srcdir)extra/scripts/gen-as-const.awk
+$(ARCH_OUT)/ucontext_i.h: $(ARCH_OUT)/ucontext_i.sym
+ @$(disp_gen)
+ $(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< \
+ | $(CC) $(CFLAGS) -x c - -S -o - \
+ | $(SED) $(PTHREAD_GENERATE_MANGLE) > $@
+ @if test ! -s $@ ; then rm -f $@ ; false ; fi
+
+pregen-headers-$(UCLIBC_HAS_CONTEXT_FUNCS) += $(ARCH_OUT)/ucontext_i.h
+
+headers_clean-$(UCLIBC_HAS_CONTEXT_FUNCS) += \
+ HEADERCLEAN_$(subst $(top_builddir),,$(ARCH_OUT)/ucontext_i)
+
+HEADERCLEAN_$(subst $(top_builddir),,$(ARCH_OUT)/ucontext_i):
+ $(do_rm) $(addprefix $(ARCH_OUT)/ucontext_i., c h s)
diff --git a/libc/sysdeps/linux/Makefile.in b/libc/sysdeps/linux/Makefile.in
index d2a980c16..dd91f215f 100644
--- a/libc/sysdeps/linux/Makefile.in
+++ b/libc/sysdeps/linux/Makefile.in
@@ -5,6 +5,9 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
+subdirs += libc/sysdeps/linux/$(TARGET_ARCH) libc/sysdeps/linux/common
+
# order is relevant
-include $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/Makefile.arch
+include $(top_srcdir)libc/sysdeps/linux/Makefile.commonarch
include $(top_srcdir)libc/sysdeps/linux/common/Makefile.in
diff --git a/libc/sysdeps/linux/README b/libc/sysdeps/linux/README
index 76944f9e9..d18bf8ce6 100644
--- a/libc/sysdeps/linux/README
+++ b/libc/sysdeps/linux/README
@@ -4,4 +4,7 @@ port uClibc to some new Linux architecture (arm, mips, etc), this is the place
to add that support.
All stuff that is not at all dependent on a particular Linux architecture
-goes in the 'common' directory.
+goes in the 'common' directory. However, for new architectures which are
+using the generic syscalls in the Linux Kernel, the 'common-generic'
+directory should be used instead as they all use identical interfaces for
+the system calls.
diff --git a/libc/sysdeps/linux/alpha/Makefile.arch b/libc/sysdeps/linux/alpha/Makefile.arch
index 5097008ab..c87f3cac6 100644
--- a/libc/sysdeps/linux/alpha/Makefile.arch
+++ b/libc/sysdeps/linux/alpha/Makefile.arch
@@ -5,11 +5,9 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-CSRC := __syscall_error.c sigprocmask.c
+CSRC-y := __syscall_error.c sigprocmask.c
-SSRC := \
+SSRC-y := \
__longjmp.S brk.S bsd-_setjmp.S bsd-setjmp.S clone.S \
divl.S divq.S pipe.S reml.S remq.S __syscall_rt_sigaction.S setjmp.S \
syscall.S
-
-include $(top_srcdir)libc/sysdeps/linux/Makefile.commonarch
diff --git a/libc/sysdeps/linux/alpha/__longjmp.S b/libc/sysdeps/linux/alpha/__longjmp.S
index 910ec0781..35fd481c4 100644
--- a/libc/sysdeps/linux/alpha/__longjmp.S
+++ b/libc/sysdeps/linux/alpha/__longjmp.S
@@ -12,14 +12,10 @@
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 <features.h>
-#define _SETJMP_H
-#define __ASSEMBLY__
-#include <bits/setjmp.h>
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <jmpbuf-offsets.h>
#define a0 $16
diff --git a/libc/sysdeps/linux/alpha/__syscall_rt_sigaction.S b/libc/sysdeps/linux/alpha/__syscall_rt_sigaction.S
index f7e9e44a6..57a4b98d3 100644
--- a/libc/sysdeps/linux/alpha/__syscall_rt_sigaction.S
+++ b/libc/sysdeps/linux/alpha/__syscall_rt_sigaction.S
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <features.h>
#include <sys/syscall.h>
@@ -31,6 +30,9 @@
.text
.globl __syscall_rt_sigaction
+#ifndef __UCLIBC_HAS_THREADS_NATIVE__
+.hidden __syscall_rt_sigaction
+#endif
.align 4
.ent __syscall_rt_sigaction, 0
__syscall_rt_sigaction:
diff --git a/libc/sysdeps/linux/alpha/bits/atomic.h b/libc/sysdeps/linux/alpha/bits/atomic.h
index 5ef091dc0..a077b932c 100644
--- a/libc/sysdeps/linux/alpha/bits/atomic.h
+++ b/libc/sysdeps/linux/alpha/bits/atomic.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <stdint.h>
@@ -179,22 +178,22 @@ typedef uintmax_t uatomic_max_t;
#define __arch_compare_and_exchange_val_8_int(mem, new, old, mb1, mb2) \
({ unsigned long __prev; int __cmp; \
__arch_compare_and_exchange_xxx_8_int(mem, new, old, mb1, mb2); \
- (typeof (*mem))__prev; })
+ (__typeof (*mem))__prev; })
#define __arch_compare_and_exchange_val_16_int(mem, new, old, mb1, mb2) \
({ unsigned long __prev; int __cmp; \
__arch_compare_and_exchange_xxx_16_int(mem, new, old, mb1, mb2); \
- (typeof (*mem))__prev; })
+ (__typeof (*mem))__prev; })
#define __arch_compare_and_exchange_val_32_int(mem, new, old, mb1, mb2) \
({ unsigned long __prev; int __cmp; \
__arch_compare_and_exchange_xxx_32_int(mem, new, old, mb1, mb2); \
- (typeof (*mem))__prev; })
+ (__typeof (*mem))__prev; })
#define __arch_compare_and_exchange_val_64_int(mem, new, old, mb1, mb2) \
({ unsigned long __prev; int __cmp; \
__arch_compare_and_exchange_xxx_64_int(mem, new, old, mb1, mb2); \
- (typeof (*mem))__prev; })
+ (__typeof (*mem))__prev; })
/* Compare and exchange with "acquire" semantics, ie barrier after. */
diff --git a/libc/sysdeps/linux/alpha/bits/dirent.h b/libc/sysdeps/linux/alpha/bits/dirent.h
index 6ed74783a..7d11250a1 100644
--- a/libc/sysdeps/linux/alpha/bits/dirent.h
+++ b/libc/sysdeps/linux/alpha/bits/dirent.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _BITS_DIRENT_H
#define _BITS_DIRENT_H 1
diff --git a/libc/sysdeps/linux/alpha/bits/epoll.h b/libc/sysdeps/linux/alpha/bits/epoll.h
new file mode 100644
index 000000000..7f9f37497
--- /dev/null
+++ b/libc/sysdeps/linux/alpha/bits/epoll.h
@@ -0,0 +1,29 @@
+/* Copyright (C) 2002-2012 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_EPOLL_H
+# error "Never use <bits/epoll.h> directly; include <sys/epoll.h> instead."
+#endif
+
+/* Flags to be passed to epoll_create1. */
+enum
+ {
+ EPOLL_CLOEXEC = 010000000,
+#define EPOLL_CLOEXEC EPOLL_CLOEXEC
+ EPOLL_NONBLOCK = 000000004
+#define EPOLL_NONBLOCK EPOLL_NONBLOCK
+ };
diff --git a/libc/sysdeps/linux/alpha/bits/eventfd.h b/libc/sysdeps/linux/alpha/bits/eventfd.h
new file mode 100644
index 000000000..b5a7e41ce
--- /dev/null
+++ b/libc/sysdeps/linux/alpha/bits/eventfd.h
@@ -0,0 +1,31 @@
+/* Copyright (C) 2007-2013 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_EVENTFD_H
+# error "Never use <bits/eventfd.h> directly; include <sys/eventfd.h> instead."
+#endif
+
+/* Flags for eventfd. */
+enum
+ {
+ EFD_SEMAPHORE = 000000001,
+#define EFD_SEMAPHORE EFD_SEMAPHORE
+ EFD_CLOEXEC = 010000000,
+#define EFD_CLOEXEC EFD_CLOEXEC
+ EFD_NONBLOCK = 000000004
+#define EFD_NONBLOCK EFD_NONBLOCK
+ };
diff --git a/libc/sysdeps/linux/alpha/bits/fcntl.h b/libc/sysdeps/linux/alpha/bits/fcntl.h
index 85e0fca30..34a174cf2 100644
--- a/libc/sysdeps/linux/alpha/bits/fcntl.h
+++ b/libc/sysdeps/linux/alpha/bits/fcntl.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FCNTL_H
# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
@@ -48,11 +47,10 @@
#ifdef __USE_GNU
# define O_DIRECTORY 0100000 /* Must be a directory. */
# define O_NOFOLLOW 0200000 /* Do not follow links. */
-# define O_DIRECT 02000000 /* Direct disk access. */
-# define O_NOATIME 04000000 /* Do not set atime. */
-# if 0
-# define O_CLOEXEC 010000000 /* Set close_on_exec. */
-# endif
+# define O_DIRECT 02000000 /* Direct disk access. */
+# define O_NOATIME 04000000 /* Do not set atime. */
+# define O_CLOEXEC 010000000 /* Set close_on_exec. */
+# define O_PATH 040000000 /* Resolve pathname but do not open file. */
#endif
#ifdef __USE_LARGEFILE64
@@ -97,6 +95,8 @@
# define F_NOTIFY 1026 /* Request notfications on a directory. */
# define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with
close-on-exit set on new fd. */
+# define F_SETPIPE_SZ 1031 /* Set pipe page size array. */
+# define F_GETPIPE_SZ 1032 /* Get pipe page size array. */
#endif
/* for F_[GET|SET]FD */
@@ -159,7 +159,6 @@ struct flock64
};
#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
@@ -181,7 +180,7 @@ struct flock64
#endif
-#ifdef __USE_GNU
+#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
@@ -204,7 +203,7 @@ struct flock64
__BEGIN_DECLS
-#ifdef __USE_GNU
+#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)
diff --git a/libc/sysdeps/linux/alpha/bits/fenv.h b/libc/sysdeps/linux/alpha/bits/fenv.h
index a9e89b498..d36b94dd1 100644
--- a/libc/sysdeps/linux/alpha/bits/fenv.h
+++ b/libc/sysdeps/linux/alpha/bits/fenv.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FENV_H
# error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
@@ -107,15 +106,15 @@ typedef unsigned long int fenv_t;
/* If the default argument is used we use this value. Note that due to
architecture-specified page mappings, no user-space pointer will ever
have its two high bits set. Co-opt one. */
-#define FE_DFL_ENV ((__const fenv_t *) 0x8800000000000000UL)
+#define FE_DFL_ENV ((const fenv_t *) 0x8800000000000000UL)
#ifdef __USE_GNU
/* Floating-point environment where none of the exceptions are masked. */
-# define FE_NOMASK_ENV ((__const fenv_t *) 0x880000000000003eUL)
+# define FE_NOMASK_ENV ((const fenv_t *) 0x880000000000003eUL)
/* Floating-point environment with (processor-dependent) non-IEEE floating
point. In this case, mapping denormals to zero. */
-# define FE_NONIEEE_ENV ((__const fenv_t *) 0x8800000000003000UL)
+# define FE_NONIEEE_ENV ((const fenv_t *) 0x8800000000003000UL)
#endif
/* The system calls to talk to the kernel's FP code. */
diff --git a/libc/sysdeps/linux/alpha/bits/inotify.h b/libc/sysdeps/linux/alpha/bits/inotify.h
new file mode 100644
index 000000000..3fbe3b8ec
--- /dev/null
+++ b/libc/sysdeps/linux/alpha/bits/inotify.h
@@ -0,0 +1,29 @@
+/* Copyright (C) 2005-2012 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_INOTIFY_H
+# error "Never use <bits/inotify.h> directly; include <sys/inotify.h> instead."
+#endif
+
+/* Flags for the parameter of inotify_init1. */
+enum
+ {
+ IN_CLOEXEC = 010000000,
+#define IN_CLOEXEC IN_CLOEXEC
+ IN_NONBLOCK = 000000004
+#define IN_NONBLOCK IN_NONBLOCK
+ };
diff --git a/libc/sysdeps/linux/alpha/bits/ioctls.h b/libc/sysdeps/linux/alpha/bits/ioctls.h
index c525046e5..65668d3a6 100644
--- a/libc/sysdeps/linux/alpha/bits/ioctls.h
+++ b/libc/sysdeps/linux/alpha/bits/ioctls.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_IOCTL_H
# error "Never use <bits/ioctls.h> directly; include <sys/ioctl.h> instead."
diff --git a/libc/sysdeps/linux/alpha/bits/ipc.h b/libc/sysdeps/linux/alpha/bits/ipc.h
index 77f3c938d..e2e20d149 100644
--- a/libc/sysdeps/linux/alpha/bits/ipc.h
+++ b/libc/sysdeps/linux/alpha/bits/ipc.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_IPC_H
# error "Never use <bits/ipc.h> directly; include <sys/ipc.h> instead."
diff --git a/libc/sysdeps/linux/alpha/bits/kernel_sigaction.h b/libc/sysdeps/linux/alpha/bits/kernel_sigaction.h
index d111a5f3d..7746e3078 100644
--- a/libc/sysdeps/linux/alpha/bits/kernel_sigaction.h
+++ b/libc/sysdeps/linux/alpha/bits/kernel_sigaction.h
@@ -9,15 +9,4 @@ struct old_kernel_sigaction {
unsigned int sa_flags;
};
-/* This is the sigaction structure from the Linux 2.1.68 kernel. */
-
-struct kernel_sigaction {
- __sighandler_t k_sa_handler;
- unsigned int sa_flags;
- sigset_t sa_mask;
-};
-
-extern int __syscall_rt_sigaction (int, const struct kernel_sigaction *__unbounded,
- struct kernel_sigaction *__unbounded, size_t) attribute_hidden;
-
#endif
diff --git a/libc/sysdeps/linux/alpha/bits/kernel_stat.h b/libc/sysdeps/linux/alpha/bits/kernel_stat.h
index 649257b7e..32830fe2d 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... */
@@ -17,9 +13,9 @@ struct kernel_stat {
unsigned int st_gid;
unsigned int st_rdev;
long int st_size;
- unsigned long st_atime;
- unsigned long st_mtime;
- unsigned long st_ctime;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
unsigned int st_blksize;
int st_blocks;
unsigned int st_flags;
@@ -40,12 +36,9 @@ struct kernel_stat64 {
unsigned int st_nlink;
unsigned int __pad0;
- unsigned long st_atime;
- unsigned long st_atimensec;
- unsigned long st_mtime;
- unsigned long st_mtimensec;
- unsigned long st_ctime;
- unsigned long st_ctimensec;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
long __unused[3];
};
diff --git a/libc/sysdeps/linux/alpha/bits/kernel_types.h b/libc/sysdeps/linux/alpha/bits/kernel_types.h
index d5574c9b4..cd59b9d5e 100644
--- a/libc/sysdeps/linux/alpha/bits/kernel_types.h
+++ b/libc/sysdeps/linux/alpha/bits/kernel_types.h
@@ -33,6 +33,8 @@ typedef __kernel_gid_t __kernel_old_gid_t;
typedef __kernel_uid_t __kernel_uid32_t;
typedef __kernel_gid_t __kernel_gid32_t;
typedef __kernel_dev_t __kernel_old_dev_t;
+typedef long __kernel_long_t;
+typedef unsigned long __kernel_ulong_t;
typedef struct {
int val[2];
diff --git a/libc/sysdeps/linux/alpha/bits/local_lim.h b/libc/sysdeps/linux/alpha/bits/local_lim.h
new file mode 100644
index 000000000..2ff109095
--- /dev/null
+++ b/libc/sysdeps/linux/alpha/bits/local_lim.h
@@ -0,0 +1,91 @@
+/* Minimum guaranteed maximum values for system limits. Linux/Alpha version.
+ Copyright (C) 1993-1998,2000,2002,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 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,
+ see <http://www.gnu.org/licenses/>. */
+
+/* The kernel header pollutes the namespace with the NR_OPEN symbol
+ and defines LINK_MAX although filesystems have different maxima. A
+ similar thing is true for OPEN_MAX: the limit can be changed at
+ runtime and therefore the macro must not be defined. Remove this
+ after including the header if necessary. */
+#ifndef NR_OPEN
+# define __undef_NR_OPEN
+#endif
+#ifndef LINK_MAX
+# define __undef_LINK_MAX
+#endif
+#ifndef OPEN_MAX
+# define __undef_OPEN_MAX
+#endif
+
+/* The kernel sources contain a file with all the needed information. */
+#include <linux/limits.h>
+
+/* Have to remove NR_OPEN? */
+#ifdef __undef_NR_OPEN
+# undef NR_OPEN
+# undef __undef_NR_OPEN
+#endif
+/* Have to remove LINK_MAX? */
+#ifdef __undef_LINK_MAX
+# undef LINK_MAX
+# undef __undef_LINK_MAX
+#endif
+/* Have to remove OPEN_MAX? */
+#ifdef __undef_OPEN_MAX
+# undef OPEN_MAX
+# undef __undef_OPEN_MAX
+#endif
+
+/* The number of data keys per process. */
+#define _POSIX_THREAD_KEYS_MAX 128
+/* This is the value this implementation supports. */
+#define PTHREAD_KEYS_MAX 1024
+
+/* Controlling the iterations of destructors for thread-specific data. */
+#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
+/* Number of iterations this implementation does. */
+#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
+
+/* The number of threads per process. */
+#define _POSIX_THREAD_THREADS_MAX 64
+/* We have no predefined limit on the number of threads. */
+#undef PTHREAD_THREADS_MAX
+
+/* Maximum amount by which a process can descrease its asynchronous I/O
+ priority level. */
+#define AIO_PRIO_DELTA_MAX 20
+
+/* Minimum size for a thread. We are free to choose a reasonable value. */
+#define PTHREAD_STACK_MIN 24576
+
+/* Maximum number of timer expiration overruns. */
+#define DELAYTIMER_MAX 2147483647
+
+/* Maximum tty name length. */
+#define TTY_NAME_MAX 32
+
+/* Maximum login name length. This is arbitrary. */
+#define LOGIN_NAME_MAX 256
+
+/* Maximum host name length. */
+#define HOST_NAME_MAX 64
+
+/* Maximum message queue priority level. */
+#define MQ_PRIO_MAX 32768
+
+/* Maximum value the semaphore can have. */
+#define SEM_VALUE_MAX (2147483647)
diff --git a/libc/sysdeps/linux/alpha/bits/mathdef.h b/libc/sysdeps/linux/alpha/bits/mathdef.h
index 3b52ec7d5..d0e659ce5 100644
--- a/libc/sysdeps/linux/alpha/bits/mathdef.h
+++ b/libc/sysdeps/linux/alpha/bits/mathdef.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#if !defined _MATH_H && !defined _COMPLEX_H
# error "Never use <bits/mathdef.h> directly; include <math.h> instead"
@@ -27,28 +26,10 @@
#if defined __USE_ISOC99 && defined _MATH_H && !defined _MATH_H_MATHDEF
# define _MATH_H_MATHDEF 1
-# ifdef __GNUC__
-# if __STDC__ == 1
-
-/* In GNU or ANSI mode, gcc leaves `float' expressions as-is. */
+/* Alpha has both `float' and `double' arithmetic. */
typedef float float_t;
typedef double double_t;
-# else
-
-/* For `gcc -traditional', `float' expressions are evaluated as `double'. */
-typedef double float_t;
-typedef double double_t;
-
-# endif
-# else
-
-/* Wild guess at types for float_t and double_t. */
-typedef double float_t;
-typedef double double_t;
-
-# endif
-
/* The values returned by `ilogb' for 0 and NaN respectively. */
# define FP_ILOGB0 (-2147483647)
# define FP_ILOGBNAN (2147483647)
@@ -62,12 +43,12 @@ typedef double double_t;
/* Due to an ABI change, we need to remap the complex float symbols. */
# define _Mdouble_ float
# define __MATHCALL(function, args) \
- __MATHDECL (_Complex float, function, args)
+ __MATHDECL(_Complex float, function, args)
# define __MATHDECL(type, function, args) \
- __MATHDECL_1(type, function##f, args, __c1_##function##f); \
- __MATHDECL_1(type, __##function##f, args, __c1_##function##f)
+ __MATHDECL_1(type, function##f, args, __c1_##function##f); \
+ __MATHDECL_1(type, __##function##f, args, __c1_##function##f)
# define __MATHDECL_1(type, function, args, alias) \
- extern type function args __asm__(#alias) __THROW
+ extern type function args __asm__(#alias) __THROW
# include <bits/cmathcalls.h>
diff --git a/libc/sysdeps/linux/alpha/bits/mathinline.h b/libc/sysdeps/linux/alpha/bits/mathinline.h
index 3dd38e89f..ff23b5c1a 100644
--- a/libc/sysdeps/linux/alpha/bits/mathinline.h
+++ b/libc/sysdeps/linux/alpha/bits/mathinline.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _MATH_H
# error "Never use <bits/mathinline.h> directly; include <math.h> instead."
@@ -25,7 +24,7 @@
#ifdef __cplusplus
# define __MATH_INLINE __inline
#else
-# define __MATH_INLINE extern __inline
+# define __MATH_INLINE __extern_inline
#endif
#if defined __USE_ISOC99 && defined __GNUC__ && !__GNUC_PREREQ(3,0)
diff --git a/libc/sysdeps/linux/alpha/bits/mman.h b/libc/sysdeps/linux/alpha/bits/mman.h
index 2f0e56491..a9820d596 100644
--- a/libc/sysdeps/linux/alpha/bits/mman.h
+++ b/libc/sysdeps/linux/alpha/bits/mman.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_MMAN_H
# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
@@ -71,6 +70,8 @@
# define MAP_NORESERVE 0x10000 /* Don't check for reservations. */
# define MAP_POPULATE 0x20000 /* Populate (prefault) pagetables. */
# define MAP_NONBLOCK 0x40000 /* Do not block on IO. */
+# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could
+ be uninitialized. */
#endif
/* Flags to `msync'. */
diff --git a/libc/sysdeps/linux/alpha/bits/msq.h b/libc/sysdeps/linux/alpha/bits/msq.h
index ab251eaf7..ea0dba0cc 100644
--- a/libc/sysdeps/linux/alpha/bits/msq.h
+++ b/libc/sysdeps/linux/alpha/bits/msq.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_MSG_H
# error "Never use <bits/msq.h> directly; include <sys/msg.h> instead."
diff --git a/libc/sysdeps/linux/alpha/bits/netdb.h b/libc/sysdeps/linux/alpha/bits/netdb.h
index e3664fd29..18ba264b5 100644
--- a/libc/sysdeps/linux/alpha/bits/netdb.h
+++ b/libc/sysdeps/linux/alpha/bits/netdb.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _NETDB_H
# error "Never include <bits/netdb.h> directly; use <netdb.h> instead."
diff --git a/libc/sysdeps/linux/alpha/bits/resource.h b/libc/sysdeps/linux/alpha/bits/resource.h
index 216374584..74f4eed69 100644
--- a/libc/sysdeps/linux/alpha/bits/resource.h
+++ b/libc/sysdeps/linux/alpha/bits/resource.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_RESOURCE_H
# error "Never use <bits/resource.h> directly; include <sys/resource.h> instead."
diff --git a/libc/sysdeps/linux/alpha/bits/sem.h b/libc/sysdeps/linux/alpha/bits/sem.h
index f63360b2b..0bd103620 100644
--- a/libc/sysdeps/linux/alpha/bits/sem.h
+++ b/libc/sysdeps/linux/alpha/bits/sem.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_SEM_H
# error "Never include <bits/sem.h> directly; use <sys/sem.h> instead."
diff --git a/libc/sysdeps/linux/alpha/bits/setjmp.h b/libc/sysdeps/linux/alpha/bits/setjmp.h
index 4471ba975..6bcdbf672 100644
--- a/libc/sysdeps/linux/alpha/bits/setjmp.h
+++ b/libc/sysdeps/linux/alpha/bits/setjmp.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _BITS_SETJMP_H
#define _BITS_SETJMP_H 1
@@ -55,33 +54,6 @@
* registers.
*/
-#if defined __USE_MISC || defined __ASSEMBLY__
-# define JB_S0 0
-# define JB_S1 1
-# define JB_S2 2
-# define JB_S3 3
-# define JB_S4 4
-# define JB_S5 5
-# define JB_PC 6
-# define JB_FP 7
-# define JB_SP 8
-# define JB_F2 9
-# define JB_F3 10
-# define JB_F4 11
-# define JB_F5 12
-# define JB_F6 13
-# define JB_F7 14
-# define JB_F8 15
-# define JB_F9 16
-#endif
-
-#ifndef __ASSEMBLY__
typedef long int __jmp_buf[17];
-/* Test if longjmp to JMPBUF would unwind the frame containing a local
- variable at ADDRESS. */
-#define _JMPBUF_UNWINDS(_jmpbuf, _address) \
- ((void *)(_address) < (void *)((_jmpbuf)[JB_SP]))
-#endif
-
#endif /* bits/setjmp.h */
diff --git a/libc/sysdeps/linux/alpha/bits/shm.h b/libc/sysdeps/linux/alpha/bits/shm.h
index 35226c16c..e62b05afb 100644
--- a/libc/sysdeps/linux/alpha/bits/shm.h
+++ b/libc/sysdeps/linux/alpha/bits/shm.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_SHM_H
# error "Never include <bits/shm.h> directly; use <sys/shm.h> instead."
diff --git a/libc/sysdeps/linux/alpha/bits/sigaction.h b/libc/sysdeps/linux/alpha/bits/sigaction.h
index 80feb2fa2..293281d52 100644
--- a/libc/sysdeps/linux/alpha/bits/sigaction.h
+++ b/libc/sysdeps/linux/alpha/bits/sigaction.h
@@ -13,39 +13,29 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SIGNAL_H
# error "Never include <bits/sigaction.h> directly; use <signal.h> instead."
#endif
/* Structure describing the action to be taken when a signal arrives. */
-struct sigaction
- {
- /* Signal handler. */
+struct sigaction {
#ifdef __USE_POSIX199309
- union
- {
- /* Used if SA_SIGINFO is not set. */
- __sighandler_t sa_handler;
- /* Used if SA_SIGINFO is set. */
- void (*sa_sigaction) (int, siginfo_t *, void *);
- }
- __sigaction_handler;
-# define sa_handler __sigaction_handler.sa_handler
-# define sa_sigaction __sigaction_handler.sa_sigaction
+ union {
+ __sighandler_t sa_handler;
+ void (*sa_sigaction)(int, siginfo_t *, void *);
+ } __sigaction_handler;
+# define sa_handler __sigaction_handler.sa_handler
+# define sa_sigaction __sigaction_handler.sa_sigaction
#else
- __sighandler_t sa_handler;
+ __sighandler_t sa_handler;
#endif
-
- /* Additional set of signals to be blocked. */
- __sigset_t sa_mask;
-
- /* Special flags. */
- unsigned int sa_flags;
- };
+ unsigned sa_flags;
+ sigset_t sa_mask;
+ /* Alpha has no sa_restorer field. */
+};
/* Bits in `sa_flags'. */
#define SA_NOCLDSTOP 0x00000004 /* Don't send SIGCHLD when children stop. */
diff --git a/libc/sysdeps/linux/alpha/bits/sigcontextinfo.h b/libc/sysdeps/linux/alpha/bits/sigcontextinfo.h
index 16c5dcbc5..730a70dce 100644
--- a/libc/sysdeps/linux/alpha/bits/sigcontextinfo.h
+++ b/libc/sysdeps/linux/alpha/bits/sigcontextinfo.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#define SIGCONTEXT int _code, struct sigcontext *
#define SIGCONTEXT_EXTRA_ARGS _code,
diff --git a/libc/sysdeps/linux/alpha/bits/siginfo.h b/libc/sysdeps/linux/alpha/bits/siginfo.h
index a2aacc04b..7e476aa70 100644
--- a/libc/sysdeps/linux/alpha/bits/siginfo.h
+++ b/libc/sysdeps/linux/alpha/bits/siginfo.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#if !defined _SIGNAL_H && !defined __need_siginfo_t \
&& !defined __need_sigevent_t
@@ -98,6 +97,14 @@ typedef struct siginfo
int si_band; /* Band event for SIGPOLL. */
int si_fd;
} _sigpoll;
+
+ /* SIGSYS. */
+ struct
+ {
+ void *_call_addr; /* Calling user insn. */
+ int _syscall; /* Triggering system call number. */
+ unsigned int _arch; /* AUDIT_ARCH_* of syscall. */
+ } _sigsys;
} _sifields;
} siginfo_t;
@@ -116,6 +123,9 @@ typedef struct siginfo
# define si_addr _sifields._sigfault.si_addr
# define si_band _sifields._sigpoll.si_band
# define si_fd _sifields._sigpoll.si_fd
+# define si_call_addr _sifields._sigsys._call_addr
+# define si_syscall _sifields._sigsys._syscall
+# define si_arch _sifields._sigsys._arch
/* Values for `si_code'. Positive values are reserved for kernel-generated
@@ -258,7 +268,11 @@ enum
/* Structure to transport application-defined values with signals. */
# define __SIGEV_MAX_SIZE 64
-# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 4)
+# if __WORDSIZE == 64
+# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 4)
+# else
+# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 3)
+# endif
typedef struct sigevent
{
diff --git a/libc/sysdeps/linux/alpha/bits/signalfd.h b/libc/sysdeps/linux/alpha/bits/signalfd.h
new file mode 100644
index 000000000..7ea70faef
--- /dev/null
+++ b/libc/sysdeps/linux/alpha/bits/signalfd.h
@@ -0,0 +1,29 @@
+/* Copyright (C) 2007-2012 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_SIGNALFD_H
+# error "Never use <bits/signalfd.h> directly; include <sys/signalfd.h> instead."
+#endif
+
+/* Flags for signalfd. */
+enum
+ {
+ SFD_CLOEXEC = 010000000,
+#define SFD_CLOEXEC SFD_CLOEXEC
+ SFD_NONBLOCK = 000000004
+#define SFD_NONBLOCK SFD_NONBLOCK
+ };
diff --git a/libc/sysdeps/linux/alpha/bits/signum.h b/libc/sysdeps/linux/alpha/bits/signum.h
index 477c13175..ce6b1b4a1 100644
--- a/libc/sysdeps/linux/alpha/bits/signum.h
+++ b/libc/sysdeps/linux/alpha/bits/signum.h
@@ -13,21 +13,11 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifdef _SIGNAL_H
-/* Fake signal functions. */
-#define SIG_ERR ((__sighandler_t) -1) /* Error return. */
-#define SIG_DFL ((__sighandler_t) 0) /* Default action. */
-#define SIG_IGN ((__sighandler_t) 1) /* Ignore signal. */
-
-#ifdef __USE_UNIX98
-# define SIG_HOLD ((__sighandler_t) 2) /* Add signal to hold mask. */
-#endif
-
/*
* Linux/AXP has different signal numbers that Linux/i386: I'm trying
* to make it OSF/1 binary compatible, at least for normal binaries.
@@ -69,14 +59,4 @@
#define SIGPWR SIGINFO
#define SIGIOT SIGABRT
-#define _NSIG 65 /* Biggest signal number + 1. */
-
-#define SIGRTMIN (__libc_current_sigrtmin ())
-#define SIGRTMAX (__libc_current_sigrtmax ())
-
-/* These are the hard limits of the kernel. These values should not be
- used directly at user level. */
-#define __SIGRTMIN 32
-#define __SIGRTMAX (_NSIG - 1)
-
#endif /* <signal.h> included. */
diff --git a/libc/sysdeps/linux/alpha/bits/sigstack.h b/libc/sysdeps/linux/alpha/bits/sigstack.h
index 7faaf98d5..4862d7f72 100644
--- a/libc/sysdeps/linux/alpha/bits/sigstack.h
+++ b/libc/sysdeps/linux/alpha/bits/sigstack.h
@@ -13,21 +13,22 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SIGNAL_H
# error "Never include this file directly. Use <signal.h> instead"
#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/socket_type.h b/libc/sysdeps/linux/alpha/bits/socket_type.h
new file mode 100644
index 000000000..ee55d66f7
--- /dev/null
+++ b/libc/sysdeps/linux/alpha/bits/socket_type.h
@@ -0,0 +1,54 @@
+/* Define enum __socket_type for Linux/Alpha.
+ Copyright (C) 1991-2012 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_SOCKET_H
+# error "Never include <bits/socket_type.h> directly; use <sys/socket.h> instead."
+#endif
+
+/* Types of sockets. */
+enum __socket_type
+{
+ SOCK_STREAM = 1, /* Sequenced, reliable, connection-based
+ byte streams. */
+#define SOCK_STREAM SOCK_STREAM
+ SOCK_DGRAM = 2, /* Connectionless, unreliable datagrams
+ of fixed maximum length. */
+#define SOCK_DGRAM SOCK_DGRAM
+ SOCK_RAW = 3, /* Raw protocol interface. */
+#define SOCK_RAW SOCK_RAW
+ SOCK_RDM = 4, /* Reliably-delivered messages. */
+#define SOCK_RDM SOCK_RDM
+ SOCK_SEQPACKET = 5, /* Sequenced, reliable, connection-based,
+ datagrams of fixed maximum length. */
+#define SOCK_SEQPACKET SOCK_SEQPACKET
+ SOCK_DCCP = 6, /* Datagram Congestion Control Protocol. */
+#define SOCK_DCCP SOCK_DCCP
+ SOCK_PACKET = 10, /* Linux specific way of getting packets
+ at the dev level. For writing rarp and
+ other similar things on the user level. */
+#define SOCK_PACKET SOCK_PACKET
+
+ /* Flags to be ORed into the type parameter of socket and socketpair. */
+
+ SOCK_CLOEXEC = 010000000, /* Atomically set close-on-exec flag for the
+ new descriptor(s). */
+#define SOCK_CLOEXEC SOCK_CLOEXEC
+ SOCK_NONBLOCK = 0x40000000 /* Atomically mark descriptor(s) as
+ non-blocking. */
+#define SOCK_NONBLOCK SOCK_NONBLOCK
+};
diff --git a/libc/sysdeps/linux/alpha/bits/stackinfo.h b/libc/sysdeps/linux/alpha/bits/stackinfo.h
index 0a281bd43..cced1c3d4 100644
--- a/libc/sysdeps/linux/alpha/bits/stackinfo.h
+++ b/libc/sysdeps/linux/alpha/bits/stackinfo.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* This file contains a bit of information about the stack allocation
of the processor. */
diff --git a/libc/sysdeps/linux/alpha/bits/stat.h b/libc/sysdeps/linux/alpha/bits/stat.h
index 148c6ff70..cbcdf2145 100644
--- a/libc/sysdeps/linux/alpha/bits/stat.h
+++ b/libc/sysdeps/linux/alpha/bits/stat.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_STAT_H
# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
@@ -41,7 +40,7 @@
Use neat tidy anonymous unions and structures when possible. */
-#if 0 /*def __USE_MISC*/
+#ifdef __USE_MISC
# if __GNUC_PREREQ(3,3)
# define __ST_TIME(X) \
__extension__ union { \
@@ -149,3 +148,8 @@ struct stat64
#define __S_IREAD 0400 /* Read by owner. */
#define __S_IWRITE 0200 /* Write by owner. */
#define __S_IEXEC 0100 /* Execute by owner. */
+
+#ifdef __USE_ATFILE
+# define UTIME_NOW ((1l << 30) - 1l)
+# define UTIME_OMIT ((1l << 30) - 2l)
+#endif
diff --git a/libc/sysdeps/linux/alpha/bits/statfs.h b/libc/sysdeps/linux/alpha/bits/statfs.h
index d838e6bf4..f8b61c722 100644
--- a/libc/sysdeps/linux/alpha/bits/statfs.h
+++ b/libc/sysdeps/linux/alpha/bits/statfs.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_STATFS_H
# error "Never include <bits/statfs.h> directly; use <sys/statfs.h> instead."
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/alpha/bits/syscalls.h b/libc/sysdeps/linux/alpha/bits/syscalls.h
index b5e0c1602..de97d41a6 100644
--- a/libc/sysdeps/linux/alpha/bits/syscalls.h
+++ b/libc/sysdeps/linux/alpha/bits/syscalls.h
@@ -1,3 +1,22 @@
+/* Copyright (C) 1992, 1995, 1996, 2000, 2003, 2004, 2006
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
#ifndef _BITS_SYSCALLS_H
#define _BITS_SYSCALLS_H
#ifndef _SYSCALL_H
@@ -6,186 +25,234 @@
#ifndef __ASSEMBLER__
-#include <errno.h>
-
-#define SYS_ify(syscall_name) (__NR_##syscall_name)
-
-#define _syscall_return(type) \
- return (_sc_err ? __set_errno(_sc_ret), _sc_ret = -1L : 0), (type) _sc_ret
-
-#define _syscall_clobbers \
- "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", \
- "$22", "$23", "$24", "$25", "$27", "$28" \
-
-#define _syscall0(type, name) \
-type name(void) \
-{ \
- long _sc_ret, _sc_err; \
- { \
- register long _sc_0 __asm__("$0"); \
- register long _sc_19 __asm__("$19"); \
- \
- _sc_0 = __NR_##name; \
- __asm__("callsys # %0 %1 %2" \
- : "=r"(_sc_0), "=r"(_sc_19) \
- : "0"(_sc_0) \
- : _syscall_clobbers); \
- _sc_ret = _sc_0, _sc_err = _sc_19; \
- } \
- _syscall_return(type); \
+#define INLINE_SYSCALL_NCS(name, nr, args...) \
+(__extension__ \
+ ({ \
+ long _sc_ret, _sc_err; \
+ inline_syscall##nr(name, args); \
+ if (unlikely (_sc_err)) \
+ { \
+ __set_errno (_sc_ret); \
+ _sc_ret = -1L; \
+ } \
+ _sc_ret; \
+ }) \
+)
+
+#define INTERNAL_SYSCALL_NCS(name, err_out, nr, args...) \
+(__extension__ \
+ ({ \
+ long _sc_ret, _sc_err; \
+ inline_syscall##nr(name, args); \
+ err_out = _sc_err; \
+ _sc_ret; \
+ }) \
+)
+#define INTERNAL_SYSCALL_DECL(err) long int err
+#define INTERNAL_SYSCALL_ERROR_P(val, err) err
+#define INTERNAL_SYSCALL_ERRNO(val, err) val
+
+#define inline_syscall_clobbers \
+ "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", \
+ "$22", "$23", "$24", "$25", "$27", "$28", "memory"
+
+/* If TLS is in use, we have a conflict between the PAL_rduniq primitive,
+ as modeled within GCC, and explicit use of the R0 register. If we use
+ the register via the asm, the scheduler may place the PAL_rduniq insn
+ before we've copied the data from R0 into _sc_ret. If this happens
+ we'll get a reload abort, since R0 is live at the same time it is
+ needed for the PAL_rduniq.
+
+ Solve this by using the "v" constraint instead of an asm for the syscall
+ output. We don't do this unconditionally to allow compilation with
+ older compilers. */
+
+#ifdef HAVE___THREAD
+#define inline_syscall_r0_asm
+#define inline_syscall_r0_out_constraint "=v"
+#else
+#define inline_syscall_r0_asm __asm__("$0")
+#define inline_syscall_r0_out_constraint "=r"
+#endif
+
+/* It is moderately important optimization-wise to limit the lifetime
+ of the hard-register variables as much as possible. Thus we copy
+ in/out as close to the asm as possible. */
+
+#define inline_syscall0(name, args...) \
+{ \
+ register long _sc_0 inline_syscall_r0_asm; \
+ register long _sc_19 __asm__("$19"); \
+ \
+ _sc_0 = name; \
+ __asm__ __volatile__ \
+ ("callsys # %0 %1 <= %2" \
+ : inline_syscall_r0_out_constraint (_sc_0), \
+ "=r"(_sc_19) \
+ : "0"(_sc_0) \
+ : inline_syscall_clobbers, \
+ "$16", "$17", "$18", "$20", "$21"); \
+ _sc_ret = _sc_0, _sc_err = _sc_19; \
}
-#define _syscall1(type,name,type1,arg1) \
-type name(type1 arg1) \
-{ \
- long _sc_ret, _sc_err; \
- { \
- register long _sc_0 __asm__("$0"); \
- register long _sc_16 __asm__("$16"); \
- register long _sc_19 __asm__("$19"); \
- \
- _sc_0 = __NR_##name; \
- _sc_16 = (long) (arg1); \
- __asm__("callsys # %0 %1 %2 %3" \
- : "=r"(_sc_0), "=r"(_sc_19) \
- : "0"(_sc_0), "r"(_sc_16) \
- : _syscall_clobbers); \
- _sc_ret = _sc_0, _sc_err = _sc_19; \
- } \
- _syscall_return(type); \
+#define inline_syscall1(name,arg1) \
+{ \
+ register long _sc_0 inline_syscall_r0_asm; \
+ register long _sc_16 __asm__("$16"); \
+ register long _sc_19 __asm__("$19"); \
+ register long _tmp_16 = (long) (arg1); \
+ \
+ _sc_0 = name; \
+ _sc_16 = _tmp_16; \
+ __asm__ __volatile__ \
+ ("callsys # %0 %1 <= %2 %3" \
+ : inline_syscall_r0_out_constraint (_sc_0), \
+ "=r"(_sc_19), "=r"(_sc_16) \
+ : "0"(_sc_0), "2"(_sc_16) \
+ : inline_syscall_clobbers, \
+ "$17", "$18", "$20", "$21"); \
+ _sc_ret = _sc_0, _sc_err = _sc_19; \
}
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name(type1 arg1,type2 arg2) \
-{ \
- long _sc_ret, _sc_err; \
- { \
- register long _sc_0 __asm__("$0"); \
- register long _sc_16 __asm__("$16"); \
- register long _sc_17 __asm__("$17"); \
- register long _sc_19 __asm__("$19"); \
- \
- _sc_0 = __NR_##name; \
- _sc_16 = (long) (arg1); \
- _sc_17 = (long) (arg2); \
- __asm__("callsys # %0 %1 %2 %3 %4" \
- : "=r"(_sc_0), "=r"(_sc_19) \
- : "0"(_sc_0), "r"(_sc_16), "r"(_sc_17) \
- : _syscall_clobbers); \
- _sc_ret = _sc_0, _sc_err = _sc_19; \
- } \
- _syscall_return(type); \
+#define inline_syscall2(name,arg1,arg2) \
+{ \
+ register long _sc_0 inline_syscall_r0_asm; \
+ register long _sc_16 __asm__("$16"); \
+ register long _sc_17 __asm__("$17"); \
+ register long _sc_19 __asm__("$19"); \
+ register long _tmp_16 = (long) (arg1); \
+ register long _tmp_17 = (long) (arg2); \
+ \
+ _sc_0 = name; \
+ _sc_16 = _tmp_16; \
+ _sc_17 = _tmp_17; \
+ __asm__ __volatile__ \
+ ("callsys # %0 %1 <= %2 %3 %4" \
+ : inline_syscall_r0_out_constraint (_sc_0), \
+ "=r"(_sc_19), "=r"(_sc_16), "=r"(_sc_17) \
+ : "0"(_sc_0), "2"(_sc_16), "3"(_sc_17) \
+ : inline_syscall_clobbers, \
+ "$18", "$20", "$21"); \
+ _sc_ret = _sc_0, _sc_err = _sc_19; \
}
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name(type1 arg1,type2 arg2,type3 arg3) \
-{ \
- long _sc_ret, _sc_err; \
- { \
- register long _sc_0 __asm__("$0"); \
- register long _sc_16 __asm__("$16"); \
- register long _sc_17 __asm__("$17"); \
- register long _sc_18 __asm__("$18"); \
- register long _sc_19 __asm__("$19"); \
- \
- _sc_0 = __NR_##name; \
- _sc_16 = (long) (arg1); \
- _sc_17 = (long) (arg2); \
- _sc_18 = (long) (arg3); \
- __asm__("callsys # %0 %1 %2 %3 %4 %5" \
- : "=r"(_sc_0), "=r"(_sc_19) \
- : "0"(_sc_0), "r"(_sc_16), "r"(_sc_17), \
- "r"(_sc_18) \
- : _syscall_clobbers); \
- _sc_ret = _sc_0, _sc_err = _sc_19; \
- } \
- _syscall_return(type); \
+#define inline_syscall3(name,arg1,arg2,arg3) \
+{ \
+ register long _sc_0 inline_syscall_r0_asm; \
+ register long _sc_16 __asm__("$16"); \
+ register long _sc_17 __asm__("$17"); \
+ register long _sc_18 __asm__("$18"); \
+ register long _sc_19 __asm__("$19"); \
+ register long _tmp_16 = (long) (arg1); \
+ register long _tmp_17 = (long) (arg2); \
+ register long _tmp_18 = (long) (arg3); \
+ \
+ _sc_0 = name; \
+ _sc_16 = _tmp_16; \
+ _sc_17 = _tmp_17; \
+ _sc_18 = _tmp_18; \
+ __asm__ __volatile__ \
+ ("callsys # %0 %1 <= %2 %3 %4 %5" \
+ : inline_syscall_r0_out_constraint (_sc_0), \
+ "=r"(_sc_19), "=r"(_sc_16), "=r"(_sc_17), \
+ "=r"(_sc_18) \
+ : "0"(_sc_0), "2"(_sc_16), "3"(_sc_17), \
+ "4"(_sc_18) \
+ : inline_syscall_clobbers, "$20", "$21"); \
+ _sc_ret = _sc_0, _sc_err = _sc_19; \
}
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
-{ \
- long _sc_ret, _sc_err; \
- { \
- register long _sc_0 __asm__("$0"); \
- register long _sc_16 __asm__("$16"); \
- register long _sc_17 __asm__("$17"); \
- register long _sc_18 __asm__("$18"); \
- register long _sc_19 __asm__("$19"); \
- \
- _sc_0 = __NR_##name; \
- _sc_16 = (long) (arg1); \
- _sc_17 = (long) (arg2); \
- _sc_18 = (long) (arg3); \
- _sc_19 = (long) (arg4); \
- __asm__("callsys # %0 %1 %2 %3 %4 %5 %6" \
- : "=r"(_sc_0), "=r"(_sc_19) \
- : "0"(_sc_0), "r"(_sc_16), "r"(_sc_17), \
- "r"(_sc_18), "1"(_sc_19) \
- : _syscall_clobbers); \
- _sc_ret = _sc_0, _sc_err = _sc_19; \
- } \
- _syscall_return(type); \
+#define inline_syscall4(name,arg1,arg2,arg3,arg4) \
+{ \
+ register long _sc_0 inline_syscall_r0_asm; \
+ register long _sc_16 __asm__("$16"); \
+ register long _sc_17 __asm__("$17"); \
+ register long _sc_18 __asm__("$18"); \
+ register long _sc_19 __asm__("$19"); \
+ register long _tmp_16 = (long) (arg1); \
+ register long _tmp_17 = (long) (arg2); \
+ register long _tmp_18 = (long) (arg3); \
+ register long _tmp_19 = (long) (arg4); \
+ \
+ _sc_0 = name; \
+ _sc_16 = _tmp_16; \
+ _sc_17 = _tmp_17; \
+ _sc_18 = _tmp_18; \
+ _sc_19 = _tmp_19; \
+ __asm__ __volatile__ \
+ ("callsys # %0 %1 <= %2 %3 %4 %5 %6" \
+ : inline_syscall_r0_out_constraint (_sc_0), \
+ "=r"(_sc_19), "=r"(_sc_16), "=r"(_sc_17), \
+ "=r"(_sc_18) \
+ : "0"(_sc_0), "2"(_sc_16), "3"(_sc_17), \
+ "4"(_sc_18), "1"(_sc_19) \
+ : inline_syscall_clobbers, "$20", "$21"); \
+ _sc_ret = _sc_0, _sc_err = _sc_19; \
}
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
- type5,arg5) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
-{ \
- long _sc_ret, _sc_err; \
- { \
- register long _sc_0 __asm__("$0"); \
- register long _sc_16 __asm__("$16"); \
- register long _sc_17 __asm__("$17"); \
- register long _sc_18 __asm__("$18"); \
- register long _sc_19 __asm__("$19"); \
- register long _sc_20 __asm__("$20"); \
- \
- _sc_0 = __NR_##name; \
- _sc_16 = (long) (arg1); \
- _sc_17 = (long) (arg2); \
- _sc_18 = (long) (arg3); \
- _sc_19 = (long) (arg4); \
- _sc_20 = (long) (arg5); \
- __asm__("callsys # %0 %1 %2 %3 %4 %5 %6 %7" \
- : "=r"(_sc_0), "=r"(_sc_19) \
- : "0"(_sc_0), "r"(_sc_16), "r"(_sc_17), \
- "r"(_sc_18), "1"(_sc_19), "r"(_sc_20) \
- : _syscall_clobbers); \
- _sc_ret = _sc_0, _sc_err = _sc_19; \
- } \
- _syscall_return(type); \
+#define inline_syscall5(name,arg1,arg2,arg3,arg4,arg5) \
+{ \
+ register long _sc_0 inline_syscall_r0_asm; \
+ register long _sc_16 __asm__("$16"); \
+ register long _sc_17 __asm__("$17"); \
+ register long _sc_18 __asm__("$18"); \
+ register long _sc_19 __asm__("$19"); \
+ register long _sc_20 __asm__("$20"); \
+ register long _tmp_16 = (long) (arg1); \
+ register long _tmp_17 = (long) (arg2); \
+ register long _tmp_18 = (long) (arg3); \
+ register long _tmp_19 = (long) (arg4); \
+ register long _tmp_20 = (long) (arg5); \
+ \
+ _sc_0 = name; \
+ _sc_16 = _tmp_16; \
+ _sc_17 = _tmp_17; \
+ _sc_18 = _tmp_18; \
+ _sc_19 = _tmp_19; \
+ _sc_20 = _tmp_20; \
+ __asm__ __volatile__ \
+ ("callsys # %0 %1 <= %2 %3 %4 %5 %6 %7" \
+ : inline_syscall_r0_out_constraint (_sc_0), \
+ "=r"(_sc_19), "=r"(_sc_16), "=r"(_sc_17), \
+ "=r"(_sc_18), "=r"(_sc_20) \
+ : "0"(_sc_0), "2"(_sc_16), "3"(_sc_17), \
+ "4"(_sc_18), "1"(_sc_19), "5"(_sc_20) \
+ : inline_syscall_clobbers, "$21"); \
+ _sc_ret = _sc_0, _sc_err = _sc_19; \
}
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
- type5,arg5,type6,arg6) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, type6 arg6)\
-{ \
- long _sc_ret, _sc_err; \
- { \
- register long _sc_0 __asm__("$0"); \
- register long _sc_16 __asm__("$16"); \
- register long _sc_17 __asm__("$17"); \
- register long _sc_18 __asm__("$18"); \
- register long _sc_19 __asm__("$19"); \
- register long _sc_20 __asm__("$20"); \
- register long _sc_21 __asm__("$21"); \
- \
- _sc_0 = __NR_##name; \
- _sc_16 = (long) (arg1); \
- _sc_17 = (long) (arg2); \
- _sc_18 = (long) (arg3); \
- _sc_19 = (long) (arg4); \
- _sc_20 = (long) (arg5); \
- _sc_21 = (long) (arg6); \
- __asm__("callsys # %0 %1 %2 %3 %4 %5 %6 %7 %8" \
- : "=r"(_sc_0), "=r"(_sc_19) \
- : "0"(_sc_0), "r"(_sc_16), "r"(_sc_17), \
- "r"(_sc_18), "1"(_sc_19), "r"(_sc_20), "r"(_sc_21) \
- : _syscall_clobbers); \
- _sc_ret = _sc_0, _sc_err = _sc_19; \
- } \
- _syscall_return(type); \
+#define inline_syscall6(name,arg1,arg2,arg3,arg4,arg5,arg6) \
+{ \
+ register long _sc_0 inline_syscall_r0_asm; \
+ register long _sc_16 __asm__("$16"); \
+ register long _sc_17 __asm__("$17"); \
+ register long _sc_18 __asm__("$18"); \
+ register long _sc_19 __asm__("$19"); \
+ register long _sc_20 __asm__("$20"); \
+ register long _sc_21 __asm__("$21"); \
+ register long _tmp_16 = (long) (arg1); \
+ register long _tmp_17 = (long) (arg2); \
+ register long _tmp_18 = (long) (arg3); \
+ register long _tmp_19 = (long) (arg4); \
+ register long _tmp_20 = (long) (arg5); \
+ register long _tmp_21 = (long) (arg6); \
+ \
+ _sc_0 = name; \
+ _sc_16 = _tmp_16; \
+ _sc_17 = _tmp_17; \
+ _sc_18 = _tmp_18; \
+ _sc_19 = _tmp_19; \
+ _sc_20 = _tmp_20; \
+ _sc_21 = _tmp_21; \
+ __asm__ __volatile__ \
+ ("callsys # %0 %1 <= %2 %3 %4 %5 %6 %7 %8" \
+ : inline_syscall_r0_out_constraint (_sc_0), \
+ "=r"(_sc_19), "=r"(_sc_16), "=r"(_sc_17), \
+ "=r"(_sc_18), "=r"(_sc_20), "=r"(_sc_21) \
+ : "0"(_sc_0), "2"(_sc_16), "3"(_sc_17), "4"(_sc_18), \
+ "1"(_sc_19), "5"(_sc_20), "6"(_sc_21) \
+ : inline_syscall_clobbers); \
+ _sc_ret = _sc_0, _sc_err = _sc_19; \
}
#endif /* __ASSEMBLER__ */
diff --git a/libc/sysdeps/linux/alpha/bits/termios.h b/libc/sysdeps/linux/alpha/bits/termios.h
index 966ccf94d..bc8ea7b66 100644
--- a/libc/sysdeps/linux/alpha/bits/termios.h
+++ b/libc/sysdeps/linux/alpha/bits/termios.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _TERMIOS_H
# error "Never include <bits/termios.h> directly; use <termios.h> instead."
diff --git a/libc/sysdeps/linux/alpha/bits/timerfd.h b/libc/sysdeps/linux/alpha/bits/timerfd.h
new file mode 100644
index 000000000..f04833d3f
--- /dev/null
+++ b/libc/sysdeps/linux/alpha/bits/timerfd.h
@@ -0,0 +1,29 @@
+/* Copyright (C) 2008-2012 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_TIMERFD_H
+# error "Never use <bits/timerfd.h> directly; include <sys/timerfd.h> instead."
+#endif
+
+/* Bits to be set in the FLAGS parameter of `timerfd_create'. */
+enum
+ {
+ TFD_CLOEXEC = 010000000,
+#define TFD_CLOEXEC TFD_CLOEXEC
+ TFD_NONBLOCK = 000000004
+#define TFD_NONBLOCK TFD_NONBLOCK
+ };
diff --git a/libc/sysdeps/linux/alpha/bits/typesizes.h b/libc/sysdeps/linux/alpha/bits/typesizes.h
index 201585af1..42ee50e50 100644
--- a/libc/sysdeps/linux/alpha/bits/typesizes.h
+++ b/libc/sysdeps/linux/alpha/bits/typesizes.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _BITS_TYPES_H
# error "Never include <bits/typesizes.h> directly; use <sys/types.h> instead."
diff --git a/libc/sysdeps/linux/alpha/bits/uClibc_arch_features.h b/libc/sysdeps/linux/alpha/bits/uClibc_arch_features.h
index e62375caa..18c18f92d 100644
--- a/libc/sysdeps/linux/alpha/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/alpha/bits/uClibc_arch_features.h
@@ -11,28 +11,31 @@
/* 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 align 64bit values in register pairs ? (32bit arches only) */
+#undef __UCLIBC_SYSCALL_ALIGN_64BIT__
/* does your target have a broken create_module() ? */
#define __UCLIBC_SLIGHTLY_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 ? */
#undef __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 */
+#undef __UCLIBC_ASM_LINE_SEP__
+
#endif /* _BITS_UCLIBC_ARCH_FEATURES_H */
diff --git a/libc/sysdeps/linux/alpha/bits/uClibc_page.h b/libc/sysdeps/linux/alpha/bits/uClibc_page.h
index 8219a19da..3f0d5d0f4 100644
--- a/libc/sysdeps/linux/alpha/bits/uClibc_page.h
+++ b/libc/sysdeps/linux/alpha/bits/uClibc_page.h
@@ -11,8 +11,8 @@
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * License along with this library; if not, see
+ * <http://www.gnu.org/licenses/>.
*/
/* Supply an architecture specific value for PAGE_SIZE and friends. */
diff --git a/libc/sysdeps/linux/alpha/bits/wordsize.h b/libc/sysdeps/linux/alpha/bits/wordsize.h
index 22fc64109..e6d32fd20 100644
--- a/libc/sysdeps/linux/alpha/bits/wordsize.h
+++ b/libc/sysdeps/linux/alpha/bits/wordsize.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#define __WORDSIZE 64
diff --git a/libc/sysdeps/linux/alpha/brk.S b/libc/sysdeps/linux/alpha/brk.S
index 42c7368b4..e7eba16bc 100644
--- a/libc/sysdeps/linux/alpha/brk.S
+++ b/libc/sysdeps/linux/alpha/brk.S
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* __brk is a special syscall under Linux since it never returns an
error. Instead, the error condition is indicated by returning the old
diff --git a/libc/sysdeps/linux/alpha/clone.S b/libc/sysdeps/linux/alpha/clone.S
index 79d4511fb..712b09288 100644
--- a/libc/sysdeps/linux/alpha/clone.S
+++ b/libc/sysdeps/linux/alpha/clone.S
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* clone() is even more special than fork() as it mucks with stacks
and invokes a function in the right context after its all over. */
diff --git a/libc/sysdeps/linux/alpha/crt1.S b/libc/sysdeps/linux/alpha/crt1.S
index 0bf71248c..ce9095a82 100644
--- a/libc/sysdeps/linux/alpha/crt1.S
+++ b/libc/sysdeps/linux/alpha/crt1.S
@@ -32,9 +32,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <features.h>
#include <sys/regdef.h>
diff --git a/libc/sysdeps/linux/alpha/crtn.S b/libc/sysdeps/linux/alpha/crtn.S
index c6fec15ba..bf847ab00 100644
--- a/libc/sysdeps/linux/alpha/crtn.S
+++ b/libc/sysdeps/linux/alpha/crtn.S
@@ -1,30 +1,13 @@
- .set noat
- .set noreorder
- .set nomacro
- .set macro
-
.section .init
- .set nomacro
.align 2
.globl _init
- .ent _init
- .set nomacro
ldq $26,0($30)
lda $30,16($30)
ret $31,($26),1
- .end _init
- .set macro
-
+
.section .fini
- .set nomacro
.align 2
.globl _fini
- .ent _fini
- .set nomacro
ldq $26,0($30)
lda $30,16($30)
ret $31,($26),1
- .end _fini
- .set macro
-
- .ident "GCC: (GNU) 3.3.2"
diff --git a/libc/sysdeps/linux/alpha/divrem.h b/libc/sysdeps/linux/alpha/divrem.h
index bd4e2d1be..27475f029 100644
--- a/libc/sysdeps/linux/alpha/divrem.h
+++ b/libc/sysdeps/linux/alpha/divrem.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* The current Alpha chips don't provide hardware for integer
division. The C compiler expects the functions
diff --git a/libc/sysdeps/linux/alpha/fpu_control.h b/libc/sysdeps/linux/alpha/fpu_control.h
index cdffcfb9d..653953893 100644
--- a/libc/sysdeps/linux/alpha/fpu_control.h
+++ b/libc/sysdeps/linux/alpha/fpu_control.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _ALPHA_FPU_CONTROL_H
#define _ALPHA_FPU_CONTROL_H
diff --git a/libc/sysdeps/linux/alpha/jmpbuf-offsets.h b/libc/sysdeps/linux/alpha/jmpbuf-offsets.h
new file mode 100644
index 000000000..df018ad93
--- /dev/null
+++ b/libc/sysdeps/linux/alpha/jmpbuf-offsets.h
@@ -0,0 +1,35 @@
+/* Private macros for accessing __jmp_buf contents. Alpha version.
+ Copyright (C) 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#define JB_S0 0
+#define JB_S1 1
+#define JB_S2 2
+#define JB_S3 3
+#define JB_S4 4
+#define JB_S5 5
+#define JB_PC 6
+#define JB_FP 7
+#define JB_SP 8
+#define JB_F2 9
+#define JB_F3 10
+#define JB_F4 11
+#define JB_F5 12
+#define JB_F6 13
+#define JB_F7 14
+#define JB_F8 15
+#define JB_F9 16
diff --git a/libc/sysdeps/linux/alpha/jmpbuf-unwind.h b/libc/sysdeps/linux/alpha/jmpbuf-unwind.h
new file mode 100644
index 000000000..80fe8b37d
--- /dev/null
+++ b/libc/sysdeps/linux/alpha/jmpbuf-unwind.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+#include <setjmp.h>
+#include <jmpbuf-offsets.h>
+
+/* Test if longjmp to JMPBUF would unwind the frame containing a local
+ variable at ADDRESS. */
+#define _JMPBUF_UNWINDS(_jmpbuf, _address) \
+ ((void *)(_address) < (void *)((_jmpbuf)[JB_SP]))
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <stdint.h>
+#include <unwind.h>
+
+#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
+ _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
+
+#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
+ ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[JB_SP] - (_adj))
+#endif
diff --git a/libc/sysdeps/linux/alpha/pipe.S b/libc/sysdeps/linux/alpha/pipe.S
index 8a9236bc5..1c9364833 100644
--- a/libc/sysdeps/linux/alpha/pipe.S
+++ b/libc/sysdeps/linux/alpha/pipe.S
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <features.h>
#include <sys/syscall.h>
diff --git a/libc/sysdeps/linux/alpha/setjmp.S b/libc/sysdeps/linux/alpha/setjmp.S
index 105cc8292..b870813a2 100644
--- a/libc/sysdeps/linux/alpha/setjmp.S
+++ b/libc/sysdeps/linux/alpha/setjmp.S
@@ -12,15 +12,10 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
-#include <features.h>
-#define _ASM
-#define _SETJMP_H
-#define __ASSEMBLY__
-#include <bits/setjmp.h>
+#include <jmpbuf-offsets.h>
#define a0 $16
@@ -30,10 +25,16 @@ __sigsetjmp:
ldgp $29, 0($27)
$sigsetjmp_local:
- subq $30, 16, $30
- .frame $26, 16, $26, 0
- stq $26, 0($30)
- .mask 0x04000000, -16
+#ifndef __PIC__
+# define FRAME 16
+ subq $30, FRAME, $30
+ .frame $30, FRAME, $26, 0
+ stq $26, 0($30)
+ .mask 0x04000000, -FRAME
+#else
+# define FRAME 0
+ .frame $30, FRAME, $26, 0
+#endif
.prologue 1
stq $9, JB_S0*8(a0)
@@ -43,9 +44,9 @@ $sigsetjmp_local:
stq $13, JB_S4*8(a0)
stq $14, JB_S5*8(a0)
stq $26, JB_PC*8(a0)
- addq $30, 16, $1
- stq $15, JB_FP*8(a0)
+ addq $30, FRAME, $1
stq $1, JB_SP*8(a0)
+ stq $15, JB_FP*8(a0)
stt $f2, JB_F2*8(a0)
stt $f3, JB_F3*8(a0)
stt $f4, JB_F4*8(a0)
@@ -55,12 +56,16 @@ $sigsetjmp_local:
stt $f8, JB_F8*8(a0)
stt $f9, JB_F9*8(a0)
+#ifndef __PIC__
/* Call to C to (potentially) save our signal mask. */
jsr $26, __sigjmp_save
-
ldq $26, 0($30)
addq $30, 16, $30
ret
+#else
+ /* Tailcall to save the signal mask. */
+ br $31, __sigjmp_save !samegp
+#endif
.end __sigsetjmp
@@ -71,7 +76,6 @@ $sigsetjmp_local:
.align 3;
.ent _setjmp , 0;
_setjmp:
- .frame $30 , 0, $26
ldgp $29, 0($27)
mov 0, $17
br $sigsetjmp_local
@@ -81,11 +85,7 @@ _setjmp:
.align 3;
.ent setjmp , 0;
setjmp:
- .frame $30 , 0, $26
ldgp $29, 0($27)
mov 1, $17
br $sigsetjmp_local
.end setjmp
-
-.weak _setjmp
-.weak setjmp
diff --git a/libc/sysdeps/linux/alpha/sigprocmask.c b/libc/sysdeps/linux/alpha/sigprocmask.c
index e9ebe091f..4b78c6054 100644
--- a/libc/sysdeps/linux/alpha/sigprocmask.c
+++ b/libc/sysdeps/linux/alpha/sigprocmask.c
@@ -13,21 +13,20 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <features.h>
#include <errno.h>
#include <sys/syscall.h>
#include <signal.h>
+#include <string.h>
/* When there is kernel support for more than 64 signals, we'll have to
switch to a new system call convention here. */
-static __inline__ _syscall2(int, osf_sigprocmask, int, how, unsigned long int, setval);
+static __inline__ _syscall2(int, osf_sigprocmask, int, how, unsigned long int, setval)
-libc_hidden_proto(sigprocmask)
int
sigprocmask (int how, const sigset_t *set, sigset_t *oset)
{
@@ -44,17 +43,18 @@ sigprocmask (int how, const sigset_t *set, sigset_t *oset)
result = osf_sigprocmask(how, setval);
if (result == -1)
- /* If there are ever more than 63 signals, we need to recode this
+ /* If there are ever more than 64 signals, we need to recode this
in assembler since we wouldn't be able to distinguish a mask of
all 1s from -1, but for now, we're doing just fine... */
return result;
if (oset)
{
+ if (_SIGSET_NWORDS == 2) /* typical */
+ oset->__val[1] = 0;
+ if (_SIGSET_NWORDS > 2)
+ memset(oset, 0, sizeof(*oset));
oset->__val[0] = result;
- result = _SIGSET_NWORDS;
- while (--result > 0)
- oset->__val[result] = 0;
}
return 0;
}
diff --git a/libc/sysdeps/linux/alpha/sys/acct.h b/libc/sysdeps/linux/alpha/sys/acct.h
index 1e00006ef..9b5201cb3 100644
--- a/libc/sysdeps/linux/alpha/sys/acct.h
+++ b/libc/sysdeps/linux/alpha/sys/acct.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_ACCT_H
@@ -59,7 +58,7 @@ enum
/* Switch process accounting on and off. */
-extern int acct (__const char *__filename) __THROW;
+extern int acct (const char *__filename) __THROW;
__END_DECLS
diff --git a/libc/sysdeps/linux/alpha/sys/io.h b/libc/sysdeps/linux/alpha/sys/io.h
index 4334c6392..3e8fdcc4a 100644
--- a/libc/sysdeps/linux/alpha/sys/io.h
+++ b/libc/sysdeps/linux/alpha/sys/io.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_IO_H
@@ -23,6 +22,7 @@
__BEGIN_DECLS
+#if defined __UCLIBC_LINUX_SPECIFIC__
/* If TURN_ON is TRUE, request for permission to do direct i/o on the
port numbers in the range [FROM,FROM+NUM-1]. Otherwise, turn I/O
permission off for that range. This call requires root privileges.
@@ -37,6 +37,7 @@ extern int ioperm (unsigned long int __from, unsigned long int __num,
access any I/O port is granted. This call requires root
privileges. */
extern int iopl (int __level) __THROW;
+#endif /* __UCLIBC_LINUX_SPECIFIC__ */
/* Return the physical address of the DENSE I/O memory or NULL if none
is available (e.g. on a jensen). */
diff --git a/libc/sysdeps/linux/alpha/sys/procfs.h b/libc/sysdeps/linux/alpha/sys/procfs.h
index bee51f94e..ed54e0e5c 100644
--- a/libc/sysdeps/linux/alpha/sys/procfs.h
+++ b/libc/sysdeps/linux/alpha/sys/procfs.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_PROCFS_H
#define _SYS_PROCFS_H 1
@@ -29,10 +28,23 @@
#include <sys/types.h>
#include <sys/ucontext.h>
#include <sys/user.h>
-#include <asm/elf.h>
__BEGIN_DECLS
+/*
+ * The OSF/1 version of <sys/procfs.h> makes gregset_t 46 entries long.
+ * I have no idea why that is so. For now, we just leave it at 33
+ * (32 general regs + processor status word).
+ */
+#define ELF_NGREG 33
+#define ELF_NFPREG 32
+
+typedef unsigned long elf_greg_t;
+typedef elf_greg_t elf_gregset_t[ELF_NGREG];
+
+typedef double elf_fpreg_t;
+typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
+
struct elf_siginfo
{
int si_signo; /* Signal number. */
diff --git a/libc/sysdeps/linux/alpha/sys/ucontext.h b/libc/sysdeps/linux/alpha/sys/ucontext.h
index 438293c62..0b93376fb 100644
--- a/libc/sysdeps/linux/alpha/sys/ucontext.h
+++ b/libc/sysdeps/linux/alpha/sys/ucontext.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_UCONTEXT_H
#define _SYS_UCONTEXT_H 1
diff --git a/libc/sysdeps/linux/alpha/sys/user.h b/libc/sysdeps/linux/alpha/sys/user.h
index f9beea082..bc3e245e7 100644
--- a/libc/sysdeps/linux/alpha/sys/user.h
+++ b/libc/sysdeps/linux/alpha/sys/user.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_USER_H
#define _SYS_USER_H 1
diff --git a/libc/sysdeps/linux/alpha/syscall.S b/libc/sysdeps/linux/alpha/syscall.S
index 89901d547..16e1ae63e 100644
--- a/libc/sysdeps/linux/alpha/syscall.S
+++ b/libc/sysdeps/linux/alpha/syscall.S
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <features.h>
#include <sys/regdef.h>
diff --git a/libc/sysdeps/linux/arc/Makefile b/libc/sysdeps/linux/arc/Makefile
new file mode 100644
index 000000000..94b43e117
--- /dev/null
+++ b/libc/sysdeps/linux/arc/Makefile
@@ -0,0 +1,13 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+#
+# Licensed under the LGPL v2.1 or later, 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/arc/Makefile.arch b/libc/sysdeps/linux/arc/Makefile.arch
new file mode 100644
index 000000000..1a52fc9bf
--- /dev/null
+++ b/libc/sysdeps/linux/arc/Makefile.arch
@@ -0,0 +1,10 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+#
+# Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+#
+
+CSRC-y := syscall.c sigaction.c __syscall_error.c cacheflush.c
+
+SSRC-y := __longjmp.S setjmp.S bsd-setjmp.S bsd-_setjmp.S vfork.S clone.S
diff --git a/libc/sysdeps/linux/arc/__longjmp.S b/libc/sysdeps/linux/arc/__longjmp.S
new file mode 100644
index 000000000..91d1852af
--- /dev/null
+++ b/libc/sysdeps/linux/arc/__longjmp.S
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sysdep.h>
+
+;@ r0 = jump buffer from which regs will be restored
+;@ r1 = value that setjmp( ) will return due to this longjmp
+
+ENTRY(__longjmp)
+
+ ld_s r13, [r0]
+ ld_s r14, [r0,4]
+ ld r15, [r0,8]
+ ld r16, [r0,12]
+ ld r17, [r0,16]
+ ld r18, [r0,20]
+ ld r19, [r0,24]
+ ld r20, [r0,28]
+ ld r21, [r0,32]
+ ld r22, [r0,36]
+ ld r23, [r0,40]
+ ld r24, [r0,44]
+ ld r25, [r0,48]
+
+ ld blink, [r0,60] ; load it early enough to not stall the pipeline
+ ld fp, [r0,52]
+ ld sp, [r0,56]
+
+ mov.f r0, r1 ; get the setjmp return value(due to longjmp) in place
+
+ j.d [blink] ; to caller of setjmp location, right after the call
+ mov.z r0, 1 ; can't let setjmp return 0 when it is due to longjmp
+
+END(__longjmp)
+libc_hidden_def(__longjmp)
diff --git a/libc/sysdeps/linux/arc/__syscall_error.c b/libc/sysdeps/linux/arc/__syscall_error.c
new file mode 100644
index 000000000..962d743e4
--- /dev/null
+++ b/libc/sysdeps/linux/arc/__syscall_error.c
@@ -0,0 +1,15 @@
+/* Wrapper for setting errno.
+ *
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <errno.h>
+#include <sys/syscall.h>
+
+int __syscall_error(int err_no)
+{
+ __set_errno(-err_no);
+ return -1;
+}
diff --git a/libc/sysdeps/linux/arc/bits/atomic.h b/libc/sysdeps/linux/arc/bits/atomic.h
new file mode 100644
index 000000000..1fdc83f70
--- /dev/null
+++ b/libc/sysdeps/linux/arc/bits/atomic.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <stdint.h>
+#include <sysdep.h>
+
+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;
+
+void __arc_link_error (void);
+
+#ifdef __A7__
+#define atomic_full_barrier() __asm__ __volatile__("": : :"memory")
+#else
+#define atomic_full_barrier() __asm__ __volatile__("dmb 3": : :"memory")
+#endif
+
+/* Atomic compare and exchange. */
+
+#define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
+ ({ __arc_link_error (); oldval; })
+
+#define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \
+ ({ __arc_link_error (); oldval; })
+
+#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
+ ({ \
+ __typeof(oldval) prev; \
+ \
+ __asm__ __volatile__( \
+ "1: llock %0, [%1] \n" \
+ " brne %0, %2, 2f \n" \
+ " scond %3, [%1] \n" \
+ " bnz 1b \n" \
+ "2: \n" \
+ : "=&r"(prev) \
+ : "r"(mem), "ir"(oldval), \
+ "r"(newval) /* can't be "ir". scond can't take limm for "b" */\
+ : "cc", "memory"); \
+ \
+ prev; \
+ })
+
+#define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
+ ({ __arc_link_error (); oldval; })
diff --git a/libc/sysdeps/linux/arc/bits/byteswap.h b/libc/sysdeps/linux/arc/bits/byteswap.h
new file mode 100644
index 000000000..75fa3590d
--- /dev/null
+++ b/libc/sysdeps/linux/arc/bits/byteswap.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ *
+ */
+
+#ifndef _ASM_BITS_BYTESWAP_H
+#define _ASM_BITS_BYTESWAP_H 1
+
+#ifdef __Xswape /* gcc defined if -mswape is enabled */
+
+#define __bswap_non_constant_32(x) \
+ __extension__ \
+ ({ unsigned int __bswap_32_v = x; \
+ __asm__ ("swape %0, %0" : "+r" (__bswap_32_v)); \
+ __bswap_32_v; })
+
+#endif /* __Xswape */
+
+#endif /* _ASM_BITS_BYTESWAP_H */
+
+#include <bits/byteswap-common.h>
diff --git a/libc/sysdeps/linux/arc/bits/endian.h b/libc/sysdeps/linux/arc/bits/endian.h
new file mode 100755
index 000000000..41163c8ca
--- /dev/null
+++ b/libc/sysdeps/linux/arc/bits/endian.h
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+#ifndef _ENDIAN_H
+# error "Never use <bits/endian.h> directly; include <endian.h> instead."
+#endif
+
+/* ARC support either endianness. */
+#ifdef __BIG_ENDIAN__
+#define __BYTE_ORDER __BIG_ENDIAN
+#else
+#define __BYTE_ORDER __LITTLE_ENDIAN
+#endif
diff --git a/libc/sysdeps/linux/nios/bits/fcntl.h b/libc/sysdeps/linux/arc/bits/fcntl.h
index 9fc29cd8b..d7d626b78 100644..100755
--- a/libc/sysdeps/linux/nios/bits/fcntl.h
+++ b/libc/sysdeps/linux/arc/bits/fcntl.h
@@ -1,22 +1,9 @@
/* O_*, F_*, FD_* bit values for Linux.
- Copyright (C) 1995, 1996, 1997, 1998 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. */
-
+ *
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
#ifndef _FCNTL_H
# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
#endif
@@ -45,10 +32,16 @@
#define O_ASYNC 020000
#ifdef __USE_GNU
-# define O_DIRECTORY 040000 /* Must be a directory. */
-# define O_NOFOLLOW 0100000 /* Do not follow links. */
-# define O_DIRECT 0200000 /* Direct disk access. */
-# define O_STREAMING 04000000/* streaming access */
+# define O_DIRECT 040000 /* Direct disk access. */
+# define O_DIRECTORY 0200000 /* Must be a directory. */
+# define O_NOFOLLOW 0400000 /* Do not follow links. */
+# define O_NOATIME 01000000 /* Do not set atime. */
+# define O_CLOEXEC 02000000 /* Set close_on_exec. */
+# define O_PATH 010000000 /* Resolve pathname but do not open file. */
+#endif
+
+#ifdef __USE_LARGEFILE64
+# define O_LARGEFILE 0100000
#endif
/* For now Linux has synchronisity options for data and read operations.
@@ -59,16 +52,13 @@
# define O_RSYNC O_SYNC /* Synchronize read operations. */
#endif
-#ifdef __USE_LARGEFILE64
-# define O_LARGEFILE 0400000
-#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). */
@@ -98,6 +88,8 @@
# define F_NOTIFY 1026 /* Request notfications on a directory. */
# define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with
close-on-exit set on new fd. */
+# define F_SETPIPE_SZ 1031 /* Set pipe page size array. */
+# define F_GETPIPE_SZ 1032 /* Get pipe page size array. */
#endif
/* For F_[GET|SET]FL. */
@@ -108,12 +100,12 @@
#define F_WRLCK 1 /* Write lock. */
#define F_UNLCK 2 /* Remove lock. */
-/* for old implementation of bsd flock () */
+/* 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 */
+/* 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
@@ -141,7 +133,7 @@
struct flock
{
- short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
+ 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. */
@@ -156,7 +148,7 @@ struct flock
#ifdef __USE_LARGEFILE64
struct flock64
{
- short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
+ 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. */
@@ -184,8 +176,7 @@ struct flock64
# define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */
#endif
-
-#ifdef __USE_GNU
+#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
@@ -208,13 +199,12 @@ struct flock64
__BEGIN_DECLS
-#ifdef __USE_GNU
+#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);
@@ -234,4 +224,3 @@ extern ssize_t tee (int __fdin, int __fdout, size_t __len,
#endif
__END_DECLS
-
diff --git a/libc/sysdeps/linux/arc/bits/kernel_types.h b/libc/sysdeps/linux/arc/bits/kernel_types.h
new file mode 100755
index 000000000..45aff7d1d
--- /dev/null
+++ b/libc/sysdeps/linux/arc/bits/kernel_types.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+/* 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
+ *
+ * Update: ARC Linux 3.2 ABI change - asm-generic/posix_types.h used now.
+ * for which ARCH wrapper (asm/posix_types.h) is generated, so need to use
+ * the asm-generic file's gaurd.
+ *
+ * Based on asm-generic/stat.h
+ */
+
+#ifndef __ASM_GENERIC_POSIX_TYPES_H
+#define __ASM_GENERIC_POSIX_TYPES_H
+
+typedef unsigned long __kernel_dev_t;
+typedef unsigned long __kernel_ino_t;
+typedef unsigned int __kernel_mode_t;
+typedef unsigned int __kernel_nlink_t;
+typedef long __kernel_off_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 unsigned int __kernel_size_t;
+typedef int __kernel_ssize_t;
+typedef int __kernel_ptrdiff_t;
+typedef long __kernel_time_t;
+typedef long __kernel_suseconds_t;
+typedef long __kernel_clock_t;
+typedef int __kernel_daddr_t;
+typedef char * __kernel_caddr_t;
+typedef unsigned short __kernel_uid16_t;
+typedef unsigned short __kernel_gid16_t;
+typedef __kernel_uid_t __kernel_uid32_t;
+typedef __kernel_gid_t __kernel_gid32_t;
+typedef __kernel_uid_t __kernel_old_uid_t;
+typedef __kernel_gid_t __kernel_old_gid_t;
+typedef long long __kernel_loff_t;
+typedef unsigned int __kernel_old_dev_t;
+typedef long __kernel_long_t;
+typedef unsigned long __kernel_ulong_t;
+
+typedef struct {
+#ifdef __USE_ALL
+ int val[2];
+#else
+ int __val[2];
+#endif
+} __kernel_fsid_t;
+
+#endif /* _ASM_ARC_POSIX_TYPES_H */
diff --git a/libc/sysdeps/linux/arc/bits/setjmp.h b/libc/sysdeps/linux/arc/bits/setjmp.h
new file mode 100644
index 000000000..a8dbdd494
--- /dev/null
+++ b/libc/sysdeps/linux/arc/bits/setjmp.h
@@ -0,0 +1,16 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#ifndef _BITS_SETJMP_H
+#define _BITS_SETJMP_H 1
+
+#if !defined _SETJMP_H && !defined _PTHREAD_H
+# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
+#endif
+
+typedef int __jmp_buf[13+1+1+1]; /*r13-r25, fp, sp, blink */
+
+#endif
diff --git a/libc/sysdeps/linux/arc/bits/sigcontextinfo.h b/libc/sysdeps/linux/arc/bits/sigcontextinfo.h
new file mode 100755
index 000000000..ac5cfa966
--- /dev/null
+++ b/libc/sysdeps/linux/arc/bits/sigcontextinfo.h
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <features.h>
+#define SIGCONTEXT struct sigcontext *
+#define SIGCONTEXT_EXTRA_ARGS
+
+#define GET_PC(ctx) ((void *) ctx->regs.scratch.ret)
+#define GET_FRAME(ctx) ((void *) ctx->regs.scratch.fp)
+#define GET_STACK(ctx) ((void *) ctx->regs.scratch.sp)
+#define CALL_SIGHANDLER(handler, signo, ctx) \
+ (handler)((signo), SIGCONTEXT_EXTRA_ARGS (ctx))
diff --git a/libc/sysdeps/linux/arc/bits/stackinfo.h b/libc/sysdeps/linux/arc/bits/stackinfo.h
new file mode 100755
index 000000000..9d68226b8
--- /dev/null
+++ b/libc/sysdeps/linux/arc/bits/stackinfo.h
@@ -0,0 +1,13 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#ifndef _STACKINFO_H
+#define _STACKINFO_H 1
+
+/* On ARC, the stack grows down. */
+#define _STACK_GROWS_DOWN 1
+
+#endif /* stackinfo.h */
diff --git a/libc/sysdeps/linux/arc/bits/syscalls.h b/libc/sysdeps/linux/arc/bits/syscalls.h
new file mode 100644
index 000000000..248ef7844
--- /dev/null
+++ b/libc/sysdeps/linux/arc/bits/syscalls.h
@@ -0,0 +1,191 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ *
+ */
+#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>
+
+/*
+ * Fine tuned code for errno handling in syscall wrappers.
+ *
+ * 1. __syscall_error(raw_syscall_ret_val) is used to set the errno (vs.
+ * the typical __set_errno). This helps elide the generated code for
+ * GOT fetch for __errno_location pointer etc, in each wrapper.
+ *
+ * 2. The call to above is also disguised in inline asm. This elides
+ * unconditional save/restore of a few callee regs which gcc almost
+ * always generates if the call is exposed
+ *
+ * 3. The function can't be hidden because wrappers from librt et all also
+ * call it. However hidden is not really needed to bypass PLT for
+ * intra-libc calls as the branch insn w/o @plt is sufficient.
+ */
+
+#ifdef IS_IN_rtld
+/* ldso doesn't have real errno */
+#define ERRNO_ERRANDS(_sys_result)
+#else /* !IS_IN_rtld */
+extern int __syscall_error (int);
+#ifndef IS_IN_libc
+/* Inter-libc callers use PLT */
+#define CALL_ERRNO_SETTER "bl __syscall_error@plt \n\t"
+#else
+/* intra-libc callers, despite PIC can bypass PLT */
+#define CALL_ERRNO_SETTER "bl __syscall_error \n\t"
+#endif
+
+#define ERRNO_ERRANDS(_sys_result) \
+ __asm__ volatile ( \
+ "st.a blink, [sp, -4] \n\t" \
+ CALL_ERRNO_SETTER \
+ "ld.ab blink, [sp, 4] \n\t" \
+ :"+r" (_sys_result) \
+ : \
+ :"r1","r2","r3","r4","r5","r6", \
+ "r7","r8","r9","r10","r11","r12" \
+ );
+
+#endif /* IS_IN_rtld */
+
+/* -1 to -1023 as valid error values will suffice for some time */
+#define INTERNAL_SYSCALL_ERROR_P(val, err) \
+ ((unsigned int) (val) > (unsigned int) -1024)
+
+/*
+ * Standard sycall wrapper
+ * -Gets syscall name (conv to __NR_xxx)
+ * -sets errno, return success/error-codes
+ */
+#define INLINE_SYSCALL(name, nr_args, args...) \
+({ \
+ register int __res __asm__("r0"); \
+ __res = INTERNAL_SYSCALL_NCS(__NR_##name, , nr_args, args); \
+ if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P ((__res), ), 0)) \
+ { \
+ ERRNO_ERRANDS(__res); \
+ } \
+ __res; \
+})
+
+/* variant of INLINE_SYSCALL, gets syscall number
+ */
+#define INLINE_SYSCALL_NCS(num, nr_args, args...) \
+({ \
+ register int __res __asm__("r0"); \
+ __res = INTERNAL_SYSCALL_NCS(num, , nr_args, args); \
+ if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P ((__res), ), 0)) \
+ { \
+ ERRNO_ERRANDS(__res); \
+ } \
+ __res; \
+})
+
+/*-------------------------------------------------------------------------
+ * Mechanics of Trap - specific to ARC700
+ *
+ * Note the memory clobber is not strictly needed for intended semantics of
+ * the inline asm. However some of the cases, such as old-style 6 arg mmap
+ * gcc was generating code for inline syscall ahead of buffer packing needed
+ * for syscall itself.
+ *-------------------------------------------------------------------------*/
+
+#ifdef __A7__
+#define ARC_TRAP_INSN "trap0 \n\t"
+#elif defined(__HS__)
+#define ARC_TRAP_INSN "trap_s 0 \n\t"
+#endif
+
+#define INTERNAL_SYSCALL_NCS(nm, err, nr_args, args...) \
+({ \
+ /* Per ABI, r0 is 1st arg and return reg */ \
+ register int __ret __asm__("r0"); \
+ register int _sys_num __asm__("r8"); \
+ \
+ LOAD_ARGS_##nr_args (nm, args) \
+ \
+ __asm__ volatile ( \
+ ARC_TRAP_INSN \
+ : "+r" (__ret) \
+ : "r"(_sys_num) ASM_ARGS_##nr_args \
+ : "memory"); \
+ \
+ __ret; \
+})
+
+/* Macros for setting up inline __asm__ input regs */
+#define ASM_ARGS_0
+#define ASM_ARGS_1 ASM_ARGS_0, "r" (__ret)
+#define ASM_ARGS_2 ASM_ARGS_1, "r" (_arg2)
+#define ASM_ARGS_3 ASM_ARGS_2, "r" (_arg3)
+#define ASM_ARGS_4 ASM_ARGS_3, "r" (_arg4)
+#define ASM_ARGS_5 ASM_ARGS_4, "r" (_arg5)
+#define ASM_ARGS_6 ASM_ARGS_5, "r" (_arg6)
+#define ASM_ARGS_7 ASM_ARGS_6, "r" (_arg7)
+
+/* Macros for converting sys-call wrapper args into sys call args */
+#define LOAD_ARGS_0(nm, arg) \
+ _sys_num = (int) (nm); \
+
+#define LOAD_ARGS_1(nm, arg1) \
+ __ret = (int) (arg1); \
+ LOAD_ARGS_0 (nm, arg1)
+
+/*
+ * Note that the use of _tmpX might look superflous, however it is needed
+ * to ensure that register variables are not clobbered if arg happens to be
+ * a function call itself. e.g. sched_setaffinity() calling getpid() for arg2
+ *
+ * Also this specific order of recursive calling is important to segregate
+ * the tmp args evaluation (function call case described above) and assigment
+ * of register variables
+ */
+#define LOAD_ARGS_2(nm, arg1, arg2) \
+ int _tmp2 = (int) (arg2); \
+ LOAD_ARGS_1 (nm, arg1) \
+ register int _arg2 __asm__ ("r1") = _tmp2;
+
+#define LOAD_ARGS_3(nm, arg1, arg2, arg3) \
+ int _tmp3 = (int) (arg3); \
+ LOAD_ARGS_2 (nm, arg1, arg2) \
+ register int _arg3 __asm__ ("r2") = _tmp3;
+
+#define LOAD_ARGS_4(nm, arg1, arg2, arg3, arg4) \
+ int _tmp4 = (int) (arg4); \
+ LOAD_ARGS_3 (nm, arg1, arg2, arg3) \
+ register int _arg4 __asm__ ("r3") = _tmp4;
+
+#define LOAD_ARGS_5(nm, arg1, arg2, arg3, arg4, arg5) \
+ int _tmp5 = (int) (arg5); \
+ LOAD_ARGS_4 (nm, arg1, arg2, arg3, arg4) \
+ register int _arg5 __asm__ ("r4") = _tmp5;
+
+#define LOAD_ARGS_6(nm, arg1, arg2, arg3, arg4, arg5, arg6) \
+ int _tmp6 = (int) (arg6); \
+ LOAD_ARGS_5 (nm, arg1, arg2, arg3, arg4, arg5) \
+ register int _arg6 __asm__ ("r5") = _tmp6;
+
+#define LOAD_ARGS_7(nm, arg1, arg2, arg3, arg4, arg5, arg6, arg7)\
+ int _tmp7 = (int) (arg7); \
+ LOAD_ARGS_6 (nm, arg1, arg2, arg3, arg4, arg5, arg6) \
+ register int _arg7 __asm__ ("r6") = _tmp7;
+
+#else
+
+#ifdef __A7__
+#define ARC_TRAP_INSN trap0
+#elif defined(__HS__)
+#define ARC_TRAP_INSN trap_s 0
+#endif
+
+#endif /* __ASSEMBLER__ */
+
+#endif /* _BITS_SYSCALLS_H */
diff --git a/libc/sysdeps/linux/sh64/bits/uClibc_arch_features.h b/libc/sysdeps/linux/arc/bits/uClibc_arch_features.h
index 1e8aa593f..51607240c 100644..100755
--- a/libc/sysdeps/linux/sh64/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/arc/bits/uClibc_arch_features.h
@@ -1,4 +1,10 @@
/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+/*
* Track misc arch-specific features that aren't config options
*/
@@ -6,33 +12,40 @@
#define _BITS_UCLIBC_ARCH_FEATURES_H
/* instruction used when calling abort() to kill yourself */
-#define __UCLIBC_ABORT_INSTRUCTION__ "movi 0x10, r9; shori 0xff, r9; trapa r9"
+#define __UCLIBC_ABORT_INSTRUCTION__ "flag 0"
/* can your target use syscall6() for mmap ? */
#undef __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__
+/* The default ';' is a comment on ARC. */
+#define __UCLIBC_ASM_LINE_SEP__ `
+
+/* does your target align 64bit values in register pairs ? (32bit arches only) */
+#if defined(__A7__)
+#undef __UCLIBC_SYSCALL_ALIGN_64BIT__
+#else
+#define __UCLIBC_SYSCALL_ALIGN_64BIT__
+#endif
+
#endif /* _BITS_UCLIBC_ARCH_FEATURES_H */
diff --git a/libc/sysdeps/linux/arc/bits/uClibc_page.h b/libc/sysdeps/linux/arc/bits/uClibc_page.h
new file mode 100755
index 000000000..b05c57501
--- /dev/null
+++ b/libc/sysdeps/linux/arc/bits/uClibc_page.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#ifndef _UCLIBC_PAGE_H
+#define _UCLIBC_PAGE_H
+
+/*
+ * ARC700/linux supports 4k, 8k, 16k pages (build time).
+ *
+ * Although uClibc determines page size dynamically, from kernel's auxv which
+ * ARC Linux does pass, still the generic code needs a fall back
+ * _dl_pagesize = auxvt[AT_PAGESZ].a_un.a_val ? : PAGE_SIZE
+ *
+ */
+
+#include <features.h>
+
+#if defined(__CONFIG_ARC_PAGE_SIZE_16K__)
+#define PAGE_SHIFT 14
+#elif defined(__CONFIG_ARC_PAGE_SIZE_4K__)
+#define PAGE_SHIFT 12
+#else
+#define PAGE_SHIFT 13
+#endif
+
+#define PAGE_SIZE (1UL << PAGE_SHIFT)
+#define PAGE_MASK (~(PAGE_SIZE-1))
+
+/* TBD: fix this with runtime value for a PAGE_SIZE agnostic uClibc */
+#define MMAP2_PAGE_SHIFT PAGE_SHIFT
+
+#endif /* _UCLIBC_PAGE_H */
diff --git a/libc/sysdeps/linux/arc/bits/wordsize.h b/libc/sysdeps/linux/arc/bits/wordsize.h
new file mode 100755
index 000000000..c7480332c
--- /dev/null
+++ b/libc/sysdeps/linux/arc/bits/wordsize.h
@@ -0,0 +1,7 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#define __WORDSIZE 32
diff --git a/libc/sysdeps/linux/arc/bsd-_setjmp.S b/libc/sysdeps/linux/arc/bsd-_setjmp.S
new file mode 100644
index 000000000..d166cb8ca
--- /dev/null
+++ b/libc/sysdeps/linux/arc/bsd-_setjmp.S
@@ -0,0 +1,20 @@
+/* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'. ARC version.
+ *
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+/* This just does a tail-call to `__sigsetjmp (ARG, 1)'.
+ We cannot do it in C because it must be a tail-call, so frame-unwinding
+ in setjmp doesn't clobber the state restored by longjmp. */
+
+#include <sysdep.h>
+
+;@ r0 = jump buffer into which regs will be saved
+
+ENTRY(_setjmp)
+ b.d __sigsetjmp
+ mov r1, 0 ; don't save signals
+END(_setjmp)
+libc_hidden_def(_setjmp)
diff --git a/libc/sysdeps/linux/arc/bsd-setjmp.S b/libc/sysdeps/linux/arc/bsd-setjmp.S
new file mode 100644
index 000000000..46745958e
--- /dev/null
+++ b/libc/sysdeps/linux/arc/bsd-setjmp.S
@@ -0,0 +1,20 @@
+/* BSD `setjmp' entry point to `sigsetjmp (..., 1)'. ARC version.
+ *
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+/* This just does a tail-call to `__sigsetjmp (ARG, 1)'.
+ We cannot do it in C because it must be a tail-call, so frame-unwinding
+ in setjmp doesn't clobber the state restored by longjmp. */
+
+#include <sysdep.h>
+
+;@ r0 = jump buffer into which regs will be saved
+
+ENTRY(setjmp)
+ b.d __sigsetjmp
+ mov r1, 1 ; save signals
+END(setjmp)
+libc_hidden_def(setjmp)
diff --git a/libc/sysdeps/linux/arc/cacheflush.c b/libc/sysdeps/linux/arc/cacheflush.c
new file mode 100644
index 000000000..d33353d83
--- /dev/null
+++ b/libc/sysdeps/linux/arc/cacheflush.c
@@ -0,0 +1,11 @@
+/* cacheflush syscall for ARC
+ *
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <sys/cachectl.h>
+
+_syscall3(int, cacheflush, void *, addr, int, nbytes, int, op)
diff --git a/libc/sysdeps/linux/arc/clone.S b/libc/sysdeps/linux/arc/clone.S
new file mode 100644
index 000000000..3c1388ec7
--- /dev/null
+++ b/libc/sysdeps/linux/arc/clone.S
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <asm/errno.h>
+#include <sys/syscall.h>
+#include <sysdep.h>
+
+; Per man, libc clone( ) is as follows
+;
+; int clone(int (*fn)(void *), void *child_stack,
+; int flags, void *arg, ...
+; /* pid_t *ptid, struct user_desc *tls, pid_t *ctid */);
+;
+; NOTE: I'm assuming that the last 3 args are NOT var-args and in case all
+; 3 are not relevant, caller will nevertheless pass those as NULL.
+; Current (Jul 2012) upstream powerpc/clone.S assumes similarly.
+; Our LTP (from 2007) doesn't seem to have tests to prove otherwise
+
+; clone syscall in kernel (ABI: CONFIG_CLONE_BACKWARDS)
+;
+; int sys_clone(unsigned long clone_flags,
+; unsigned long newsp,
+; int __user *parent_tidptr,
+; void *tls,
+; int __user *child_tidptr)
+
+#define CLONE_VM 0x00000100
+#define CLONE_THREAD 0x00010000
+#define CLONE_SETTLS 0x00080000
+#define CLONE_THREAD_N_VM (CLONE_THREAD | CLONE_VM)
+
+ENTRY(clone)
+ cmp r0, 0 ; @fn can't be NULL
+ cmp.ne r1, 0 ; @child_stack can't be NULL
+ bz .L__sys_err
+
+ ; save some of the orig args
+ ; r0 containg @fn will be clobbered AFTER syscall (with ret val)
+ ; rest are clobbered BEFORE syscall due to different arg ordering
+ mov r10, r0 ; @fn
+ mov r11, r3 ; @args
+ mov r12, r2 ; @clone_flags
+ mov r9, r5 ; @tls
+
+ ; adjust libc args for syscall
+
+ mov r0, r2 ; libc @flags is 1st syscall arg
+ mov r2, r4 ; libc @ptid
+ mov r3, r5 ; libc @tls
+ mov r4, r6 ; libc @ctid
+ mov r8, __NR_clone
+ ARC_TRAP_INSN
+
+ cmp r0, 0 ; return code : 0 new process, !0 parent
+ blt .L__sys_err2 ; < 0 (signed) error
+ jnz [blink] ; Parent returns
+
+ ; ----- child starts here ---------
+
+#if defined(__UCLIBC_HAS_TLS__)
+ ; Setup TP register (since kernel doesn't do that)
+ and.f 0, r12, CLONE_SETTLS
+ bz .Lnext_clone_quirk
+ SET_TP r9
+
+.Lnext_clone_quirk:
+#ifdef RESET_PID
+ mov_s r2, CLONE_THREAD_N_VM
+ and_s r2, r2, r12
+ brne r2, r12, .Lgo_thread
+
+ mov r8, __NR_clone
+ ARC_TRAP_INSN ; r0 has PID
+ THREAD_SELF r1 ; Get to struct pthread (just before TCB)
+ st r0, [r1, PTHREAD_PID]
+ st r0, [r1, PTHREAD_TID]
+
+.Lgo_thread:
+#endif
+#endif
+ ; child jumps off to @fn with @arg as argument, and returns here
+ jl.d [r10]
+ mov r0, r11
+
+ ; falls thru to _exit() with result from @fn (already in r0)
+ b HIDDEN_JUMPTARGET(_exit)
+
+.L__sys_err:
+ mov r0, -EINVAL
+.L__sys_err2:
+ ; (1) No need to make -ve kernel error code as positive errno
+ ; __syscall_error expects the -ve error code returned by kernel
+ ; (2) r0 still had orig -ve kernel error code
+ ; (3) Tail call to __syscall_error so we dont have to come back
+ ; here hence instead of jmp-n-link (reg push/pop) we do jmp
+ ; (4) No need to route __syscall_error via PLT, B is inherently
+ ; position independent
+ b __syscall_error
+END(clone)
+libc_hidden_def(clone)
diff --git a/libc/sysdeps/linux/arc/crt1.S b/libc/sysdeps/linux/arc/crt1.S
new file mode 100644
index 000000000..95c41f888
--- /dev/null
+++ b/libc/sysdeps/linux/arc/crt1.S
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <features.h>
+
+.text
+
+#ifndef __UCLIBC_CTOR_DTOR__
+ .weak _init
+ .weak _fini
+#endif
+
+/* Stick in a dummy reference to main(), so that if an application
+ * is linking when the main() function is in a static library (.a)
+ * we can be sure that main() actually gets linked in
+ */
+ .type main,@function
+ .type _main,@function
+
+
+/* When we enter this piece of code, the program stack looks like this:
+ argc argument counter (integer)
+ argv[0] program name (pointer)
+ argv[1...N] program args (pointers)
+ argv[argc-1] end of args (integer)
+ NULL
+ env[0...N] environment variables (pointers)
+ NULL
+*/
+ .text
+ .align 4
+ .global __start
+ .hidden __start
+ .type __start,@function
+__start:
+ mov fp, 0
+ ld_s r1, [sp] ; argc
+
+ mov_s r5, r0 ; rltd_fini
+ add_s r2, sp, 4 ; argv
+
+ mov_s r0, main
+ mov_s r3, _init
+ mov r4, _fini
+
+ and sp, sp, -8
+ mov r6, sp
+
+ /* __uClibc_main (main, argc, argv, init, fini, rtld_fini, stack_end) */
+ bl __uClibc_main
+
+ /* Should never get here.... */
+ flag 1
+.size __start,.-__start
diff --git a/libc/sysdeps/linux/arc/crti.S b/libc/sysdeps/linux/arc/crti.S
new file mode 100644
index 000000000..da8fc2a2a
--- /dev/null
+++ b/libc/sysdeps/linux/arc/crti.S
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+___gnu_compiled_c:
+
+ .section .init
+ .align 4
+ .global _init
+ .type _init,@function
+_init:
+ st.a blink,[sp,-4]
+ st.a fp,[sp,-4]
+ mov fp,sp
+
+
+ .section .fini
+ .align 4
+ .global _fini
+ .type _fini,@function
+_fini:
+ st.a blink,[sp,-4]
+ st.a fp,[sp,-4]
+ mov fp,sp
+ .align 4
diff --git a/libc/sysdeps/linux/arc/crtn.S b/libc/sysdeps/linux/arc/crtn.S
new file mode 100644
index 000000000..f507080b3
--- /dev/null
+++ b/libc/sysdeps/linux/arc/crtn.S
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+___gnu_compiled_c:
+
+ .section .init
+ .align 4
+ .global _init
+ .type _init,@function
+ ; EPILOGUE
+ ld.ab fp,[sp,4]
+ ld blink,[sp,0]
+ j.d [blink]
+ add sp,sp,4
+; .size _init,.-_init
+
+ .section .fini
+ .align 4
+ .global _fini
+ .type _fini,@function
+ ; EPILOGUE
+ ld.ab fp,[sp,4]
+ ld blink,[sp,0]
+ j.d [blink]
+ add sp,sp,4
+; .size _fini,.-_fini
diff --git a/libc/sysdeps/linux/arc/jmpbuf-offsets.h b/libc/sysdeps/linux/arc/jmpbuf-offsets.h
new file mode 100644
index 000000000..314e03110
--- /dev/null
+++ b/libc/sysdeps/linux/arc/jmpbuf-offsets.h
@@ -0,0 +1,7 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#define __JMP_BUF_SP (13+1)
diff --git a/libc/sysdeps/linux/arc/jmpbuf-unwind.h b/libc/sysdeps/linux/arc/jmpbuf-unwind.h
new file mode 100644
index 000000000..8c41816c5
--- /dev/null
+++ b/libc/sysdeps/linux/arc/jmpbuf-unwind.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <setjmp.h>
+#include <jmpbuf-offsets.h>
+
+/* Test if longjmp to JMPBUF would unwind the frame
+ containing a local variable at ADDRESS. */
+#define _JMPBUF_UNWINDS(jmpbuf, address) \
+ ((void *) (address) < (void *) (jmpbuf[__JMP_BUF_SP]))
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <stdint.h>
+#include <unwind.h>
+
+/* Test if longjmp to JMPBUF would unwind the frame
+ containing a local variable at ADDRESS. */
+#undef _JMPBUF_UNWINDS
+#define _JMPBUF_UNWINDS(jmpbuf, address, demangle) \
+ ((void *) (address) < (void *) demangle (jmpbuf[__JMP_BUF_SP]))
+
+#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
+ _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
+
+#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
+ ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[__JMP_BUF_SP] - (_adj))
+#endif
diff --git a/libc/sysdeps/linux/arc/setjmp.S b/libc/sysdeps/linux/arc/setjmp.S
new file mode 100644
index 000000000..b6a65f579
--- /dev/null
+++ b/libc/sysdeps/linux/arc/setjmp.S
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sysdep.h>
+
+;@ r0 = jump buffer into which regs will be saved
+;@ r1 = do we need to save signals
+
+ENTRY(__sigsetjmp)
+
+ st_s r13, [r0]
+ st_s r14, [r0,4]
+ st r15, [r0,8]
+ st r16, [r0,12]
+ st r17, [r0,16]
+ st r18, [r0,20]
+ st r19, [r0,24]
+ st r20, [r0,28]
+ st r21, [r0,32]
+ st r22, [r0,36]
+ st r23, [r0,40]
+ st r24, [r0,44]
+ st r25, [r0,48]
+ st fp, [r0,52]
+ st sp, [r0,56]
+
+ ; make a note of where longjmp will return to.
+ ; that will be right next to this setjmp call-site which will be
+ ; contained in blink, since "C" caller of this routine will do
+ ; a branch-n-link
+
+ st blink, [r0,60]
+ b __sigjmp_save
+
+END(__sigsetjmp)
+libc_hidden_def(__sigsetjmp)
diff --git a/libc/sysdeps/linux/arc/sigaction.c b/libc/sysdeps/linux/arc/sigaction.c
new file mode 100644
index 000000000..67ca38aca
--- /dev/null
+++ b/libc/sysdeps/linux/arc/sigaction.c
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <errno.h>
+#include <signal.h>
+#include <string.h>
+#include <sys/syscall.h>
+#include <bits/kernel_sigaction.h>
+
+/*
+ * Default sigretrun stub if user doesn't specify SA_RESTORER
+ */
+static void attribute_optimize("Os") __attribute_noinline__
+__default_rt_sa_restorer(void)
+{
+ INTERNAL_SYSCALL_NCS(__NR_rt_sigreturn, , 0);
+}
+
+#define SA_RESTORER 0x04000000
+
+/* 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)
+{
+ struct sigaction kact;
+
+ /*
+ * SA_RESTORER is only relevant for act != NULL case
+ * (!act means caller only wants to know @oact)
+ */
+ if (act && !(act->sa_flags & SA_RESTORER)) {
+ kact.sa_restorer = __default_rt_sa_restorer;
+ kact.sa_flags = act->sa_flags | SA_RESTORER;
+
+ kact.sa_handler = act->sa_handler;
+ kact.sa_mask = act->sa_mask;
+
+ act = &kact;
+ }
+
+ return INLINE_SYSCALL(rt_sigaction, 4,
+ sig, act, oact, sizeof(act->sa_mask));
+}
+
+#ifndef LIBC_SIGACTION
+# ifndef __UCLIBC_HAS_THREADS__
+strong_alias(__libc_sigaction,sigaction)
+libc_hidden_def(sigaction)
+# else
+weak_alias(__libc_sigaction,sigaction)
+libc_hidden_weak(sigaction)
+# endif
+#endif
diff --git a/libc/sysdeps/linux/arc/sys/cachectl.h b/libc/sysdeps/linux/arc/sys/cachectl.h
new file mode 100644
index 000000000..e9a783bdc
--- /dev/null
+++ b/libc/sysdeps/linux/arc/sys/cachectl.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#ifndef _SYS_CACHECTL_H
+#define _SYS_CACHECTL_H 1
+
+/*
+ * Get the kernel definition for the flag bits
+ */
+#include <asm/cachectl.h>
+
+__BEGIN_DECLS
+
+extern int cacheflush(void *addr, int nbytes, int flags);
+
+__END_DECLS
+
+#endif /* sys/cachectl.h */
diff --git a/libc/sysdeps/linux/nios/sys/procfs.h b/libc/sysdeps/linux/arc/sys/procfs.h
index 8cbaa41c5..a47430340 100644..100755
--- a/libc/sysdeps/linux/nios/sys/procfs.h
+++ b/libc/sysdeps/linux/arc/sys/procfs.h
@@ -1,58 +1,37 @@
-/* Copyright (C) 1996, 1997, 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. */
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
#ifndef _SYS_PROCFS_H
#define _SYS_PROCFS_H 1
-/* This is somehow modelled after the file of the same name on SysVr4
+/* 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. */
+ 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 <signal.h>
#include <sys/time.h>
#include <sys/types.h>
-#include <sys/ucontext.h>
#include <sys/user.h>
-#include <bits/wordsize.h>
+#include <asm/ptrace.h>
__BEGIN_DECLS
-#define ELF_NGREG 38
-
-typedef struct
- {
- union
- {
- unsigned long pr_regs[32];
- double pr_dregs[16];
- } pr_fr;
- unsigned long __unused;
- unsigned long pr_fsr;
- unsigned char pr_qcnt;
- unsigned char pr_q_entrysize;
- unsigned char pr_en;
- unsigned int pr_q[64];
- } elf_fpregset_t;
-
+/* Type for a general-purpose register. */
typedef unsigned long elf_greg_t;
+
+#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t))
typedef elf_greg_t elf_gregset_t[ELF_NGREG];
+typedef struct { } elf_fpregset_t;
+/* Signal info. */
struct elf_siginfo
{
int si_signo; /* Signal number. */
@@ -62,11 +41,11 @@ struct elf_siginfo
/* 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
+ 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. Fields present but not used are
- marked with "XXX". */
+ GDB doesn't really use excluded. */
+
struct elf_prstatus
{
struct elf_siginfo pr_info; /* Info associated with signal. */
@@ -86,7 +65,7 @@ struct elf_prstatus
};
-#define ELF_PRARGSZ (80) /* Number of chars for args */
+#define ELF_PRARGSZ (80) /* Number of chars for args. */
struct elf_prpsinfo
{
@@ -103,6 +82,10 @@ struct elf_prpsinfo
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;
@@ -114,7 +97,7 @@ typedef elf_fpregset_t prfpregset_t;
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;
diff --git a/libc/sysdeps/linux/arc/sys/ucontext.h b/libc/sysdeps/linux/arc/sys/ucontext.h
new file mode 100755
index 000000000..23d928562
--- /dev/null
+++ b/libc/sysdeps/linux/arc/sys/ucontext.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#ifndef _SYS_UCONTEXT_H
+#define _SYS_UCONTEXT_H 1
+
+#include <features.h>
+#include <signal.h>
+#include <bits/sigcontext.h>
+
+typedef struct ucontext {
+ unsigned long uc_flags;
+ struct ucontext *uc_link;
+ stack_t uc_stack;
+ struct sigcontext uc_mcontext;
+ sigset_t uc_sigmask; /* mask last for extensibility */
+} ucontext_t;
+
+#endif /* sys/ucontext.h */
diff --git a/libc/sysdeps/linux/arc/sys/user.h b/libc/sysdeps/linux/arc/sys/user.h
new file mode 100755
index 000000000..e340074ce
--- /dev/null
+++ b/libc/sysdeps/linux/arc/sys/user.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#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. */
+
+
+/* Actually apps like strace also expect a struct user, so it's better to
+ * have a dummy implementation
+ */
+
+struct user {
+ int dummy;
+};
+
+#endif /* sys/user.h */
diff --git a/libc/sysdeps/linux/arc/syscall.c b/libc/sysdeps/linux/arc/syscall.c
new file mode 100644
index 000000000..5648b0e1f
--- /dev/null
+++ b/libc/sysdeps/linux/arc/syscall.c
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <features.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/syscall.h>
+
+extern long syscall(long int sysnum, long a, long b, long c, long d, long e, long f);
+
+long syscall(long int sysnum, long a, long b, long c, long d, long e, long f)
+{
+ return INLINE_SYSCALL_NCS(sysnum, 6, a, b, c, d, e, f);
+}
diff --git a/libc/sysdeps/linux/arc/sysdep.h b/libc/sysdeps/linux/arc/sysdep.h
new file mode 100644
index 000000000..d75d89100
--- /dev/null
+++ b/libc/sysdeps/linux/arc/sysdep.h
@@ -0,0 +1,26 @@
+#ifndef _LINUX_ARC_SYSDEP_H
+#define _LINUX_ARC_SYSDEP_H 1
+
+#include <features.h>
+#include <libc-internal.h>
+
+#ifdef __ASSEMBLER__
+
+#define ENTRY(nm) \
+ .text ` \
+ .align 4 ` \
+ .globl nm ` \
+ .type nm,@function ` \
+nm:
+
+#define END(name) .size name,.-name
+
+#endif /* __ASSEMBLER __*/
+
+#include <common/sysdep.h>
+
+/* Pointer mangling is not yet supported */
+#define PTR_MANGLE(var) (void) (var)
+#define PTR_DEMANGLE(var) (void) (var)
+
+#endif
diff --git a/libc/sysdeps/linux/arc/vfork.S b/libc/sysdeps/linux/arc/vfork.S
new file mode 100644
index 000000000..573a29f26
--- /dev/null
+++ b/libc/sysdeps/linux/arc/vfork.S
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <sysdep.h>
+
+/* No legacy syscall ABI means NR_vfork is not available at all, use clone */
+#define _SIGNAL_H
+#include <bits/signum.h> /* For SIGCHLD */
+
+#define CLONE_VM 0x00000100
+#define CLONE_VFORK 0x00004000
+#define CLONE_FLAGS_FOR_VFORK (CLONE_VM|CLONE_VFORK|SIGCHLD)
+
+ENTRY(__vfork)
+#ifdef SAVE_PID
+ THREAD_SELF r1 ; Get to struct pthread (just before TCB)
+ ld r2, [r1, PTHREAD_PID]
+ neg.f r3, r2
+ bset.z r3, r3, 31
+ st r3, [r1, PTHREAD_PID]
+#endif
+ mov r0, CLONE_FLAGS_FOR_VFORK
+ mov_s r1, sp
+ mov r8, __NR_clone
+ ARC_TRAP_INSN
+
+ cmp r0, 0
+#ifdef RESTORE_PID
+ bz 1f ; child continues
+ THREAD_SELF r1 ; Get to struct pthread (just before TCB)
+ st r2, [r1, PTHREAD_PID]
+1:
+#endif
+ jge [blink] ; pid >=0 return, else detour via tailcall to errno
+
+ b __syscall_error
+END(__vfork)
+
+weak_alias(__vfork,vfork)
+libc_hidden_def(vfork)
diff --git a/libc/sysdeps/linux/arc/xstatconv.c b/libc/sysdeps/linux/arc/xstatconv.c
new file mode 100644
index 000000000..d7948c075
--- /dev/null
+++ b/libc/sysdeps/linux/arc/xstatconv.c
@@ -0,0 +1 @@
+/* We don't need any of this. */
diff --git a/libc/sysdeps/linux/arm/Makefile.arch b/libc/sysdeps/linux/arm/Makefile.arch
index a3b6fc4d8..cda3db206 100644
--- a/libc/sysdeps/linux/arm/Makefile.arch
+++ b/libc/sysdeps/linux/arm/Makefile.arch
@@ -5,31 +5,42 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-CSRC := brk.c ioperm.c iopl.c mmap.c posix_fadvise.c posix_fadvise64.c \
- sigaction.c __syscall_error.c
+CSRC-y := brk.c ioperm.c iopl.c __syscall_error.c sigaction.c
-SSRC := \
- __longjmp.S vfork.S clone.S setjmp.S bsd-setjmp.S \
- bsd-_setjmp.S sigrestorer.S mmap64.S
+SSRC-y := \
+ __longjmp.S setjmp.S bsd-setjmp.S \
+ bsd-_setjmp.S sigrestorer.S \
+ vfork.S clone.S
-ifeq ($(CONFIG_ARM_EABI),y)
-CSRC += aeabi_assert.c aeabi_atexit.c aeabi_errno_addr.c \
+SSRC-$(UCLIBC_HAS_LFS) += mmap64.S
+SSRC-$(UCLIBC_HAS_THREADS_NATIVE) += libc-thumb_atomics.S
+libc-nonshared-$(UCLIBC_HAS_THREADS_NATIVE) += $(ARCH_OUT)/libc-aeabi_read_tp.os
+libc-static-$(UCLIBC_HAS_THREADS_NATIVE) += $(ARCH_OUT)/libc-aeabi_read_tp.o
+CSRC-$(UCLIBC_HAS_CONTEXT_FUNCS) += makecontext.c
+SSRC-$(UCLIBC_HAS_CONTEXT_FUNCS) += getcontext.S setcontext.S swapcontext.S
+
+# Is our compiler set up for EABI ?
+CC_IS_EABI_CHECK = $(filter-out -include libc-symbols.h,$(CC) $(CFLAGS))
+$(eval $(call cache-output-var,IS_EABI,$(CC_IS_EABI_CHECK) -x c - -E -dM </dev/null 2>/dev/null | grep __ARM_EABI__ 2>&1 >/dev/null && echo 'y'))
+
+CSRC-$(IS_EABI) += aeabi_assert.c aeabi_atexit.c aeabi_errno_addr.c \
aeabi_localeconv.c aeabi_memclr.c aeabi_memcpy.c \
aeabi_memmove.c aeabi_memset.c find_exidx.c
-SSRC += syscall-eabi.S
-ifeq ($(UCLIBC_HAS_WCHAR),y)
-CSRC += aeabi_mb_cur_max.c
-endif
-else
-CSRC += syscall.c
+SSRC-$(IS_EABI) += syscall-eabi.S
+CSRC-$(if $(IS_EABI),,y)) += syscall.c
+ARCH_OBJ_FILTEROUT-$(IS_EABI) := syscall.c
+ifeq ($(IS_EABI),y)
+CSRC-$(UCLIBC_HAS_WCHAR) += aeabi_mb_cur_max.c
endif
-include $(top_srcdir)libc/sysdeps/linux/Makefile.commonarch
-
-ifeq ($(CONFIG_ARM_EABI),y)
-libc-static-y += $(ARCH_OUT)/aeabi_lcsts.o $(ARCH_OUT)/aeabi_math.o \
- $(ARCH_OUT)/aeabi_sighandlers.o
-libc-nonshared-y += $(ARCH_OUT)/aeabi_lcsts.os $(ARCH_OUT)/aeabi_math.os \
- $(ARCH_OUT)/aeabi_sighandlers.os
-libc-shared-y += $(ARCH_OUT)/aeabi_unwind_cpp_pr1.os
-endif
+libc-static-$(IS_EABI) += $(addprefix $(ARCH_OUT)/, \
+ aeabi_lcsts.o \
+ aeabi_math.o \
+ aeabi_sighandlers.o \
+ )
+libc-nonshared-$(IS_EABI) += $(addprefix $(ARCH_OUT)/, \
+ aeabi_lcsts.os \
+ aeabi_math.os \
+ aeabi_sighandlers.os \
+ aeabi_unwind_cpp_pr1.o \
+ )
diff --git a/libc/sysdeps/linux/arm/__longjmp.S b/libc/sysdeps/linux/arm/__longjmp.S
index 5faf4ece9..58ae8ab58 100644
--- a/libc/sysdeps/linux/arm/__longjmp.S
+++ b/libc/sysdeps/linux/arm/__longjmp.S
@@ -13,16 +13,12 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <features.h>
#include <bits/arm_asm.h>
-#define _SETJMP_H
-#define _ASM
-#include <bits/setjmp.h>
-
+#include <bits/arm_bx.h>
.global __longjmp
.type __longjmp,%function
@@ -102,12 +98,7 @@ __longjmp:
ldcl p1, cr14, [r12], #8
ldcl p1, cr15, [r12], #8
#endif
-
-#if defined(__USE_BX__)
- bx lr
-#else
- mov pc, lr
-#endif
+ BX(lr)
#endif
.size __longjmp,.-__longjmp
diff --git a/libc/sysdeps/linux/arm/aeabi_assert.c b/libc/sysdeps/linux/arm/aeabi_assert.c
index e0985b446..1f91e26c9 100644
--- a/libc/sysdeps/linux/arm/aeabi_assert.c
+++ b/libc/sysdeps/linux/arm/aeabi_assert.c
@@ -12,19 +12,16 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#undef NDEBUG
#include <assert.h>
#include <stdlib.h>
-libc_hidden_proto(__assert)
-void
-__aeabi_assert (const char *assertion, const char *file,
- unsigned int line)
+void __aeabi_assert(const char *assertion, const char *file, unsigned int line) attribute_noreturn;
+void __aeabi_assert(const char *assertion, const char *file, unsigned int line)
{
__assert (assertion, file, line, NULL);
}
diff --git a/libc/sysdeps/linux/arm/aeabi_atexit.c b/libc/sysdeps/linux/arm/aeabi_atexit.c
index 4a7a6f1dc..190ed461a 100644
--- a/libc/sysdeps/linux/arm/aeabi_atexit.c
+++ b/libc/sysdeps/linux/arm/aeabi_atexit.c
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <stdlib.h>
@@ -24,8 +23,8 @@ libc_hidden_proto(__cxa_atexit)
/* Register a function to be called by exit or when a shared library
is unloaded. This routine is like __cxa_atexit, but uses the
calling sequence required by the ARM EABI. */
-int
-__aeabi_atexit (void *arg, void (*func) (void *), void *d)
+int __aeabi_atexit (void *arg, void (*func) (void *), void *d);
+int __aeabi_atexit (void *arg, void (*func) (void *), void *d)
{
return __cxa_atexit (func, arg, d);
}
diff --git a/libc/sysdeps/linux/arm/aeabi_errno_addr.c b/libc/sysdeps/linux/arm/aeabi_errno_addr.c
index 09bdc1efe..aa36bde39 100644
--- a/libc/sysdeps/linux/arm/aeabi_errno_addr.c
+++ b/libc/sysdeps/linux/arm/aeabi_errno_addr.c
@@ -12,14 +12,13 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <errno.h>
-volatile int *
-__aeabi_errno_addr (void)
+volatile int * __aeabi_errno_addr (void);
+volatile int * __aeabi_errno_addr (void)
{
return &errno;
}
diff --git a/libc/sysdeps/linux/arm/aeabi_lcsts.c b/libc/sysdeps/linux/arm/aeabi_lcsts.c
index 99c79851e..746c0ffe1 100644
--- a/libc/sysdeps/linux/arm/aeabi_lcsts.c
+++ b/libc/sysdeps/linux/arm/aeabi_lcsts.c
@@ -30,9 +30,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* The ARM EABI requires that we provide ISO compile-time constants as
link-time constants. Some portable applications may reference these. */
@@ -79,6 +78,23 @@ eabi_constant (BUFSIZ);
eabi_constant (FOPEN_MAX);
eabi_constant (TMP_MAX);
eabi_constant (FILENAME_MAX);
+#ifdef __UCLIBC_SUSV4_LEGACY__
eabi_constant (L_tmpnam);
+#endif
+
+FILE *__aeabi_stdin attribute_hidden;
+FILE *__aeabi_stdout attribute_hidden;
+FILE *__aeabi_stderr attribute_hidden;
+
+static void __attribute__ ((used))
+setup_aeabi_stdio (void)
+{
+ __aeabi_stdin = stdin;
+ __aeabi_stdout = stdout;
+ __aeabi_stderr = stderr;
+}
+
+static void (*fp) (void) __attribute__ ((used, section (".preinit_array")))
+ = setup_aeabi_stdio;
eabi_constant (CLOCKS_PER_SEC);
diff --git a/libc/sysdeps/linux/arm/aeabi_localeconv.c b/libc/sysdeps/linux/arm/aeabi_localeconv.c
index c9e9dd23f..53f03ae09 100644
--- a/libc/sysdeps/linux/arm/aeabi_localeconv.c
+++ b/libc/sysdeps/linux/arm/aeabi_localeconv.c
@@ -12,16 +12,14 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <locale.h>
-libc_hidden_proto(localeconv)
-struct lconv *
-__aeabi_localeconv (void)
+struct lconv * __aeabi_localeconv (void);
+struct lconv * __aeabi_localeconv (void)
{
return localeconv ();
}
diff --git a/libc/sysdeps/linux/arm/aeabi_math.c b/libc/sysdeps/linux/arm/aeabi_math.c
index e7f1dbf5f..151125246 100644
--- a/libc/sysdeps/linux/arm/aeabi_math.c
+++ b/libc/sysdeps/linux/arm/aeabi_math.c
@@ -29,9 +29,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <math.h>
diff --git a/libc/sysdeps/linux/arm/aeabi_mb_cur_max.c b/libc/sysdeps/linux/arm/aeabi_mb_cur_max.c
index 937a7fffb..9966e5840 100644
--- a/libc/sysdeps/linux/arm/aeabi_mb_cur_max.c
+++ b/libc/sysdeps/linux/arm/aeabi_mb_cur_max.c
@@ -12,24 +12,15 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <langinfo.h>
#include <locale.h>
#include <stdlib.h>
-#ifdef __UCLIBC_HAS_WCHAR__
-libc_hidden_proto(_stdlib_mb_cur_max)
-#endif
-
-int
-__aeabi_MB_CUR_MAX (void)
+int __aeabi_MB_CUR_MAX (void);
+int __aeabi_MB_CUR_MAX (void)
{
-#ifdef __UCLIBC_HAS_WCHAR__
return MB_CUR_MAX;
-#else
- return 1;
-#endif
}
diff --git a/libc/sysdeps/linux/arm/aeabi_memclr.c b/libc/sysdeps/linux/arm/aeabi_memclr.c
index c0f90216c..9bfe86e8a 100644
--- a/libc/sysdeps/linux/arm/aeabi_memclr.c
+++ b/libc/sysdeps/linux/arm/aeabi_memclr.c
@@ -12,18 +12,16 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <string.h>
-/* Experimentally off - libc_hidden_proto(memset) */
/* Clear memory. Can't alias to bzero because it's not defined in the
same translation unit. */
-void
-__aeabi_memclr (void *dest, size_t n)
+void __aeabi_memclr (void *dest, size_t n);
+void __aeabi_memclr (void *dest, size_t n)
{
memset (dest, 0, n);
}
diff --git a/libc/sysdeps/linux/arm/aeabi_memcpy.c b/libc/sysdeps/linux/arm/aeabi_memcpy.c
index 83eac0b67..a84d9f4f7 100644
--- a/libc/sysdeps/linux/arm/aeabi_memcpy.c
+++ b/libc/sysdeps/linux/arm/aeabi_memcpy.c
@@ -12,19 +12,17 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <string.h>
-/* Experimentally off - libc_hidden_proto(memcpy) */
/* Copy memory like memcpy, but no return value required. Can't alias
to memcpy because it's not defined in the same translation
unit. */
-void
-__aeabi_memcpy (void *dest, const void *src, size_t n)
+void __aeabi_memcpy (void *dest, const void *src, size_t n);
+void __aeabi_memcpy (void *dest, const void *src, size_t n)
{
memcpy (dest, src, n);
}
diff --git a/libc/sysdeps/linux/arm/aeabi_memmove.c b/libc/sysdeps/linux/arm/aeabi_memmove.c
index 164d72bc9..adb69c787 100644
--- a/libc/sysdeps/linux/arm/aeabi_memmove.c
+++ b/libc/sysdeps/linux/arm/aeabi_memmove.c
@@ -12,19 +12,17 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <string.h>
-/* Experimentally off - libc_hidden_proto(memmove) */
/* Copy memory like memmove, but no return value required. Can't
alias to memmove because it's not defined in the same translation
unit. */
-void
-__aeabi_memmove (void *dest, const void *src, size_t n)
+void __aeabi_memmove (void *dest, const void *src, size_t n);
+void __aeabi_memmove (void *dest, const void *src, size_t n)
{
memmove (dest, src, n);
}
diff --git a/libc/sysdeps/linux/arm/aeabi_memset.c b/libc/sysdeps/linux/arm/aeabi_memset.c
index f1c366f27..183454a25 100644
--- a/libc/sysdeps/linux/arm/aeabi_memset.c
+++ b/libc/sysdeps/linux/arm/aeabi_memset.c
@@ -12,18 +12,16 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <string.h>
-/* Experimentally off - libc_hidden_proto(memset) */
/* Set memory like memset, but different argument order and no return
value required. */
-void
-__aeabi_memset (void *dest, size_t n, int c)
+void __aeabi_memset (void *dest, size_t n, int c);
+void __aeabi_memset (void *dest, size_t n, int c)
{
memset (dest, c, n);
}
diff --git a/libc/sysdeps/linux/arm/aeabi_sighandlers.S b/libc/sysdeps/linux/arm/aeabi_sighandlers.S
index ba9769fd0..f30f5878e 100644
--- a/libc/sysdeps/linux/arm/aeabi_sighandlers.S
+++ b/libc/sysdeps/linux/arm/aeabi_sighandlers.S
@@ -30,9 +30,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* The ARM EABI defines these as "functions". */
diff --git a/libc/sysdeps/linux/arm/aeabi_unwind_cpp_pr1.c b/libc/sysdeps/linux/arm/aeabi_unwind_cpp_pr1.c
index e657d3836..a5cd73faf 100644
--- a/libc/sysdeps/linux/arm/aeabi_unwind_cpp_pr1.c
+++ b/libc/sysdeps/linux/arm/aeabi_unwind_cpp_pr1.c
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* Because some objects in ld.so and libc.so are built with
-fexceptions, we end up with references to this personality
@@ -24,20 +23,17 @@
#include <stdlib.h>
-attribute_hidden
-void
-__aeabi_unwind_cpp_pr0 (void)
+attribute_hidden void __aeabi_unwind_cpp_pr0 (void);
+attribute_hidden void __aeabi_unwind_cpp_pr0 (void)
{
}
-attribute_hidden
-void
-__aeabi_unwind_cpp_pr1 (void)
+attribute_hidden void __aeabi_unwind_cpp_pr1 (void);
+attribute_hidden void __aeabi_unwind_cpp_pr1 (void)
{
}
-attribute_hidden
-void
-__aeabi_unwind_cpp_pr2 (void)
+attribute_hidden void __aeabi_unwind_cpp_pr2 (void);
+attribute_hidden void __aeabi_unwind_cpp_pr2 (void)
{
}
diff --git a/libc/sysdeps/linux/arm/bits/arm_asm.h b/libc/sysdeps/linux/arm/bits/arm_asm.h
index 1d87df6eb..898a78bcc 100644
--- a/libc/sysdeps/linux/arm/bits/arm_asm.h
+++ b/libc/sysdeps/linux/arm/bits/arm_asm.h
@@ -3,20 +3,22 @@
#define _ARM_ASM_H
#ifdef __thumb2__
+# ifdef __ASSEMBLER__
.thumb
.syntax unified
+# endif /* __ASSEMBLER__ */
#define IT(t, cond) i##t cond
#else
/* XXX: This can be removed if/when we require an assembler that supports
unified assembly syntax. */
#define IT(t, cond)
/* Code to return from a thumb function stub. */
-#ifdef __ARM_ARCH_4T__
-#define POP_RET pop {r2, pc}
-#else
-#define POP_RET pop {r2, r3}; bx r3
-#endif
-#endif
+# if defined __ARM_ARCH_4T__ && defined __THUMB_INTERWORK__
+# define POP_RET pop {r2, r3}; bx r3
+# else
+# define POP_RET pop {r2, pc}
+# endif
+#endif /* __thumb2__ */
#if defined(__ARM_ARCH_6M__)
/* Force arm mode to flush out errors on M profile cores. */
@@ -25,4 +27,3 @@
#endif
#endif /* _ARM_ASM_H */
-
diff --git a/libc/sysdeps/linux/arm/bits/arm_bx.h b/libc/sysdeps/linux/arm/bits/arm_bx.h
new file mode 100644
index 000000000..2c290896d
--- /dev/null
+++ b/libc/sysdeps/linux/arm/bits/arm_bx.h
@@ -0,0 +1,40 @@
+/* Copyright (C) 2013 Yann E. MORIN <yann.morin.1998@free.fr>
+ *
+ * This file 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.
+ *
+ * This file 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, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _ARM_BX_H
+#define _ARM_BX_H
+
+/* We need features.h first */
+#if !defined _FEATURES_H
+#error Please include features.h first
+#endif /* features.h not yet included */
+
+#if defined(__USE_BX__)
+# if (__ARM_ARCH <= 4 && !defined __ARM_ARCH_4T__)
+# error Use of BX was requested, but is not available on the target processor.
+# endif /* ARCH level */
+#endif /* __USE_BX__ */
+
+#if defined(__USE_BX__) && (__ARM_ARCH > 4 || (__ARM_ARCH == 4 && defined __ARM_ARCH_4T__))
+# define BX(reg) bx reg
+# define BXC(cond, reg) bx##cond reg
+#else
+# define BX(reg) mov pc, reg
+# define BXC(cond, reg) mov##cond pc, reg
+#endif
+
+#endif /* _ARM_BX_H */
diff --git a/libc/sysdeps/linux/arm/bits/armsigctx.h b/libc/sysdeps/linux/arm/bits/armsigctx.h
index 4530cdbda..aced7b64a 100644
--- a/libc/sysdeps/linux/arm/bits/armsigctx.h
+++ b/libc/sysdeps/linux/arm/bits/armsigctx.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* The format of struct sigcontext changed between 2.0 and 2.1 kernels.
Fortunately 2.0 puts a magic number in the first word and this is not
diff --git a/libc/sysdeps/linux/arm/bits/atomic.h b/libc/sysdeps/linux/arm/bits/atomic.h
new file mode 100644
index 000000000..343288cb6
--- /dev/null
+++ b/libc/sysdeps/linux/arm/bits/atomic.h
@@ -0,0 +1,135 @@
+/* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#if defined __thumb__ && !defined __thumb2__
+#include_next <common/bits/atomic.h>
+#else
+#include <stdint.h>
+#include <sysdep.h>
+
+
+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;
+
+void __arm_link_error (void);
+
+/* 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" \
+ "movt\tip, #0xffff\n\t" \
+ "blx\tip" \
+ : : : "ip", "lr", "cc", "memory");
+#else
+#define atomic_full_barrier() \
+ __asm__ __volatile__ \
+ ("mov\tip, #0xffff0fff\n\t" \
+ "mov\tlr, pc\n\t" \
+ "add\tpc, ip, #(0xffff0fa0 - 0xffff0fff)" \
+ : : : "ip", "lr", "cc", "memory");
+#endif
+
+/* Atomic compare and exchange. This sequence relies on the kernel to
+ provide a compare and exchange operation which is atomic on the
+ current architecture, either via cleverness on pre-ARMv6 or via
+ ldrex / strex on ARMv6. */
+
+#define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
+ ({ __arm_link_error (); oldval; })
+
+#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. */
+
+#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_tmp __asm__ ("r3"); \
+ register __typeof (oldval) a_oldval2 __asm__ ("r4") = (oldval); \
+ __asm__ __volatile__ \
+ ("0:\tldr\t%[tmp],[%[ptr]]\n\t" \
+ "cmp\t%[tmp], %[old2]\n\t" \
+ "bne\t1f\n\t" \
+ "mov\t%[old], %[old2]\n\t" \
+ "movw\t%[tmp], #0x0fc0\n\t" \
+ "movt\t%[tmp], #0xffff\n\t" \
+ "blx\t%[tmp]\n\t" \
+ "bcc\t0b\n\t" \
+ "mov\t%[tmp], %[old2]\n\t" \
+ "1:" \
+ : [old] "=&r" (a_oldval), [tmp] "=&r" (a_tmp) \
+ : [new] "r" (a_newval), [ptr] "r" (a_ptr), \
+ [old2] "r" (a_oldval2) \
+ : "ip", "lr", "cc", "memory"); \
+ 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_tmp __asm__ ("r3"); \
+ register __typeof (oldval) a_oldval2 __asm__ ("r4") = (oldval); \
+ __asm__ __volatile__ \
+ ("0:\tldr\t%[tmp],[%[ptr]]\n\t" \
+ "cmp\t%[tmp], %[old2]\n\t" \
+ "bne\t1f\n\t" \
+ "mov\t%[old], %[old2]\n\t" \
+ "mov\t%[tmp], #0xffff0fff\n\t" \
+ "mov\tlr, pc\n\t" \
+ "add\tpc, %[tmp], #(0xffff0fc0 - 0xffff0fff)\n\t" \
+ "bcc\t0b\n\t" \
+ "mov\t%[tmp], %[old2]\n\t" \
+ "1:" \
+ : [old] "=&r" (a_oldval), [tmp] "=&r" (a_tmp) \
+ : [new] "r" (a_newval), [ptr] "r" (a_ptr), \
+ [old2] "r" (a_oldval2) \
+ : "ip", "lr", "cc", "memory"); \
+ a_tmp; })
+#endif
+
+#define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
+ ({ __arm_link_error (); oldval; })
+
+#endif
diff --git a/libc/sysdeps/linux/arm/bits/fcntl.h b/libc/sysdeps/linux/arm/bits/fcntl.h
index 01d2d3d14..c6ba9588c 100644
--- a/libc/sysdeps/linux/arm/bits/fcntl.h
+++ b/libc/sysdeps/linux/arm/bits/fcntl.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FCNTL_H
# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
@@ -50,9 +49,8 @@
# define O_NOFOLLOW 0100000 /* Do not follow links. */
# define O_DIRECT 0200000 /* Direct disk access. */
# define O_NOATIME 01000000 /* Do not set atime. */
-# if 0
# define O_CLOEXEC 02000000 /* Set close_on_exec. */
-# endif
+# define O_PATH 010000000 /* Resolve pathname but do not open file. */
#endif
/* For now Linux has synchronisity options for data and read operations.
@@ -102,6 +100,8 @@
# define F_NOTIFY 1026 /* Request notfications on a directory. */
# define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with
close-on-exit set on new fd. */
+# define F_SETPIPE_SZ 1031 /* Set pipe page size array. */
+# define F_GETPIPE_SZ 1032 /* Get pipe page size array. */
#endif
/* For F_[GET|SET]FD. */
@@ -189,7 +189,7 @@ struct flock64
#endif
-#ifdef __USE_GNU
+#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
@@ -212,7 +212,7 @@ struct flock64
__BEGIN_DECLS
-#ifdef __USE_GNU
+#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)
diff --git a/libc/sysdeps/linux/arm/bits/fenv.h b/libc/sysdeps/linux/arm/bits/fenv.h
index 3764d7749..106bf36c2 100644
--- a/libc/sysdeps/linux/arm/bits/fenv.h
+++ b/libc/sysdeps/linux/arm/bits/fenv.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FENV_H
# error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
diff --git a/libc/sysdeps/linux/arm/bits/huge_val.h b/libc/sysdeps/linux/arm/bits/huge_val.h
index a215f3c0b..a8b85b3ba 100644
--- a/libc/sysdeps/linux/arm/bits/huge_val.h
+++ b/libc/sysdeps/linux/arm/bits/huge_val.h
@@ -16,9 +16,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _MATH_H
# error "Never use <bits/huge_val.h> directly; include <math.h> instead."
@@ -32,7 +31,7 @@
# define HUGE_VAL (__extension__ 0x1.0p2047)
#elif defined __GNUC__
-#ifndef __CONFIG_ARM_EABI__
+#ifndef __ARM_EABI__
# define HUGE_VAL \
(__extension__ \
((union { unsigned __l __attribute__((__mode__(__DI__))); double __d; }) \
@@ -50,7 +49,7 @@
typedef union { unsigned char __c[8]; double __d; } __huge_val_t;
-#ifndef __CONFIG_ARM_EABI__
+#ifndef __ARM_EABI__
# if __BYTE_ORDER == __BIG_ENDIAN
# define __HUGE_VAL_bytes { 0, 0, 0, 0, 0x7f, 0xf0, 0, 0 }
# endif
diff --git a/libc/sysdeps/linux/arm/bits/kernel_stat.h b/libc/sysdeps/linux/arm/bits/kernel_stat.h
index ebac6f5ff..7bd89f9ab 100644
--- a/libc/sysdeps/linux/arm/bits/kernel_stat.h
+++ b/libc/sysdeps/linux/arm/bits/kernel_stat.h
@@ -1,16 +1,10 @@
#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... */
-#define STAT_HAVE_NSEC 1
-
struct kernel_stat {
#if defined(__ARMEB__)
unsigned short st_dev;
@@ -18,7 +12,7 @@ struct kernel_stat {
#else
unsigned long st_dev;
#endif
- unsigned long st_ino;
+ unsigned long st_ino;
unsigned short st_mode;
unsigned short st_nlink;
unsigned short st_uid;
@@ -32,12 +26,9 @@ struct kernel_stat {
unsigned long st_size;
unsigned long st_blksize;
unsigned long st_blocks;
- unsigned long st_atime;
- unsigned long st_atime_nsec;
- unsigned long st_mtime;
- unsigned long st_mtime_nsec;
- unsigned long st_ctime;
- unsigned long st_ctime_nsec;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
unsigned long __unused4;
unsigned long __unused5;
};
@@ -60,12 +51,9 @@ struct kernel_stat64 {
unsigned long st_blksize;
unsigned long long st_blocks; /* Number 512-byte blocks allocated. */
- unsigned long st_atime;
- unsigned long st_atime_nsec;
- unsigned long st_mtime;
- unsigned long st_mtime_nsec;
- unsigned long st_ctime;
- unsigned long st_ctime_nsec;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
unsigned long long st_ino;
#ifndef __ARM_EABI__
} __attribute__((packed));
diff --git a/libc/sysdeps/linux/arm/bits/kernel_types.h b/libc/sysdeps/linux/arm/bits/kernel_types.h
index 766a30621..6b36f3263 100644
--- a/libc/sysdeps/linux/arm/bits/kernel_types.h
+++ b/libc/sysdeps/linux/arm/bits/kernel_types.h
@@ -32,6 +32,8 @@ typedef unsigned short __kernel_old_uid_t;
typedef unsigned short __kernel_old_gid_t;
typedef long long __kernel_loff_t;
typedef __kernel_dev_t __kernel_old_dev_t;
+typedef long __kernel_long_t;
+typedef unsigned long __kernel_ulong_t;
typedef struct {
#ifdef __USE_ALL
diff --git a/libc/sysdeps/linux/arm/bits/mathdef.h b/libc/sysdeps/linux/arm/bits/mathdef.h
index e013e74b7..478ceed15 100644
--- a/libc/sysdeps/linux/arm/bits/mathdef.h
+++ b/libc/sysdeps/linux/arm/bits/mathdef.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#if !defined _MATH_H && !defined _COMPLEX_H
# error "Never use <bits/mathdef.h> directly; include <math.h> instead"
diff --git a/libc/sysdeps/linux/arm/bits/setjmp.h b/libc/sysdeps/linux/arm/bits/setjmp.h
index ac52f1281..aa71ba706 100644
--- a/libc/sysdeps/linux/arm/bits/setjmp.h
+++ b/libc/sysdeps/linux/arm/bits/setjmp.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1997,1998,2005,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
@@ -12,19 +12,18 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* Define the machine-dependent type `jmp_buf'. ARM version. */
+
#ifndef _BITS_SETJMP_H
-#define _BITS_SETJMP_H 1
+#define _BITS_SETJMP_H 1
#if !defined _SETJMP_H && !defined _PTHREAD_H
# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
#endif
-#ifndef _ASM
/* Jump buffer contains v1-v6, sl, fp, sp and pc. Other registers are not
saved. */
#ifdef __ARM_EABI__
@@ -38,15 +37,10 @@ typedef int __jmp_buf[64] __attribute__((aligned (8)));
#elif defined __MAVERICK__ || defined __IWMMXT__
typedef int __jmp_buf[34];
#else
+# ifdef __UCLIBC_HAS_FPU__
typedef int __jmp_buf[22];
+# else
+typedef int __jmp_buf[10];
+# endif
#endif
#endif
-
-#define __JMP_BUF_SP 8
-
-/* Test if longjmp to JMPBUF would unwind the frame
- containing a local variable at ADDRESS. */
-#define _JMPBUF_UNWINDS(jmpbuf, address) \
- ((void *) (address) < (void *) (jmpbuf[__JMP_BUF_SP]))
-
-#endif /* bits/setjmp.h */
diff --git a/libc/sysdeps/linux/arm/bits/shm.h b/libc/sysdeps/linux/arm/bits/shm.h
index c89c00a17..2708c58ff 100644
--- a/libc/sysdeps/linux/arm/bits/shm.h
+++ b/libc/sysdeps/linux/arm/bits/shm.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_SHM_H
# error "Never include <bits/shm.h> directly; use <sys/shm.h> instead."
diff --git a/libc/sysdeps/linux/arm/bits/sigcontextinfo.h b/libc/sysdeps/linux/arm/bits/sigcontextinfo.h
index 67167f90f..268f0a3f3 100644
--- a/libc/sysdeps/linux/arm/bits/sigcontextinfo.h
+++ b/libc/sysdeps/linux/arm/bits/sigcontextinfo.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <bits/armsigctx.h>
#include <linux/version.h>
diff --git a/libc/sysdeps/linux/arm/bits/stackinfo.h b/libc/sysdeps/linux/arm/bits/stackinfo.h
index 2410ba9bd..f4f0bb1cf 100644
--- a/libc/sysdeps/linux/arm/bits/stackinfo.h
+++ b/libc/sysdeps/linux/arm/bits/stackinfo.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* This file contains a bit of information about the stack allocation
of the processor. */
diff --git a/libc/sysdeps/linux/arm/bits/syscalls.h b/libc/sysdeps/linux/arm/bits/syscalls.h
index 2d2e0f0a4..e447a7b2d 100644
--- a/libc/sysdeps/linux/arm/bits/syscalls.h
+++ b/libc/sysdeps/linux/arm/bits/syscalls.h
@@ -9,8 +9,6 @@
glibc-2.3.2/sysdeps/unix/sysv/linux/arm/sysdep.h
*/
-#define SYS_ify(syscall_name) (__NR_##syscall_name)
-
#ifdef __ASSEMBLER__
/* Call a given syscall, with arguments loaded. For EABI, we must
@@ -32,172 +30,103 @@
#include <errno.h>
-#undef _syscall0
-#define _syscall0(type,name) \
-type name(void) \
-{ \
-return (type) (INLINE_SYSCALL(name, 0)); \
-}
-
-#undef _syscall1
-#define _syscall1(type,name,type1,arg1) \
-type name(type1 arg1) \
-{ \
-return (type) (INLINE_SYSCALL(name, 1, arg1)); \
-}
-
-#undef _syscall2
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name(type1 arg1,type2 arg2) \
-{ \
-return (type) (INLINE_SYSCALL(name, 2, arg1, arg2)); \
-}
-
-#undef _syscall3
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name(type1 arg1,type2 arg2,type3 arg3) \
-{ \
-return (type) (INLINE_SYSCALL(name, 3, arg1, arg2, arg3)); \
-}
-
-#undef _syscall4
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
-{ \
-return (type) (INLINE_SYSCALL(name, 4, arg1, arg2, arg3, arg4)); \
-}
-
-#undef _syscall5
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
- type5,arg5) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
-{ \
-return (type) (INLINE_SYSCALL(name, 5, arg1, arg2, arg3, arg4, arg5)); \
-}
-
-#undef _syscall6
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
- type5,arg5,type6,arg6) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, type6 arg6) \
-{ \
-return (type) (INLINE_SYSCALL(name, 6, arg1, arg2, arg3, arg4, arg5, arg6)); \
-}
-
-#undef _syscall7
-#define _syscall7(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
- type5,arg5,type6,arg6,type7,arg7) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, type6 arg6,type7 arg7) \
-{ \
-return (type) (INLINE_SYSCALL(name, 7, arg1, arg2, arg3, arg4, arg5, arg6, arg7)); \
-}
-
-
-#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)) \
+#define INLINE_SYSCALL_NCS(name, nr, args...) \
+(__extension__ \
+ ({ \
+ unsigned int _inline_sys_result = INTERNAL_SYSCALL_NCS (name, , nr, args);\
+ if (unlikely (INTERNAL_SYSCALL_ERROR_P (_inline_sys_result, ))) \
{ \
- __set_errno (INTERNAL_SYSCALL_ERRNO (_inline_sys_result, )); \
- _inline_sys_result = (unsigned int) -1; \
+ __set_errno (INTERNAL_SYSCALL_ERRNO (_inline_sys_result, )); \
+ _inline_sys_result = (unsigned int) -1; \
} \
- (int) _inline_sys_result; })
-
-#undef INTERNAL_SYSCALL_DECL
-#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
+ (int) _inline_sys_result; \
+ }) \
+)
-#undef INTERNAL_SYSCALL
-#if !defined(__thumb__)
-#if defined(__ARM_EABI__)
-#define INTERNAL_SYSCALL(name, err, nr, args...) \
- ({unsigned int __sys_result; \
- { \
- register int _a1 __asm__ ("r0"), _nr __asm__ ("r7"); \
- LOAD_ARGS_##nr (args) \
- _nr = SYS_ify(name); \
- __asm__ __volatile__ ("swi 0x0 @ syscall " #name \
- : "=r" (_a1) \
- : "r" (_nr) ASM_ARGS_##nr \
- : "memory"); \
- __sys_result = _a1; \
- } \
- (int) __sys_result; })
-#else /* defined(__ARM_EABI__) */
-
-#define INTERNAL_SYSCALL(name, err, nr, args...) \
- ({ unsigned int __sys_result; \
- { \
- register int _a1 __asm__ ("a1"); \
- LOAD_ARGS_##nr (args) \
- __asm__ __volatile__ ("swi %1 @ syscall " #name \
- : "=r" (_a1) \
- : "i" (SYS_ify(name)) ASM_ARGS_##nr \
- : "memory"); \
- __sys_result = _a1; \
- } \
- (int) __sys_result; })
-#endif
-#else /* !defined(__thumb__) */
+#if defined(__thumb__)
/* We can't use push/pop inside the asm because that breaks
unwinding (ie. thread cancellation).
*/
-#define INTERNAL_SYSCALL(name, err, nr, args...) \
- ({ unsigned int __sys_result; \
+#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+(__extension__ \
+ ({ unsigned int __internal_sys_result; \
{ \
int _sys_buf[2]; \
- register int _a1 __asm__ ("a1"); \
- register int *_v3 __asm__ ("v3") = _sys_buf; \
- *_v3 = (int) (SYS_ify(name)); \
+ register int __a1 __asm__ ("a1"); \
+ register int *__v3 __asm__ ("v3") = _sys_buf; \
+ *__v3 = (int) (name); \
LOAD_ARGS_##nr (args) \
__asm__ __volatile__ ("str r7, [v3, #4]\n" \
"\tldr r7, [v3]\n" \
"\tswi 0 @ syscall " #name "\n" \
"\tldr r7, [v3, #4]" \
- : "=r" (_a1) \
- : "r" (_v3) ASM_ARGS_##nr \
+ : "=r" (__a1) \
+ : "r" (__v3) ASM_ARGS_##nr \
: "memory"); \
- __sys_result = _a1; \
+ __internal_sys_result = __a1; \
} \
- (int) __sys_result; })
-#endif /*!defined(__thumb__)*/
+ (int) __internal_sys_result; }) \
+)
+#else /* ARM */
+#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+(__extension__ \
+ ({unsigned int __internal_sys_result; \
+ { \
+ register int __a1 __asm__ ("r0"), _nr __asm__ ("r7"); \
+ LOAD_ARGS_##nr (args) \
+ _nr = (name); \
+ __asm__ __volatile__ ("swi 0x0 @ syscall " #name \
+ : "=r" (__a1) \
+ : "r" (_nr) ASM_ARGS_##nr \
+ : "memory"); \
+ __internal_sys_result = __a1; \
+ } \
+ (int) __internal_sys_result; }) \
+)
+#endif
-#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))
-
#define LOAD_ARGS_0()
#define ASM_ARGS_0
#define LOAD_ARGS_1(a1) \
- _a1 = (int) (a1); \
- LOAD_ARGS_0 ()
-#define ASM_ARGS_1 ASM_ARGS_0, "r" (_a1)
+ int __a1tmp = (int) (a1); \
+ LOAD_ARGS_0 () \
+ __a1 = __a1tmp;
+#define ASM_ARGS_1 ASM_ARGS_0, "r" (__a1)
#define LOAD_ARGS_2(a1, a2) \
- register int _a2 __asm__ ("a2") = (int) (a2); \
- LOAD_ARGS_1 (a1)
-#define ASM_ARGS_2 ASM_ARGS_1, "r" (_a2)
+ int __a2tmp = (int) (a2); \
+ LOAD_ARGS_1 (a1) \
+ register int __a2 __asm__ ("a2") = __a2tmp;
+#define ASM_ARGS_2 ASM_ARGS_1, "r" (__a2)
#define LOAD_ARGS_3(a1, a2, a3) \
- register int _a3 __asm__ ("a3") = (int) (a3); \
- LOAD_ARGS_2 (a1, a2)
-#define ASM_ARGS_3 ASM_ARGS_2, "r" (_a3)
+ int __a3tmp = (int) (a3); \
+ LOAD_ARGS_2 (a1, a2) \
+ register int __a3 __asm__ ("a3") = __a3tmp;
+#define ASM_ARGS_3 ASM_ARGS_2, "r" (__a3)
#define LOAD_ARGS_4(a1, a2, a3, a4) \
- register int _a4 __asm__ ("a4") = (int) (a4); \
- LOAD_ARGS_3 (a1, a2, a3)
-#define ASM_ARGS_4 ASM_ARGS_3, "r" (_a4)
+ int __a4tmp = (int) (a4); \
+ LOAD_ARGS_3 (a1, a2, a3) \
+ register int __a4 __asm__ ("a4") = __a4tmp;
+#define ASM_ARGS_4 ASM_ARGS_3, "r" (__a4)
#define LOAD_ARGS_5(a1, a2, a3, a4, a5) \
- register int _v1 __asm__ ("v1") = (int) (a5); \
- LOAD_ARGS_4 (a1, a2, a3, a4)
-#define ASM_ARGS_5 ASM_ARGS_4, "r" (_v1)
+ int __v1tmp = (int) (a5); \
+ LOAD_ARGS_4 (a1, a2, a3, a4) \
+ register int __v1 __asm__ ("v1") = __v1tmp;
+#define ASM_ARGS_5 ASM_ARGS_4, "r" (__v1)
#define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6) \
- register int _v2 __asm__ ("v2") = (int) (a6); \
- LOAD_ARGS_5 (a1, a2, a3, a4, a5)
-#define ASM_ARGS_6 ASM_ARGS_5, "r" (_v2)
+ int __v2tmp = (int) (a6); \
+ LOAD_ARGS_5 (a1, a2, a3, a4, a5) \
+ register int __v2 __asm__ ("v2") = __v2tmp;
+#define ASM_ARGS_6 ASM_ARGS_5, "r" (__v2)
+#ifndef __thumb__
#define LOAD_ARGS_7(a1, a2, a3, a4, a5, a6, a7) \
- register int _v3 __asm__ ("v3") = (int) (a7); \
- LOAD_ARGS_6 (a1, a2, a3, a4, a5, a6)
-#define ASM_ARGS_7 ASM_ARGS_6, "r" (_v3)
-
+ int __v3tmp = (int) (a7); \
+ LOAD_ARGS_6 (a1, a2, a3, a4, a5, a6) \
+ register int __v3 __asm__ ("v3") = __v3tmp;
+#define ASM_ARGS_7 ASM_ARGS_6, "r" (__v3)
+#endif
#endif /* __ASSEMBLER__ */
#endif /* _BITS_SYSCALLS_H */
diff --git a/libc/sysdeps/linux/arm/bits/uClibc_arch_features.h b/libc/sysdeps/linux/arm/bits/uClibc_arch_features.h
index 85c9adb8a..671afd3ac 100644
--- a/libc/sysdeps/linux/arm/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/arm/bits/uClibc_arch_features.h
@@ -11,28 +11,72 @@
/* can your target use syscall6() for mmap ? */
#undef __UCLIBC_MMAP_HAS_6_ARGS__
-/* does your target use syscall4() for truncate64 ? (32bit arches only) */
-#undef __UCLIBC_TRUNCATE64_HAS_4_ARGS__
+/* does your target align 64bit values in register pairs ? (32bit arches only) */
+#ifdef __ARM_EABI__
+#define __UCLIBC_SYSCALL_ALIGN_64BIT__
+#else
+#undef __UCLIBC_SYSCALL_ALIGN_64BIT__
+#endif
/* does your target have a broken create_module() ? */
#define __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 */
+#undef __UCLIBC_ASM_LINE_SEP__
+
+
+/* The __ARM_ARCH define is provided by gcc 4.8. Construct it otherwise. */
+#ifndef __ARM_ARCH
+# ifdef __ARM_ARCH_2__
+# define __ARM_ARCH 2
+# elif defined (__ARM_ARCH_3__) || defined (__ARM_ARCH_3M__)
+# define __ARM_ARCH 3
+# elif defined (__ARM_ARCH_4__) || defined (__ARM_ARCH_4T__)
+# define __ARM_ARCH 4
+# elif defined (__ARM_ARCH_5__) || defined (__ARM_ARCH_5E__) \
+ || defined(__ARM_ARCH_5T__) || defined(__ARM_ARCH_5TE__) \
+ || defined(__ARM_ARCH_5TEJ__)
+# define __ARM_ARCH 5
+# elif defined (__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \
+ || defined (__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) \
+ || defined (__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__)
+# define __ARM_ARCH 6
+# elif defined (__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \
+ || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) \
+ || defined(__ARM_ARCH_7EM__)
+# define __ARM_ARCH 7
+# else
+# error unknown arm architecture
+# endif
+#endif
+
+#ifdef __GNUC__
+# define __need_uClibc_config_h
+# include <bits/uClibc_config.h>
+# undef __need_uClibc_config_h
+# if defined __CONFIG_ARM_EABI__ && !defined __ARM_EABI__
+# error Your toolchain does not support EABI
+# elif !defined __CONFIG_ARM_EABI__ && defined __ARM_EABI__
+# error Your toolchain was built for EABI, but you have chosen OABI
+# endif
+#endif
+
#endif /* _BITS_UCLIBC_ARCH_FEATURES_H */
diff --git a/libc/sysdeps/linux/arm/bits/wordsize.h b/libc/sysdeps/linux/arm/bits/wordsize.h
index ba643b60a..ca82fd7d4 100644
--- a/libc/sysdeps/linux/arm/bits/wordsize.h
+++ b/libc/sysdeps/linux/arm/bits/wordsize.h
@@ -12,8 +12,7 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#define __WORDSIZE 32
diff --git a/libc/sysdeps/linux/arm/brk.c b/libc/sysdeps/linux/arm/brk.c
index 47179901f..0d04eb4dd 100644
--- a/libc/sysdeps/linux/arm/brk.c
+++ b/libc/sysdeps/linux/arm/brk.c
@@ -13,15 +13,13 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <errno.h>
#include <unistd.h>
#include <sys/syscall.h>
-libc_hidden_proto(brk)
/* This must be initialized data because commons can't have aliases. */
void *__curbrk attribute_hidden = 0;
diff --git a/libc/sysdeps/linux/arm/bsd-_setjmp.S b/libc/sysdeps/linux/arm/bsd-_setjmp.S
index a05570df7..0320bb82c 100644
--- a/libc/sysdeps/linux/arm/bsd-_setjmp.S
+++ b/libc/sysdeps/linux/arm/bsd-_setjmp.S
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <bits/arm_asm.h>
diff --git a/libc/sysdeps/linux/arm/bsd-setjmp.S b/libc/sysdeps/linux/arm/bsd-setjmp.S
index d7ca72ad5..f37110e36 100644
--- a/libc/sysdeps/linux/arm/bsd-setjmp.S
+++ b/libc/sysdeps/linux/arm/bsd-setjmp.S
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <bits/arm_asm.h>
diff --git a/libc/sysdeps/linux/arm/clone.S b/libc/sysdeps/linux/arm/clone.S
index d9483735d..b4c7d8a02 100644
--- a/libc/sysdeps/linux/arm/clone.S
+++ b/libc/sysdeps/linux/arm/clone.S
@@ -13,29 +13,37 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* clone() is even more special than fork() as it mucks with stacks
and invokes a function in the right context after its all over. */
+#include <sysdep.h>
#define _ERRNO_H
#include <features.h>
#include <bits/errno.h>
#include <sys/syscall.h>
#include <bits/arm_asm.h>
+#include <bits/arm_bx.h>
+
+#if defined __UCLIBC_HAS_THREADS__ && !defined __LINUXTHREADS_OLD__
+#include <sysdep-cancel.h>
+#endif
+
+#define CLONE_VM 0x00000100
+#define CLONE_THREAD 0x00010000
#if defined(__NR_clone)
/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */
.text
-.global clone
-.type clone,%function
+.global __clone
+.type __clone,%function
.align 2
#if defined(THUMB1_ONLY)
.thumb_func
-clone:
+__clone:
@ sanity check args
cmp r0, #0
beq __einval
@@ -61,8 +69,13 @@ clone:
@ pick the function arg and call address off the stack and execute
ldr r0, [sp, #4]
+#if defined(__USE_BX__)
ldr r1, [sp]
bl 2f @ blx r1
+#else
+ mov lr, pc
+ ldr pc, [sp]
+#endif
@ and we are done, passing the return value through r0
bl HIDDEN_JUMPTARGET(_exit)
@@ -80,7 +93,9 @@ __error:
POP_RET
.pool
#else
-clone:
+__clone:
+.fnstart
+.cantunwind
@ sanity check args
cmp r0, #0
IT(te, ne)
@@ -89,25 +104,55 @@ clone:
beq __error
@ insert the args onto the new stack
- sub r1, r1, #8
- str r3, [r1, #4]
- @ save the function pointer as the 0th element
- str r0, [r1]
+ str r3, [r1, #-4]!
+ str r0, [r1, #-4]!
@ do the system call
@ get flags
mov r0, r2
+#ifdef RESET_PID
+ mov ip, r2
+#endif
@ new sp is already in r1
- DO_CALL (clone)
- movs a1, a1
+ push {r4, r7}
+ cfi_adjust_cfa_offset (8)
+ cfi_rel_offset (r4, 0)
+ cfi_rel_offset (r7, 4)
+ ldr r2, [sp, #8]
+ ldr r3, [sp, #12]
+ ldr r4, [sp, #16]
+ ldr r7, =SYS_ify(clone)
+ swi 0x0
+ cfi_endproc
+ cmp r0, #0
+ beq 1f
+ pop {r4, r7}
blt __error
IT(t, ne)
-#if defined(__USE_BX__)
- bxne lr
-#else
- movne pc, lr
-#endif
+ BXC(ne, lr)
+
+ cfi_startproc
+.fnend
+PSEUDO_END (__clone)
+1:
+ .fnstart
+ .cantunwind
+#ifdef RESET_PID
+ tst ip, #CLONE_THREAD
+ bne 3f
+ GET_TLS (lr)
+ mov r1, r0
+ tst ip, #CLONE_VM
+ ldr r7, =SYS_ify(getpid)
+ ite ne
+ movne r0, #-1
+ swieq 0x0
+ NEGOFF_ADJ_BASE (r1, TID_OFFSET)
+ str r0, NEGOFF_OFF1 (r1, TID_OFFSET)
+ str r0, NEGOFF_OFF2 (r1, PID_OFFSET, TID_OFFSET)
+3:
+#endif
@ pick the function arg and call address off the stack and execute
ldr r0, [sp, #4]
mov lr, pc
@@ -120,6 +165,7 @@ __error:
b __syscall_error
#endif
-.size clone,.-clone
+.size __clone,.-__clone
+weak_alias(__clone, clone)
#endif
diff --git a/libc/sysdeps/linux/arm/crt1.S b/libc/sysdeps/linux/arm/crt1.S
index 082348e39..ab3b0d293 100644
--- a/libc/sysdeps/linux/arm/crt1.S
+++ b/libc/sysdeps/linux/arm/crt1.S
@@ -31,9 +31,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* This is the canonical entry point, usually the first thing in the text
segment.
@@ -133,7 +132,6 @@ _start:
#ifdef __PIC__
ldr r4, .L_GOT
-.L_GOT_OFF:
adr r5, .L_GOT
add r4, r5, r4
@@ -201,8 +199,8 @@ _start:
#ifdef __PIC__
ldr sl, .L_GOT
-.L_GOT_OFF:
- add sl, pc, sl
+ adr a4, .L_GOT
+ add sl, sl, a4
ldr ip, .L_GOT+4 /* _fini */
ldr a1, [sl, ip]
@@ -238,7 +236,7 @@ _start:
#ifdef __PIC__
.L_GOT:
- .word _GLOBAL_OFFSET_TABLE_-(.L_GOT_OFF+8)
+ .word _GLOBAL_OFFSET_TABLE_ - .L_GOT
.word _fini(GOT)
.word _init(GOT)
.word main(GOT)
diff --git a/libc/sysdeps/linux/arm/crtn.S b/libc/sysdeps/linux/arm/crtn.S
index de01b38dc..a4752c186 100644
--- a/libc/sysdeps/linux/arm/crtn.S
+++ b/libc/sysdeps/linux/arm/crtn.S
@@ -15,7 +15,6 @@
.arm
ldmdb fp, {r4, r5, r6, r7, r8, r9, sl, fp, sp, pc}
#endif
- .size _init, .-_init
.section .fini
.global _fini
@@ -29,7 +28,6 @@
.arm
ldmdb fp, {r4, r5, r6, r7, r8, r9, sl, fp, sp, pc}
#endif
- .size _fini, .-_fini
@ In fact this is modified to 3.4.4
.ident "GCC: (GNU) 3.3.2 20031005 (Debian prerelease)"
diff --git a/libc/sysdeps/linux/arm/find_exidx.c b/libc/sysdeps/linux/arm/find_exidx.c
index 9e4f4012f..679d90c05 100644
--- a/libc/sysdeps/linux/arm/find_exidx.c
+++ b/libc/sysdeps/linux/arm/find_exidx.c
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <link.h>
#include <unwind.h>
@@ -65,8 +64,8 @@ find_exidx_callback (struct dl_phdr_info * info, size_t size, void * ptr)
/* Find the exception index table containing PC. */
-_Unwind_Ptr
-__gnu_Unwind_Find_exidx (_Unwind_Ptr pc, int * pcount)
+_Unwind_Ptr __gnu_Unwind_Find_exidx (_Unwind_Ptr pc, int * pcount);
+_Unwind_Ptr __gnu_Unwind_Find_exidx (_Unwind_Ptr pc, int * pcount)
{
struct unw_eh_callback_data data;
diff --git a/libc/sysdeps/linux/arm/fpu_control.h b/libc/sysdeps/linux/arm/fpu_control.h
index 1170c9e97..1b9b09df6 100644
--- a/libc/sysdeps/linux/arm/fpu_control.h
+++ b/libc/sysdeps/linux/arm/fpu_control.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FPU_CONTROL_H
#define _FPU_CONTROL_H
diff --git a/libc/sysdeps/linux/arm/getcontext.S b/libc/sysdeps/linux/arm/getcontext.S
new file mode 100644
index 000000000..a987c52f3
--- /dev/null
+++ b/libc/sysdeps/linux/arm/getcontext.S
@@ -0,0 +1,80 @@
+/* Copyright (C) 2012 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+
+#include "ucontext_i.h"
+
+ .syntax unified
+ .text
+
+/* int getcontext (ucontext_t *ucp) */
+
+ENTRY(__getcontext)
+ /* No need to save r0-r3, d0-d7, or d16-d31. */
+ add r1, r0, #MCONTEXT_ARM_R4
+ stmia r1, {r4-r11}
+
+ /* Save R13 separately as Thumb can't STM it. */
+ str r13, [r0, #MCONTEXT_ARM_SP]
+ str r14, [r0, #MCONTEXT_ARM_LR]
+ /* Return to LR */
+ str r14, [r0, #MCONTEXT_ARM_PC]
+ /* Return zero */
+ mov r2, #0
+ str r2, [r0, #MCONTEXT_ARM_R0]
+
+ /* Save ucontext_t * across the next call. */
+ mov r4, r0
+
+ /* __sigprocmask(SIG_BLOCK, NULL, &(ucontext->uc_sigmask)) */
+ mov r0, #SIG_BLOCK
+ mov r1, #0
+ add r2, r4, #UCONTEXT_SIGMASK
+ bl PLTJMP(sigprocmask)
+
+#if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__
+# ifdef __VFP_FP__
+ /* Store the VFP registers. */
+ /* Following instruction is fstmiax ip!, {d8-d15}. */
+ stc p11, cr8, [r0], #64
+ /* Store the floating-point status register. */
+ /* Following instruction is fmrx r2, fpscr. */
+ mrc p10, 7, r1, cr1, cr0, 0
+ str r1, [r0], #4
+# endif
+#endif
+#ifdef __IWMMXT__
+ /* Save the call-preserved iWMMXt registers. */
+ /* Following instructions are wstrd wr10, [r0], #8 (etc.) */
+ stcl p1, cr10, [r0], #8
+ stcl p1, cr11, [r0], #8
+ stcl p1, cr12, [r0], #8
+ stcl p1, cr13, [r0], #8
+ stcl p1, cr14, [r0], #8
+ stcl p1, cr15, [r0], #8
+#endif
+
+ /* Restore the clobbered R4 and LR. */
+ ldr r14, [r4, #MCONTEXT_ARM_LR]
+ ldr r4, [r4, #MCONTEXT_ARM_R4]
+
+ mov r0, #0
+ DO_RET(r14)
+
+END(__getcontext)
+weak_alias(__getcontext, getcontext)
diff --git a/libc/sysdeps/linux/arm/ioperm.c b/libc/sysdeps/linux/arm/ioperm.c
index 708e8ec49..d7ea52695 100644
--- a/libc/sysdeps/linux/arm/ioperm.c
+++ b/libc/sysdeps/linux/arm/ioperm.c
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* I/O port access on the ARM is something of a fiction. What we do is to
map an appropriate area of /dev/mem into user space so that a program
@@ -33,33 +32,16 @@
the area affected (this is a kernel limitation). So we now just
enable all the ports all of the time. */
+#include <sys/io.h>
+#include <sys/mman.h>
+#include <sys/sysctl.h>
+#include <paths.h>
#include <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
#include <ctype.h>
-#include <stdlib.h>
+#include <stdio.h>
#include <string.h>
#include <unistd.h>
-
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <sys/sysctl.h>
-#include <sys/io.h>
-
-libc_hidden_proto(ioperm)
-
-libc_hidden_proto(readlink)
-libc_hidden_proto(mmap)
-libc_hidden_proto(sscanf)
-libc_hidden_proto(fscanf)
-libc_hidden_proto(fprintf)
-libc_hidden_proto(fgets)
-libc_hidden_proto(fopen)
-libc_hidden_proto(fclose)
-/* Experimentally off - libc_hidden_proto(strcmp) */
-libc_hidden_proto(open)
-libc_hidden_proto(close)
-
+#include <fcntl.h>
#include <linux/version.h>
#define PATH_ARM_SYSTYPE "/etc/arm_systype"
@@ -198,7 +180,7 @@ int ioperm (unsigned long int from, unsigned long int num, int turn_on)
if (! io.base) {
int fd;
- fd = open ("/dev/mem", O_RDWR);
+ fd = open (_PATH_MEM, O_RDWR);
if (fd < 0)
return -1;
diff --git a/libc/sysdeps/linux/arm/iopl.c b/libc/sysdeps/linux/arm/iopl.c
index 654a4158f..005f2f403 100644
--- a/libc/sysdeps/linux/arm/iopl.c
+++ b/libc/sysdeps/linux/arm/iopl.c
@@ -14,14 +14,12 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <sys/io.h>
#include <errno.h>
-libc_hidden_proto(ioperm)
#define MAX_PORT 0x10000
diff --git a/libc/sysdeps/linux/arm/jmpbuf-offsets.h b/libc/sysdeps/linux/arm/jmpbuf-offsets.h
new file mode 100644
index 000000000..93b50afc5
--- /dev/null
+++ b/libc/sysdeps/linux/arm/jmpbuf-offsets.h
@@ -0,0 +1,19 @@
+/* Private macros for accessing __jmp_buf contents. ARM version.
+ Copyright (C) 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#define __JMP_BUF_SP 8
diff --git a/libc/sysdeps/linux/arm/jmpbuf-unwind.h b/libc/sysdeps/linux/arm/jmpbuf-unwind.h
new file mode 100644
index 000000000..d7b49e224
--- /dev/null
+++ b/libc/sysdeps/linux/arm/jmpbuf-unwind.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+#include <setjmp.h>
+#include <jmpbuf-offsets.h>
+
+/* Test if longjmp to JMPBUF would unwind the frame
+ containing a local variable at ADDRESS. */
+#define _JMPBUF_UNWINDS(jmpbuf, address) \
+ ((void *) (address) < (void *) (jmpbuf[__JMP_BUF_SP]))
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <stdint.h>
+#include <unwind.h>
+
+/* Test if longjmp to JMPBUF would unwind the frame
+ containing a local variable at ADDRESS. */
+#undef _JMPBUF_UNWINDS
+#define _JMPBUF_UNWINDS(jmpbuf, address, demangle) \
+ ((void *) (address) < (void *) demangle (jmpbuf[__JMP_BUF_SP]))
+
+#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
+ _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
+
+#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
+ ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[__JMP_BUF_SP] - (_adj))
+#endif
diff --git a/libc/sysdeps/linux/arm/libc-aeabi_read_tp.S b/libc/sysdeps/linux/arm/libc-aeabi_read_tp.S
new file mode 100644
index 000000000..3aa135bf2
--- /dev/null
+++ b/libc/sysdeps/linux/arm/libc-aeabi_read_tp.S
@@ -0,0 +1 @@
+#include <ldso/ldso/arm/aeabi_read_tp.S>
diff --git a/libc/sysdeps/linux/arm/libc-thumb_atomics.S b/libc/sysdeps/linux/arm/libc-thumb_atomics.S
new file mode 100644
index 000000000..e7bc8950d
--- /dev/null
+++ b/libc/sysdeps/linux/arm/libc-thumb_atomics.S
@@ -0,0 +1 @@
+#include <ldso/ldso/arm/thumb_atomics.S>
diff --git a/libc/sysdeps/linux/arm/makecontext.c b/libc/sysdeps/linux/arm/makecontext.c
new file mode 100644
index 000000000..d6ae6f0d7
--- /dev/null
+++ b/libc/sysdeps/linux/arm/makecontext.c
@@ -0,0 +1,73 @@
+/* Copyright (C) 2012 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <stdarg.h>
+#include <ucontext.h>
+
+/* Number of arguments that go in registers. */
+#define NREG_ARGS 4
+
+/* Take a context previously prepared via getcontext() and set to
+ call func() with the given int only args. */
+void
+__makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...)
+{
+ extern void __startcontext (void);
+ unsigned long *funcstack;
+ va_list vl;
+ unsigned long *regptr;
+ unsigned int reg;
+ int misaligned;
+
+ /* Start at the top of stack. */
+ funcstack = (unsigned long *) (ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size);
+
+ /* Ensure the stack stays eight byte aligned. */
+ misaligned = ((unsigned long) funcstack & 4) != 0;
+
+ if ((argc > NREG_ARGS) && (argc & 1) != 0)
+ misaligned = !misaligned;
+
+ if (misaligned)
+ funcstack -= 1;
+
+ va_start (vl, argc);
+
+ /* Reserve space for the on-stack arguments. */
+ if (argc > NREG_ARGS)
+ funcstack -= (argc - NREG_ARGS);
+
+ ucp->uc_mcontext.arm_sp = (unsigned long) funcstack;
+ ucp->uc_mcontext.arm_pc = (unsigned long) func;
+
+ /* Exit to startcontext() with the next context in R4 */
+ ucp->uc_mcontext.arm_r4 = (unsigned long) ucp->uc_link;
+ ucp->uc_mcontext.arm_lr = (unsigned long) __startcontext;
+
+ /* The first four arguments go into registers. */
+ regptr = &(ucp->uc_mcontext.arm_r0);
+
+ for (reg = 0; (reg < argc) && (reg < NREG_ARGS); reg++)
+ *regptr++ = va_arg (vl, unsigned long);
+
+ /* And the remainder on the stack. */
+ for (; reg < argc; reg++)
+ *funcstack++ = va_arg (vl, unsigned long);
+
+ va_end (vl);
+}
+weak_alias (__makecontext, makecontext)
diff --git a/libc/sysdeps/linux/arm/mmap.c b/libc/sysdeps/linux/arm/mmap.c
deleted file mode 100644
index 47a29f4ae..000000000
--- a/libc/sysdeps/linux/arm/mmap.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * _mmap() for uClibc
- *
- * Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org>
- *
- * GNU Library General Public License (LGPL) version 2 or later.
- */
-#include <errno.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <sys/syscall.h>
-
-#if defined (__NR_mmap) || defined (__NR_mmap2)
-
-libc_hidden_proto (mmap)
-#if defined (__UCLIBC_MMAP_HAS_6_ARGS__) && defined (__NR_mmap)
-#define __NR__mmap __NR_mmap
-static __inline__ _syscall6 (__ptr_t, _mmap, __ptr_t, addr, size_t, len,
- int, prot, int, flags, int, fd, __off_t, offset);
-__ptr_t mmap(__ptr_t addr, size_t len, int prot,
- int flags, int fd, __off_t offset)
-{
- return (__ptr_t) _mmap (addr, len, prot, flags,
- fd, offset);
-}
-
-#elif defined (__NR_mmap2)
-#define __NR__mmap __NR_mmap2
-
-#ifndef MMAP2_PAGE_SHIFT
-# define MMAP2_PAGE_SHIFT 12
-#endif
-
-static __inline__ _syscall6 (__ptr_t, _mmap, __ptr_t, addr, size_t, len,
- int, prot, int, flags, int, fd, __off_t, offset);
-__ptr_t mmap(__ptr_t addr, size_t len, int prot,
- int flags, int fd, __off_t offset)
-{
- /* check if offset is page aligned */
- if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1))
- {
- __set_errno(EINVAL);
- return MAP_FAILED;
- }
-#ifdef __USE_FILE_OFFSET64
- return (__ptr_t) _mmap (addr, len, prot, flags,
- fd, ((__u_quad_t) offset >> MMAP2_PAGE_SHIFT));
-#else
- return (__ptr_t) _mmap (addr, len, prot, flags,
- fd, ((__u_long) offset >> MMAP2_PAGE_SHIFT));
-#endif
-}
-#elif defined (__NR_mmap)
-# define __NR__mmap __NR_mmap
-static __inline__ _syscall1(__ptr_t, _mmap, unsigned long *, buffer);
-__ptr_t mmap(__ptr_t addr, size_t len, int prot,
- int flags, int fd, __off_t offset)
-{
- unsigned long buffer[6];
-
- buffer[0] = (unsigned long) addr;
- buffer[1] = (unsigned long) len;
- buffer[2] = (unsigned long) prot;
- buffer[3] = (unsigned long) flags;
- buffer[4] = (unsigned long) fd;
- buffer[5] = (unsigned long) offset;
- return (__ptr_t) _mmap(buffer);
-}
-#endif
-libc_hidden_def (mmap)
-#else
-# error "Your architecture doesn't seem to provide mmap() !?"
-#endif
diff --git a/libc/sysdeps/linux/arm/mmap64.S b/libc/sysdeps/linux/arm/mmap64.S
index 707154124..c9f2bd2f7 100644
--- a/libc/sysdeps/linux/arm/mmap64.S
+++ b/libc/sysdeps/linux/arm/mmap64.S
@@ -12,17 +12,17 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
-#include <features.h>
+#include <_lfs_64.h>
#define _ERRNO_H
#include <bits/errno.h>
#include <sys/syscall.h>
#include <bits/arm_asm.h>
+#include <bits/arm_bx.h>
-#if defined __UCLIBC_HAS_LFS__ && defined __NR_mmap2
+#ifdef __NR_mmap2
/* The mmap2 system call takes six arguments, all in registers. */
.text
@@ -92,11 +92,7 @@ mmap64:
cmn r0, $4096
ldmfd sp!, {r4, r5}
IT(t, cc)
-#if defined(__USE_BX__)
- bxcc lr
-#else
- movcc pc, lr
-#endif
+ BXC(cc, lr)
b __syscall_error
.Linval:
mov r0, $-EINVAL
diff --git a/libc/sysdeps/linux/arm/posix_fadvise.c b/libc/sysdeps/linux/arm/posix_fadvise.c
deleted file mode 100644
index bb4ac7b0c..000000000
--- a/libc/sysdeps/linux/arm/posix_fadvise.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * posix_fadvise() for ARM uClibc
- * http://www.opengroup.org/onlinepubs/009695399/functions/posix_fadvise.html
- *
- * 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 <fcntl.h>
-#if defined __NR_arm_fadvise64_64
-/* This is for the ARM version of fadvise64_64 which swaps the params
- * * about to avoid having ABI compat issues
- * */
-#define __NR___syscall_arm_fadvise64_64 __NR_arm_fadvise64_64
-int __libc_posix_fadvise(int fd, off_t offset, off_t len, int advise)
-{
- INTERNAL_SYSCALL_DECL (err);
- int ret = INTERNAL_SYSCALL (arm_fadvise64_64, err, 6, fd, advise,
- __LONG_LONG_PAIR ((long)(offset >> 32), (long)offset),
- __LONG_LONG_PAIR ((long)(len >> 32), (long)len));
-
- if (INTERNAL_SYSCALL_ERROR_P (ret, err))
- return INTERNAL_SYSCALL_ERRNO (ret, err);
- return 0;
-
-}
-weak_alias(__libc_posix_fadvise, posix_fadvise);
-#else
-int posix_fadvise(int fd attribute_unused, off_t offset attribute_unused, off_t len attribute_unused, int advice attribute_unused)
-{
- return ENOSYS;
-}
-#endif
-
diff --git a/libc/sysdeps/linux/arm/posix_fadvise64.c b/libc/sysdeps/linux/arm/posix_fadvise64.c
deleted file mode 100644
index 479b0c5a2..000000000
--- a/libc/sysdeps/linux/arm/posix_fadvise64.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * posix_fadvise64() for ARM uClibc
- * http://www.opengroup.org/onlinepubs/009695399/functions/posix_fadvise.html
- *
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-#include <features.h>
-#include <unistd.h>
-#include <errno.h>
-#include <endian.h>
-#include <stdint.h>
-#include <sys/types.h>
-#include <sys/syscall.h>
-#include <fcntl.h>
-
-#ifdef __UCLIBC_HAS_LFS__
-
-#if defined __NR_arm_fadvise64_64
-/* This is for the ARM version of fadvise64_64 which swaps the params
- * about to avoid having ABI compat issues
- */
-#define __NR___syscall_arm_fadvise64_64 __NR_arm_fadvise64_64
-int __libc_posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advise)
-{
- INTERNAL_SYSCALL_DECL (err);
- int ret = INTERNAL_SYSCALL (arm_fadvise64_64, err, 6, fd, advise,
- __LONG_LONG_PAIR ((long)(offset >> 32), (long)offset),
- __LONG_LONG_PAIR ((long)(len >> 32), (long)len));
- if (!INTERNAL_SYSCALL_ERROR_P (ret, err))
- return 0;
- if (INTERNAL_SYSCALL_ERRNO (ret, err) != ENOSYS)
- return INTERNAL_SYSCALL_ERRNO (ret, err);
- return 0;
-}
-weak_alias(__libc_posix_fadvise64, posix_fadvise64);
-#else
-int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advise)
-{
- return ENOSYS;
-}
-#endif
-#endif
diff --git a/libc/sysdeps/linux/arm/setcontext.S b/libc/sysdeps/linux/arm/setcontext.S
new file mode 100644
index 000000000..a5c33a022
--- /dev/null
+++ b/libc/sysdeps/linux/arm/setcontext.S
@@ -0,0 +1,76 @@
+/* Copyright (C) 2012 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+
+#include "ucontext_i.h"
+
+ .syntax unified
+ .text
+
+/* int setcontext (const ucontext_t *ucp) */
+
+ENTRY(__setcontext)
+ mov r4, r0
+
+#if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__
+# ifdef __VFP_FP__
+ /* Following instruction is vldmia r0!, {d8-d15}. */
+ ldc p11, cr8, [r0], #64
+ /* Restore the floating-point status register. */
+ ldr r1, [r0], #4
+ /* Following instruction is fmxr fpscr, r1. */
+ mcr p10, 7, r1, cr1, cr0, 0
+# endif
+#endif
+
+#ifdef __IWMMXT__
+ /* Restore the call-preserved iWMMXt registers. */
+ /* Following instructions are wldrd wr10, [r0], #8 (etc.) */
+ ldcl p1, cr10, [r0], #8
+ ldcl p1, cr11, [r0], #8
+ ldcl p1, cr12, [r0], #8
+ ldcl p1, cr13, [r0], #8
+ ldcl p1, cr14, [r0], #8
+ ldcl p1, cr15, [r0], #8
+#endif
+
+ /* Now bring back the signal status. */
+ mov r0, #SIG_SETMASK
+ add r1, r4, #UCONTEXT_SIGMASK
+ mov r2, #0
+ bl PLTJMP(sigprocmask)
+
+ /* Loading r0-r3 makes makecontext easier. */
+ add r14, r4, #MCONTEXT_ARM_R0
+ ldmia r14, {r0-r11}
+ ldr r13, [r14, #(MCONTEXT_ARM_SP - MCONTEXT_ARM_R0)]
+ add r14, r14, #(MCONTEXT_ARM_LR - MCONTEXT_ARM_R0)
+ ldmia r14, {r14, pc}
+
+END(setcontext)
+weak_alias(__setcontext, setcontext)
+
+ /* Called when a makecontext() context returns. Start the
+ context in R4 or fall through to exit(). */
+ENTRY(__startcontext)
+ movs r0, r4
+ bne PLTJMP(__setcontext)
+
+ @ New context was 0 - exit
+ b PLTJMP(_exit)
+END(__startcontext)
diff --git a/libc/sysdeps/linux/arm/setjmp.S b/libc/sysdeps/linux/arm/setjmp.S
index 2df7d551a..f7a74cc5a 100644
--- a/libc/sysdeps/linux/arm/setjmp.S
+++ b/libc/sysdeps/linux/arm/setjmp.S
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <features.h>
#include <bits/arm_asm.h>
@@ -47,7 +46,7 @@ __sigsetjmp:
mov ip, r0
#if defined(__thumb2__)
stmia ip!, {v1-v6, sl, fp}
- movs r2, sp
+ mov r2, sp
stmia ip!, {r2, lr}
#else
/* Save registers */
diff --git a/libc/sysdeps/linux/arm/sigaction.c b/libc/sysdeps/linux/arm/sigaction.c
index 552ac17bf..22d4248f3 100644
--- a/libc/sysdeps/linux/arm/sigaction.c
+++ b/libc/sysdeps/linux/arm/sigaction.c
@@ -12,9 +12,8 @@
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.
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>.
Totally hacked up for uClibc by Erik Andersen <andersen@codepoet.org>
*/
@@ -29,98 +28,76 @@
extern void __default_sa_restorer(void);
extern void __default_rt_sa_restorer(void);
-extern __typeof(sigaction) __libc_sigaction;
-
/* When RT signals are in use we need to use a different return stub. */
#ifdef __NR_rt_sigreturn
#define choose_restorer(flags) \
- (flags & SA_SIGINFO) ? __default_rt_sa_restorer \
- : __default_sa_restorer
+ (flags & SA_SIGINFO) ? __default_rt_sa_restorer \
+ : __default_sa_restorer
#else
#define choose_restorer(flags) \
- __default_sa_restorer
+ __default_sa_restorer
#endif
-#ifdef __NR_rt_sigaction
-/* Experimentally off - libc_hidden_proto(memcpy) */
+#ifdef __NR_rt_sigaction
/* 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 __libc_sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
{
- int result;
- struct kernel_sigaction kact, koact;
-
- if (act) {
- kact.k_sa_handler = act->sa_handler;
- memcpy (&kact.sa_mask, &act->sa_mask, sizeof (sigset_t));
- kact.sa_flags = act->sa_flags;
-# ifdef HAVE_SA_RESTORER
- if (kact.sa_flags & SA_RESTORER) {
- kact.sa_restorer = act->sa_restorer;
- } else {
- kact.sa_restorer = choose_restorer (kact.sa_flags);
- kact.sa_flags |= SA_RESTORER;
+ struct sigaction kact;
+ if (act && !(act->sa_flags & SA_RESTORER)) {
+ memcpy(&kact, act, sizeof(kact));
+ kact.sa_restorer = choose_restorer(kact.sa_flags);
+ kact.sa_flags |= SA_RESTORER;
+ act = &kact;
}
-# endif
- }
-
- /* 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 (sigset_t));
- oact->sa_flags = koact.sa_flags;
-# ifdef HAVE_SA_RESTORER
- oact->sa_restorer = koact.sa_restorer;
-# endif
- }
- return result;
+ /* NB: kernel (as of 2.6.25) will return EINVAL
+ * if sizeof(act->sa_mask) does not match kernel's sizeof(sigset_t) */
+ return __syscall_rt_sigaction(sig, act, oact, sizeof(act->sa_mask));
}
-
#else
/* 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 __libc_sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
{
- int result;
- struct old_kernel_sigaction kact, koact;
-
- if (act) {
- kact.k_sa_handler = act->sa_handler;
- kact.sa_mask = act->sa_mask.__val[0];
- kact.sa_flags = act->sa_flags;
-# ifdef HAVE_SA_RESTORER
- if (kact.sa_flags & SA_RESTORER) {
- kact.sa_restorer = act->sa_restorer;
- } else {
- kact.sa_restorer = choose_restorer (kact.sa_flags);
- kact.sa_flags |= SA_RESTORER;
+ int result;
+ struct old_kernel_sigaction kact, koact;
+
+ if (act) {
+ kact.k_sa_handler = act->sa_handler;
+ kact.sa_mask = act->sa_mask.__val[0];
+ kact.sa_flags = act->sa_flags;
+ if (kact.sa_flags & SA_RESTORER) {
+ kact.sa_restorer = act->sa_restorer;
+ } else {
+ kact.sa_restorer = choose_restorer(kact.sa_flags);
+ kact.sa_flags |= SA_RESTORER;
+ }
}
-# endif
- }
- result = __syscall_sigaction(sig, act ? __ptrvalue (&kact) : NULL,
- oact ? __ptrvalue (&koact) : NULL);
- if (oact && result >= 0) {
- oact->sa_handler = koact.k_sa_handler;
- oact->sa_mask.__val[0] = koact.sa_mask;
- oact->sa_flags = koact.sa_flags;
-# ifdef HAVE_SA_RESTORER
- oact->sa_restorer = koact.sa_restorer;
-# endif
- }
- return result;
+ result = __syscall_sigaction(sig,
+ act ? &kact : NULL,
+ oact ? &koact : NULL);
+ if (oact && result >= 0) {
+ oact->sa_handler = koact.k_sa_handler;
+ oact->sa_mask.__val[0] = koact.sa_mask;
+ oact->sa_flags = koact.sa_flags;
+ oact->sa_restorer = koact.sa_restorer;
+ }
+ return result;
}
#endif
+
#ifndef LIBC_SIGACTION
-libc_hidden_proto(sigaction)
+# ifndef __UCLIBC_HAS_THREADS__
+strong_alias(__libc_sigaction,sigaction)
+libc_hidden_def(sigaction)
+# else
weak_alias(__libc_sigaction,sigaction)
libc_hidden_weak(sigaction)
+# endif
#endif
diff --git a/libc/sysdeps/linux/arm/sigrestorer.S b/libc/sysdeps/linux/arm/sigrestorer.S
index 79728fd40..f657fe333 100644
--- a/libc/sysdeps/linux/arm/sigrestorer.S
+++ b/libc/sysdeps/linux/arm/sigrestorer.S
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <bits/arm_asm.h>
#include <sys/syscall.h>
diff --git a/libc/sysdeps/linux/arm/swapcontext.S b/libc/sysdeps/linux/arm/swapcontext.S
new file mode 100644
index 000000000..ba6e31c4d
--- /dev/null
+++ b/libc/sysdeps/linux/arm/swapcontext.S
@@ -0,0 +1,63 @@
+/* Copyright (C) 2012 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+
+#include "ucontext_i.h"
+
+ .syntax unified
+ .text
+
+/* int swapcontext (ucontext_t *oucp, const ucontext_t *ucp) */
+
+ENTRY(swapcontext)
+
+ /* Have getcontext() do most of the work then fix up
+ LR afterwards. Save R3 to keep the stack aligned. */
+ push {r0,r1,r3,r14}
+ cfi_adjust_cfa_offset (16)
+ cfi_rel_offset (r0,0)
+ cfi_rel_offset (r1,4)
+ cfi_rel_offset (r3,8)
+ cfi_rel_offset (r14,12)
+
+ bl __getcontext
+ mov r4, r0
+
+ pop {r0,r1,r3,r14}
+ cfi_adjust_cfa_offset (-16)
+ cfi_restore (r0)
+ cfi_restore (r1)
+ cfi_restore (r3)
+ cfi_restore (r14)
+
+ /* Exit if getcontext() failed. */
+ cmp r4, #0
+ itt ne
+ movne r0, r4
+ RETINSTR(ne, r14)
+
+ /* Fix up LR and the PC. */
+ str r13,[r0, #MCONTEXT_ARM_SP]
+ str r14,[r0, #MCONTEXT_ARM_LR]
+ str r14,[r0, #MCONTEXT_ARM_PC]
+
+ /* And swap using swapcontext(). */
+ mov r0, r1
+ b __setcontext
+
+END(swapcontext)
diff --git a/libc/sysdeps/linux/arm/sys/elf.h b/libc/sysdeps/linux/arm/sys/elf.h
index faa731068..4c06715da 100644
--- a/libc/sysdeps/linux/arm/sys/elf.h
+++ b/libc/sysdeps/linux/arm/sys/elf.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_ELF_H
#define _SYS_ELF_H 1
diff --git a/libc/sysdeps/linux/arm/sys/io.h b/libc/sysdeps/linux/arm/sys/io.h
index 68639902c..1a47bb514 100644
--- a/libc/sysdeps/linux/arm/sys/io.h
+++ b/libc/sysdeps/linux/arm/sys/io.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_IO_H
@@ -23,16 +22,19 @@
__BEGIN_DECLS
+#if defined __UCLIBC_LINUX_SPECIFIC__
/* If TURN_ON is TRUE, request for permission to do direct i/o on the
port numbers in the range [FROM,FROM+NUM-1]. Otherwise, turn I/O
permission off for that range. This call requires root privileges. */
extern int ioperm (unsigned long int __from, unsigned long int __num,
int __turn_on) __THROW;
+libc_hidden_proto(ioperm)
/* Set the I/O privilege level to LEVEL. If LEVEL is nonzero,
permission to access any I/O port is granted. This call requires
root privileges. */
extern int iopl (int __level) __THROW;
+#endif /* __UCLIBC_LINUX_SPECIFIC__ */
/* The functions that actually perform reads and writes. */
extern unsigned char inb (unsigned long int port) __THROW;
diff --git a/libc/sysdeps/linux/arm/sys/procfs.h b/libc/sysdeps/linux/arm/sys/procfs.h
index 3b3736324..14f233a63 100644
--- a/libc/sysdeps/linux/arm/sys/procfs.h
+++ b/libc/sysdeps/linux/arm/sys/procfs.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_PROCFS_H
#define _SYS_PROCFS_H 1
diff --git a/libc/sysdeps/linux/arm/sys/ucontext.h b/libc/sysdeps/linux/arm/sys/ucontext.h
index 9ecff7b59..c10d774a5 100644
--- a/libc/sysdeps/linux/arm/sys/ucontext.h
+++ b/libc/sysdeps/linux/arm/sys/ucontext.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* System V/ARM ABI compliant context switching support. */
diff --git a/libc/sysdeps/linux/arm/sys/user.h b/libc/sysdeps/linux/arm/sys/user.h
index 3fae43f83..4420fc9c8 100644
--- a/libc/sysdeps/linux/arm/sys/user.h
+++ b/libc/sysdeps/linux/arm/sys/user.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_USER_H
#define _SYS_USER_H 1
diff --git a/libc/sysdeps/linux/arm/syscall-eabi.S b/libc/sysdeps/linux/arm/syscall-eabi.S
index b9318821b..534c6e988 100644
--- a/libc/sysdeps/linux/arm/syscall-eabi.S
+++ b/libc/sysdeps/linux/arm/syscall-eabi.S
@@ -12,12 +12,12 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
-#include <sys/syscall.h>
+#include <features.h>
#include <bits/arm_asm.h>
+#include <bits/arm_bx.h>
/* In the EABI syscall interface, we don't need a special syscall to
implement syscall(). It won't work reliably with 64-bit arguments
@@ -62,11 +62,7 @@ syscall:
ldmfd sp!, {r4, r5, r6, r7}
cmn r0, #4096
IT(t, cc)
-#if defined(__USE_BX__)
- bxcc lr
-#else
- movcc pc, lr
-#endif
+ BXC(cc, lr)
b __syscall_error
#endif
diff --git a/libc/sysdeps/linux/arm/sysdep.h b/libc/sysdeps/linux/arm/sysdep.h
new file mode 100644
index 000000000..14529892d
--- /dev/null
+++ b/libc/sysdeps/linux/arm/sysdep.h
@@ -0,0 +1,396 @@
+/* Assembler macros for ARM.
+ Copyright (C) 1997, 1998, 2003 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _LINUX_ARM_SYSDEP_H
+#define _LINUX_ARM_SYSDEP_H 1
+
+#include <common/sysdep.h>
+#include <bits/arm_bx.h>
+#include <sys/syscall.h>
+/* For Linux we can use the system call table in the header file
+ /usr/include/asm/unistd.h
+ of the kernel. But these symbols do not follow the SYS_* syntax
+ so we have to redefine the `SYS_ify' macro here. */
+#undef SYS_ify
+#define SWI_BASE (0x900000)
+#define SYS_ify(syscall_name) (__NR_##syscall_name)
+
+#ifdef __ASSEMBLER__
+
+/* Syntactic details of assembler. */
+
+#define ALIGNARG(log2) log2
+/* For ELF we need the `.type' directive to make shared libs work right. */
+#define ASM_TYPE_DIRECTIVE(name,typearg) .type name,%##typearg;
+#define ASM_SIZE_DIRECTIVE(name) .size name,.-name
+
+/* In ELF C symbols are asm symbols. */
+#undef NO_UNDERSCORES
+#define NO_UNDERSCORES
+
+#define PLTJMP(_x) _x##(PLT)
+
+/* APCS-32 doesn't preserve the condition codes across function call. */
+#ifdef __APCS_32__
+#define LOADREGS(cond, base, reglist...)\
+ ldm##cond base,reglist
+#define RETINSTR(cond, reg) \
+ BXC(cond, reg)
+#define DO_RET(_reg) \
+ BX(_reg)
+#else /* APCS-26 */
+#define LOADREGS(cond, base, reglist...) \
+ ldm##cond base,reglist^
+#define RETINSTR(cond, reg) \
+ mov##cond##s pc, reg
+#define DO_RET(_reg) \
+ movs pc, _reg
+#endif
+
+/* Define an entry point visible from C. */
+#define ENTRY(name) \
+ .globl C_SYMBOL_NAME(name); \
+ ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),function) \
+ .align ALIGNARG(4); \
+ name##: \
+ CALL_MCOUNT
+
+#undef END
+#define END(name) \
+ ASM_SIZE_DIRECTIVE(name)
+
+/* If compiled for profiling, call `mcount' at the start of each function. */
+#ifdef PROF
+#define CALL_MCOUNT \
+ str lr,[sp, #-4]! ; \
+ bl PLTJMP(mcount) ; \
+ ldr lr, [sp], #4 ;
+#else
+#define CALL_MCOUNT /* Do nothing. */
+#endif
+
+#ifdef NO_UNDERSCORES
+/* Since C identifiers are not normally prefixed with an underscore
+ on this system, the asm identifier `syscall_error' intrudes on the
+ C name space. Make sure we use an innocuous name. */
+#define syscall_error __syscall_error
+#define mcount _mcount
+#endif
+/* Linux uses a negative return value to indicate syscall errors,
+ unlike most Unices, which use the condition codes' carry flag.
+
+ Since version 2.1 the return value of a system call might be
+ negative even if the call succeeded. E.g., the `lseek' system call
+ might return a large offset. Therefore we must not anymore test
+ for < 0, but test for a real error by making sure the value in R0
+ is a real error number. Linus said he will make sure the no syscall
+ returns a value in -1 .. -4095 as a valid result so we can safely
+ test with -4095. */
+
+#undef PSEUDO
+#define PSEUDO(name, syscall_name, args) \
+ .text; \
+ ENTRY (name); \
+ DO_CALL (syscall_name, args); \
+ cmn r0, $4096;
+
+#define PSEUDO_RET \
+ RETINSTR(cc, lr); \
+ b PLTJMP(SYSCALL_ERROR)
+#undef ret
+#define ret PSEUDO_RET
+
+#undef PSEUDO_END
+#define PSEUDO_END(name) \
+ SYSCALL_ERROR_HANDLER \
+ END (name)
+
+#undef PSEUDO_NOERRNO
+#define PSEUDO_NOERRNO(name, syscall_name, args) \
+ .text; \
+ ENTRY (name); \
+ DO_CALL (syscall_name, args);
+
+#define PSEUDO_RET_NOERRNO \
+ DO_RET (lr);
+
+#undef ret_NOERRNO
+#define ret_NOERRNO PSEUDO_RET_NOERRNO
+
+#undef PSEUDO_END_NOERRNO
+#define PSEUDO_END_NOERRNO(name) \
+ END (name)
+
+/* The function has to return the error code. */
+#undef PSEUDO_ERRVAL
+#define PSEUDO_ERRVAL(name, syscall_name, args) \
+ .text; \
+ ENTRY (name) \
+ DO_CALL (syscall_name, args); \
+ rsb r0, r0, #0
+
+#undef PSEUDO_END_ERRVAL
+#define PSEUDO_END_ERRVAL(name) \
+ END (name)
+
+#undef ret_ERRVAL
+#define ret_ERRVAL PSEUDO_RET_NOERRNO
+
+#if defined NOT_IN_libc
+# define SYSCALL_ERROR __local_syscall_error
+# ifdef RTLD_PRIVATE_ERRNO
+# define SYSCALL_ERROR_HANDLER \
+__local_syscall_error: \
+ ldr r1, 1f; \
+ rsb r0, r0, #0; \
+0: str r0, [pc, r1]; \
+ mvn r0, #0; \
+ DO_RET(lr); \
+1: .word C_SYMBOL_NAME(rtld_errno) - 0b - 8;
+# else
+# define SYSCALL_ERROR_HANDLER \
+__local_syscall_error: \
+ str lr, [sp, #-4]!; \
+ str r0, [sp, #-4]!; \
+ bl PLTJMP(C_SYMBOL_NAME(__errno_location)); \
+ ldr r1, [sp], #4; \
+ rsb r1, r1, #0; \
+ str r1, [r0]; \
+ mvn r0, #0; \
+ ldr pc, [sp], #4;
+# endif
+#else
+# define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */
+# define SYSCALL_ERROR __syscall_error
+#endif
+
+/* Linux takes system call args in registers:
+ syscall number in the SWI instruction
+ arg 1 r0
+ arg 2 r1
+ arg 3 r2
+ arg 4 r3
+ arg 5 r4 (this is different from the APCS convention)
+ arg 6 r5
+ arg 7 r6
+
+ The compiler is going to form a call by coming here, through PSEUDO, with
+ arguments
+ syscall number in the DO_CALL macro
+ arg 1 r0
+ arg 2 r1
+ arg 3 r2
+ arg 4 r3
+ arg 5 [sp]
+ arg 6 [sp+4]
+ arg 7 [sp+8]
+
+ We need to shuffle values between R4..R6 and the stack so that the
+ caller's v1..v3 and stack frame are not corrupted, and the kernel
+ sees the right arguments.
+
+*/
+#if __ARM_ARCH > 6 || defined (__ARM_ARCH_6K__) || defined (__ARM_ARCH_6ZK__)
+# define ARCH_HAS_HARD_TP
+#endif
+
+# ifdef __thumb2__
+# define NEGOFF_ADJ_BASE(R, OFF) add R, R, $OFF
+# define NEGOFF_ADJ_BASE2(D, S, OFF) add D, S, $OFF
+# define NEGOFF_OFF1(R, OFF) [R]
+# define NEGOFF_OFF2(R, OFFA, OFFB) [R, $((OFFA) - (OFFB))]
+# else
+# define NEGOFF_ADJ_BASE(R, OFF)
+# define NEGOFF_ADJ_BASE2(D, S, OFF) mov D, S
+# define NEGOFF_OFF1(R, OFF) [R, $OFF]
+# define NEGOFF_OFF2(R, OFFA, OFFB) [R, $OFFA]
+# endif
+
+# ifdef ARCH_HAS_HARD_TP
+/* If the cpu has cp15 available, use it. */
+# define GET_TLS(TMP) mrc p15, 0, r0, c13, c0, 3
+# else
+/* At this generic level we have no tricks to pull. Call the ABI routine. */
+# define GET_TLS(TMP) \
+ push { r1, r2, r3, lr }; \
+ cfi_remember_state; \
+ cfi_adjust_cfa_offset (16); \
+ cfi_rel_offset (r1, 0); \
+ cfi_rel_offset (r2, 4); \
+ cfi_rel_offset (r3, 8); \
+ cfi_rel_offset (lr, 12); \
+ bl __aeabi_read_tp; \
+ pop { r1, r2, r3, lr }; \
+ cfi_restore_state
+# endif /* ARCH_HAS_HARD_TP */
+
+
+
+
+#undef DO_CALL
+#if defined(__ARM_EABI__)
+#define DO_CALL(syscall_name, args) \
+ DOARGS_##args \
+ mov ip, r7; \
+ ldr r7, =SYS_ify (syscall_name); \
+ swi 0x0; \
+ mov r7, ip; \
+ UNDOARGS_##args
+#else
+#define DO_CALL(syscall_name, args) \
+ DOARGS_##args \
+ swi SYS_ify (syscall_name); \
+ UNDOARGS_##args
+#endif
+
+#define DOARGS_0 /* nothing */
+#define DOARGS_1 /* nothing */
+#define DOARGS_2 /* nothing */
+#define DOARGS_3 /* nothing */
+#define DOARGS_4 /* nothing */
+#define DOARGS_5 str r4, [sp, $-4]!; ldr r4, [sp, $4];
+#define DOARGS_6 mov ip, sp; stmfd sp!, {r4, r5}; ldmia ip, {r4, r5};
+#define DOARGS_7 mov ip, sp; stmfd sp!, {r4, r5, r6}; ldmia ip, {r4, r5, r6};
+
+#define UNDOARGS_0 /* nothing */
+#define UNDOARGS_1 /* nothing */
+#define UNDOARGS_2 /* nothing */
+#define UNDOARGS_3 /* nothing */
+#define UNDOARGS_4 /* nothing */
+#define UNDOARGS_5 ldr r4, [sp], $4;
+#define UNDOARGS_6 ldmfd sp!, {r4, r5};
+#define UNDOARGS_7 ldmfd sp!, {r4, r5, r6};
+
+#else /* not __ASSEMBLER__ */
+/* Define a macro which expands into the inline wrapper code for a system
+ call. */
+#undef INLINE_SYSCALL
+#define INLINE_SYSCALL(name, nr, args...) \
+ ({ unsigned int _inline_sys_result = INTERNAL_SYSCALL (name, , nr, args); \
+ if (unlikely (INTERNAL_SYSCALL_ERROR_P (_inline_sys_result, ))) \
+ { \
+ __set_errno (INTERNAL_SYSCALL_ERRNO (_inline_sys_result, )); \
+ _inline_sys_result = (unsigned int) -1; \
+ } \
+ (int) _inline_sys_result; })
+
+#undef INTERNAL_SYSCALL_DECL
+#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
+
+#undef INTERNAL_SYSCALL_RAW
+#if defined(__thumb__)
+/* Hide the use of r7 from the compiler, this would be a lot
+ * easier but for the fact that the syscalls can exceed 255.
+ * For the moment the LOAD_ARG_7 is sacrificed.
+ * We can't use push/pop inside the asm because that breaks
+ * unwinding (ie. thread cancellation).
+ */
+#define INTERNAL_SYSCALL_RAW(name, err, nr, args...) \
+ ({ unsigned int _internal_sys_result; \
+ { \
+ int _sys_buf[2]; \
+ register int __a1 __asm__ ("a1"); \
+ register int *_v3 __asm__ ("v3") = _sys_buf; \
+ LOAD_ARGS_##nr (args) \
+ *_v3 = (int) (name); \
+ __asm__ __volatile__ ("str r7, [v3, #4]\n" \
+ "\tldr r7, [v3]\n" \
+ "\tswi 0 @ syscall " #name "\n" \
+ "\tldr r7, [v3, #4]" \
+ : "=r" (__a1) \
+ : "r" (_v3) ASM_ARGS_##nr \
+ : "memory"); \
+ _internal_sys_result = __a1; \
+ } \
+ (int) _internal_sys_result; })
+#elif defined(__ARM_EABI__)
+#define INTERNAL_SYSCALL_RAW(name, err, nr, args...) \
+ ({unsigned int _internal_sys_result; \
+ { \
+ register int __a1 __asm__ ("r0"), _nr __asm__ ("r7"); \
+ LOAD_ARGS_##nr (args) \
+ _nr = name; \
+ __asm__ __volatile__ ("swi 0x0 @ syscall " #name \
+ : "=r" (__a1) \
+ : "r" (_nr) ASM_ARGS_##nr \
+ : "memory"); \
+ _internal_sys_result = __a1; \
+ } \
+ (int) _internal_sys_result; })
+#else /* !defined(__ARM_EABI__) */
+#define INTERNAL_SYSCALL_RAW(name, err, nr, args...) \
+ ({ unsigned int _internal_sys_result; \
+ { \
+ register int __a1 __asm__ ("a1"); \
+ LOAD_ARGS_##nr (args) \
+ __asm__ __volatile__ ("swi %1 @ syscall " #name \
+ : "=r" (__a1) \
+ : "i" (name) ASM_ARGS_##nr \
+ : "memory"); \
+ _internal_sys_result = __a1; \
+ } \
+ (int) _internal_sys_result; })
+#endif
+
+#undef INTERNAL_SYSCALL
+#define INTERNAL_SYSCALL(name, err, nr, args...) \
+ INTERNAL_SYSCALL_RAW(SYS_ify(name), err, nr, args)
+
+#undef INTERNAL_SYSCALL_ARM
+#define INTERNAL_SYSCALL_ARM(name, err, nr, args...) \
+ INTERNAL_SYSCALL_RAW(__ARM_NR_##name, err, nr, args)
+
+#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 defined(__ARM_EABI__)
+#undef INTERNAL_SYSCALL_NCS
+#define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
+ INTERNAL_SYSCALL_RAW(number, err, nr, args)
+#else
+/* We can't implement non-constant syscalls directly since the syscall
+ number is normally encoded in the instruction. So use SYS_syscall. */
+#undef INTERNAL_SYSCALL_NCS
+#define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
+ INTERNAL_SYSCALL_NCS_##nr (number, err, args)
+
+#define INTERNAL_SYSCALL_NCS_0(number, err, args...) \
+ INTERNAL_SYSCALL (syscall, err, 1, number, args)
+#define INTERNAL_SYSCALL_NCS_1(number, err, args...) \
+ INTERNAL_SYSCALL (syscall, err, 2, number, args)
+#define INTERNAL_SYSCALL_NCS_2(number, err, args...) \
+ INTERNAL_SYSCALL (syscall, err, 3, number, args)
+#define INTERNAL_SYSCALL_NCS_3(number, err, args...) \
+ INTERNAL_SYSCALL (syscall, err, 4, number, args)
+#define INTERNAL_SYSCALL_NCS_4(number, err, args...) \
+ INTERNAL_SYSCALL (syscall, err, 5, number, args)
+#define INTERNAL_SYSCALL_NCS_5(number, err, args...) \
+ INTERNAL_SYSCALL (syscall, err, 6, number, args)
+#endif
+
+#endif /* __ASSEMBLER__ */
+
+/* Pointer mangling is not yet supported for ARM. */
+#define PTR_MANGLE(var) (void) (var)
+#define PTR_DEMANGLE(var) (void) (var)
+
+#endif /* linux/arm/sysdep.h */
diff --git a/libc/sysdeps/linux/arm/ucontext_i.sym b/libc/sysdeps/linux/arm/ucontext_i.sym
new file mode 100644
index 000000000..965032260
--- /dev/null
+++ b/libc/sysdeps/linux/arm/ucontext_i.sym
@@ -0,0 +1,30 @@
+#include <inttypes.h>
+#include <signal.h>
+#include <stddef.h>
+#include <sys/ucontext.h>
+
+SIG_BLOCK
+SIG_SETMASK
+
+-- Offsets of the fields in the ucontext_t structure.
+#define ucontext(member) offsetof (ucontext_t, member)
+#define mcontext(member) ucontext (uc_mcontext.member)
+
+UCONTEXT_FLAGS ucontext (uc_flags)
+UCONTEXT_LINK ucontext (uc_link)
+UCONTEXT_STACK ucontext (uc_stack)
+UCONTEXT_MCONTEXT ucontext (uc_mcontext)
+UCONTEXT_SIGMASK ucontext (uc_sigmask)
+
+UCONTEXT_REGSPACE ucontext (uc_regspace)
+
+MCONTEXT_TRAP_NO mcontext (trap_no)
+MCONTEXT_ERROR_CODE mcontext (error_code)
+MCONTEXT_OLDMASK mcontext (oldmask)
+MCONTEXT_ARM_R0 mcontext (arm_r0)
+MCONTEXT_ARM_R4 mcontext (arm_r4)
+MCONTEXT_ARM_SP mcontext (arm_sp)
+MCONTEXT_ARM_LR mcontext (arm_lr)
+MCONTEXT_ARM_PC mcontext (arm_pc)
+MCONTEXT_ARM_CPSR mcontext (arm_cpsr)
+MCONTEXT_FAULT_ADDRESS mcontext (fault_address)
diff --git a/libc/sysdeps/linux/arm/unwind.h b/libc/sysdeps/linux/arm/unwind.h
new file mode 100644
index 000000000..601aa8f59
--- /dev/null
+++ b/libc/sysdeps/linux/arm/unwind.h
@@ -0,0 +1,278 @@
+/* Header file for the ARM EABI unwinder
+ Copyright (C) 2003, 2004, 2005, 2009 Free Software Foundation, Inc.
+ Contributed by Paul Brook
+
+ This file is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ In addition to the permissions in the GNU General Public License, the
+ Free Software Foundation gives you unlimited permission to link the
+ compiled version of this file into combinations with other programs,
+ and to distribute those combinations without any restriction coming
+ from the use of this file. (The General Public License restrictions
+ do apply in other respects; for example, they cover modification of
+ the file, and distribution when not linked into a combine
+ executable.)
+
+ This file 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
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* Language-independent unwinder header public defines. This contains both
+ ABI defined objects, and GNU support routines. */
+
+#ifndef UNWIND_ARM_H
+#define UNWIND_ARM_H
+
+#define __ARM_EABI_UNWINDER__ 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ typedef unsigned _Unwind_Word __attribute__((__mode__(__word__)));
+ typedef signed _Unwind_Sword __attribute__((__mode__(__word__)));
+ typedef unsigned _Unwind_Ptr __attribute__((__mode__(__pointer__)));
+ typedef unsigned _Unwind_Internal_Ptr __attribute__((__mode__(__pointer__)));
+ typedef _Unwind_Word _uw;
+ typedef unsigned _uw64 __attribute__((mode(__DI__)));
+ typedef unsigned _uw16 __attribute__((mode(__HI__)));
+ typedef unsigned _uw8 __attribute__((mode(__QI__)));
+
+ typedef enum
+ {
+ _URC_OK = 0, /* operation completed successfully */
+ _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
+ _URC_END_OF_STACK = 5,
+ _URC_HANDLER_FOUND = 6,
+ _URC_INSTALL_CONTEXT = 7,
+ _URC_CONTINUE_UNWIND = 8,
+ _URC_FAILURE = 9 /* unspecified failure of some kind */
+ }
+ _Unwind_Reason_Code;
+
+ typedef enum
+ {
+ _US_VIRTUAL_UNWIND_FRAME = 0,
+ _US_UNWIND_FRAME_STARTING = 1,
+ _US_UNWIND_FRAME_RESUME = 2,
+ _US_ACTION_MASK = 3,
+ _US_FORCE_UNWIND = 8,
+ _US_END_OF_STACK = 16
+ }
+ _Unwind_State;
+
+ /* Provided only for for compatibility with existing code. */
+ typedef int _Unwind_Action;
+#define _UA_SEARCH_PHASE 1
+#define _UA_CLEANUP_PHASE 2
+#define _UA_HANDLER_FRAME 4
+#define _UA_FORCE_UNWIND 8
+#define _UA_END_OF_STACK 16
+#define _URC_NO_REASON _URC_OK
+
+ typedef struct _Unwind_Control_Block _Unwind_Control_Block;
+ typedef struct _Unwind_Context _Unwind_Context;
+ typedef _uw _Unwind_EHT_Header;
+
+
+ /* UCB: */
+
+ struct _Unwind_Control_Block
+ {
+#ifdef _LIBC
+ /* For the benefit of code which assumes this is a scalar. All
+ glibc ever does is clear it. */
+ _uw64 exception_class;
+#else
+ char exception_class[8];
+#endif
+ void (*exception_cleanup)(_Unwind_Reason_Code, _Unwind_Control_Block *);
+ /* Unwinder cache, private fields for the unwinder's use */
+ struct
+ {
+ _uw reserved1; /* Forced unwind stop fn, 0 if not forced */
+ _uw reserved2; /* Personality routine address */
+ _uw reserved3; /* Saved callsite address */
+ _uw reserved4; /* Forced unwind stop arg */
+ _uw reserved5;
+ }
+ unwinder_cache;
+ /* Propagation barrier cache (valid after phase 1): */
+ struct
+ {
+ _uw sp;
+ _uw bitpattern[5];
+ }
+ barrier_cache;
+ /* Cleanup cache (preserved over cleanup): */
+ struct
+ {
+ _uw bitpattern[4];
+ }
+ cleanup_cache;
+ /* Pr cache (for pr's benefit): */
+ struct
+ {
+ _uw fnstart; /* function start address */
+ _Unwind_EHT_Header *ehtp; /* pointer to EHT entry header word */
+ _uw additional; /* additional data */
+ _uw reserved1;
+ }
+ pr_cache;
+ long long int :0; /* Force alignment to 8-byte boundary */
+ };
+
+ /* Virtual Register Set*/
+
+ typedef enum
+ {
+ _UVRSC_CORE = 0, /* integer register */
+ _UVRSC_VFP = 1, /* vfp */
+ _UVRSC_FPA = 2, /* fpa */
+ _UVRSC_WMMXD = 3, /* Intel WMMX data register */
+ _UVRSC_WMMXC = 4 /* Intel WMMX control register */
+ }
+ _Unwind_VRS_RegClass;
+
+ typedef enum
+ {
+ _UVRSD_UINT32 = 0,
+ _UVRSD_VFPX = 1,
+ _UVRSD_FPAX = 2,
+ _UVRSD_UINT64 = 3,
+ _UVRSD_FLOAT = 4,
+ _UVRSD_DOUBLE = 5
+ }
+ _Unwind_VRS_DataRepresentation;
+
+ typedef enum
+ {
+ _UVRSR_OK = 0,
+ _UVRSR_NOT_IMPLEMENTED = 1,
+ _UVRSR_FAILED = 2
+ }
+ _Unwind_VRS_Result;
+
+ /* Frame unwinding state. */
+ typedef struct
+ {
+ /* The current word (bytes packed msb first). */
+ _uw data;
+ /* Pointer to the next word of data. */
+ _uw *next;
+ /* The number of bytes left in this word. */
+ _uw8 bytes_left;
+ /* The number of words pointed to by ptr. */
+ _uw8 words_left;
+ }
+ __gnu_unwind_state;
+
+ typedef _Unwind_Reason_Code (*personality_routine) (_Unwind_State,
+ _Unwind_Control_Block *, _Unwind_Context *);
+
+ _Unwind_VRS_Result _Unwind_VRS_Set(_Unwind_Context *, _Unwind_VRS_RegClass,
+ _uw, _Unwind_VRS_DataRepresentation,
+ void *);
+
+ _Unwind_VRS_Result _Unwind_VRS_Get(_Unwind_Context *, _Unwind_VRS_RegClass,
+ _uw, _Unwind_VRS_DataRepresentation,
+ void *);
+
+ _Unwind_VRS_Result _Unwind_VRS_Pop(_Unwind_Context *, _Unwind_VRS_RegClass,
+ _uw, _Unwind_VRS_DataRepresentation);
+
+
+ /* Support functions for the PR. */
+#define _Unwind_Exception _Unwind_Control_Block
+ typedef char _Unwind_Exception_Class[8];
+
+ void * _Unwind_GetLanguageSpecificData (_Unwind_Context *);
+ _Unwind_Ptr _Unwind_GetRegionStart (_Unwind_Context *);
+
+ /* These two should never be used. */
+ _Unwind_Ptr _Unwind_GetDataRelBase (_Unwind_Context *);
+ _Unwind_Ptr _Unwind_GetTextRelBase (_Unwind_Context *);
+
+ /* Interface functions: */
+ _Unwind_Reason_Code _Unwind_RaiseException(_Unwind_Control_Block *ucbp);
+ void __attribute__((noreturn)) _Unwind_Resume(_Unwind_Control_Block *ucbp);
+ _Unwind_Reason_Code _Unwind_Resume_or_Rethrow (_Unwind_Control_Block *ucbp);
+
+ typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)
+ (int, _Unwind_Action, _Unwind_Exception_Class,
+ _Unwind_Control_Block *, struct _Unwind_Context *, void *);
+ _Unwind_Reason_Code _Unwind_ForcedUnwind (_Unwind_Control_Block *,
+ _Unwind_Stop_Fn, void *);
+ _Unwind_Word _Unwind_GetCFA (struct _Unwind_Context *);
+ void _Unwind_Complete(_Unwind_Control_Block *ucbp);
+ void _Unwind_DeleteException (_Unwind_Exception *);
+
+ _Unwind_Reason_Code __gnu_unwind_frame (_Unwind_Control_Block *,
+ _Unwind_Context *);
+ _Unwind_Reason_Code __gnu_unwind_execute (_Unwind_Context *,
+ __gnu_unwind_state *);
+
+ /* Decode an R_ARM_TARGET2 relocation. */
+ static inline _Unwind_Word
+ _Unwind_decode_target2 (_Unwind_Word ptr)
+ {
+ _Unwind_Word tmp;
+
+ tmp = *(_Unwind_Word *) ptr;
+ /* Zero values are always NULL. */
+ if (!tmp)
+ return 0;
+
+#if defined(linux) || defined(__NetBSD__)
+ /* Pc-relative indirect. */
+ tmp += ptr;
+ tmp = *(_Unwind_Word *) tmp;
+#elif defined(__symbian__)
+ /* Absolute pointer. Nothing more to do. */
+#else
+ /* Pc-relative pointer. */
+ tmp += ptr;
+#endif
+ return tmp;
+ }
+
+ static inline _Unwind_Word
+ _Unwind_GetGR (_Unwind_Context *context, int regno)
+ {
+ _uw val;
+ _Unwind_VRS_Get (context, _UVRSC_CORE, regno, _UVRSD_UINT32, &val);
+ return val;
+ }
+
+ /* Return the address of the instruction, not the actual IP value. */
+#define _Unwind_GetIP(context) \
+ (_Unwind_GetGR (context, 15) & ~(_Unwind_Word)1)
+
+ static inline void
+ _Unwind_SetGR (_Unwind_Context *context, int regno, _Unwind_Word val)
+ {
+ _Unwind_VRS_Set (context, _UVRSC_CORE, regno, _UVRSD_UINT32, &val);
+ }
+
+ /* The dwarf unwinder doesn't understand arm/thumb state. We assume the
+ landing pad uses the same instruction set as the call site. */
+#define _Unwind_SetIP(context, val) \
+ _Unwind_SetGR (context, 15, val | (_Unwind_GetGR (context, 15) & 1))
+
+typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn)
+ (struct _Unwind_Context *, void *);
+
+extern _Unwind_Reason_Code _Unwind_Backtrace (_Unwind_Trace_Fn, void *);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* defined UNWIND_ARM_H */
diff --git a/libc/sysdeps/linux/arm/vfork.S b/libc/sysdeps/linux/arm/vfork.S
index 42595b026..221a90c40 100644
--- a/libc/sysdeps/linux/arm/vfork.S
+++ b/libc/sysdeps/linux/arm/vfork.S
@@ -7,11 +7,21 @@
#include <features.h>
#include <bits/arm_asm.h>
+#include <bits/arm_bx.h>
#define _ERRNO_H
#include <bits/errno.h>
#include <sys/syscall.h>
+#ifndef SAVE_PID
+#define SAVE_PID
+#endif
+
+#ifndef RESTORE_PID
+#define RESTORE_PID
+#endif
+
+
#ifdef __NR_fork
.text
.global __vfork
@@ -23,7 +33,9 @@
.thumb_func
__vfork:
#ifdef __NR_vfork
+ SAVE_PID
DO_CALL (vfork)
+ RESTORE_PID
ldr r1, =0xfffff000
cmp r0, r1
bcs 1f
@@ -57,14 +69,12 @@ __error:
__vfork:
#ifdef __NR_vfork
+ SAVE_PID
DO_CALL (vfork)
+ RESTORE_PID
cmn r0, #4096
IT(t, cc)
-#if defined(__USE_BX__)
- bxcc lr
-#else
- movcc pc, lr
-#endif
+ BXC(cc, lr)
/* Check if vfork even exists. */
ldr r1, =-ENOSYS
@@ -78,11 +88,7 @@ __vfork:
/* Syscall worked. Return to child/parent */
IT(t, cc)
-#if defined(__USE_BX__)
- bxcc lr
-#else
- movcc pc, lr
-#endif
+ BXC(cc, lr)
__error:
b __syscall_error
@@ -91,5 +97,5 @@ __error:
.size __vfork,.-__vfork
weak_alias(__vfork,vfork)
-libc_hidden_weak(vfork)
+libc_hidden_def(vfork)
#endif
diff --git a/libc/sysdeps/linux/avr32/Makefile b/libc/sysdeps/linux/avr32/Makefile
index 338abc086..4fa4bb107 100644
--- a/libc/sysdeps/linux/avr32/Makefile
+++ b/libc/sysdeps/linux/avr32/Makefile
@@ -13,8 +13,7 @@
# 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
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
top_srcdir=../../../../
top_builddir=../../../../
diff --git a/libc/sysdeps/linux/avr32/Makefile.arch b/libc/sysdeps/linux/avr32/Makefile.arch
index 44fc01ebf..9bc6a64d6 100644
--- a/libc/sysdeps/linux/avr32/Makefile.arch
+++ b/libc/sysdeps/linux/avr32/Makefile.arch
@@ -5,9 +5,7 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-CSRC := brk.c clone.c mmap.c sigaction.c
+CSRC-y := brk.c clone.c mmap.c prctl.c sigaction.c
-SSRC := __longjmp.S setjmp.S bsd-setjmp.S bsd-_setjmp.S \
+SSRC-y := __longjmp.S setjmp.S bsd-setjmp.S bsd-_setjmp.S \
sigrestorer.S syscall.S vfork.S
-
-include $(top_srcdir)/libc/sysdeps/linux/Makefile.commonarch
diff --git a/libc/sysdeps/linux/avr32/bits/atomic.h b/libc/sysdeps/linux/avr32/bits/atomic.h
index e6be41f01..3bc2aeefc 100644
--- a/libc/sysdeps/linux/avr32/bits/atomic.h
+++ b/libc/sysdeps/linux/avr32/bits/atomic.h
@@ -28,6 +28,7 @@ typedef uintmax_t uatomic_max_t;
#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
({ \
+ __uint32_t __result; \
__typeof__(*(mem)) __prev; \
__asm__ __volatile__( \
"/* __arch_compare_and_exchange_val_32_acq */\n" \
diff --git a/libc/sysdeps/linux/avr32/bits/byteswap.h b/libc/sysdeps/linux/avr32/bits/byteswap.h
deleted file mode 100644
index f0bea4cea..000000000
--- a/libc/sysdeps/linux/avr32/bits/byteswap.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2005 Atmel Corporation
- *
- * This file is subject to the terms and conditions of the GNU Lesser General
- * Public License. See the file "COPYING.LIB" in the main directory of this
- * archive for more details.
- */
-
-#if !defined _BYTESWAP_H && !defined _NETINET_IN_H
-# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
-#endif
-
-#ifndef _BITS_BYTESWAP_H
-#define _BITS_BYTESWAP_H 1
-
-/* Swap bytes in 16 bit value. */
-#if defined __GNUC__
-# define __bswap_16(x) (__extension__ __builtin_bswap_16(x))
-#else
-/* This is better than nothing. */
-static __inline__ unsigned short int
-__bswap_16 (unsigned short int __bsx)
-{
- return ((((__bsx) >> 8) & 0xff) | (((__bsx) & 0xff) << 8));
-}
-#endif
-
-/* Swap bytes in 32 bit value. */
-#if defined __GNUC__
-# define __bswap_32(x) (__extension__ __builtin_bswap_32(x))
-#else
-static __inline__ unsigned int
-__bswap_32 (unsigned int __bsx)
-{
- return ((((__bsx) & 0xff000000) >> 24) | (((__bsx) & 0x00ff0000) >> 8) |
- (((__bsx) & 0x0000ff00) << 8) | (((__bsx) & 0x000000ff) << 24));
-}
-#endif
-
-#if defined __GNUC__
-/* Swap bytes in 64 bit value. */
-# define __bswap_constant_64(x) \
- ((((x) & 0xff00000000000000ull) >> 56) \
- | (((x) & 0x00ff000000000000ull) >> 40) \
- | (((x) & 0x0000ff0000000000ull) >> 24) \
- | (((x) & 0x000000ff00000000ull) >> 8) \
- | (((x) & 0x00000000ff000000ull) << 8) \
- | (((x) & 0x0000000000ff0000ull) << 24) \
- | (((x) & 0x000000000000ff00ull) << 40) \
- | (((x) & 0x00000000000000ffull) << 56))
-
-# define __bswap_64(x) \
- (__extension__ \
- ({ \
- union { \
- __extension__ unsigned long long int __ll; \
- unsigned int __l[2]; \
- } __w, __r; \
- if (__builtin_constant_p(x)) \
- __r.__ll = __bswap_constant_64(x); \
- else { \
- __w.__ll = (x); \
- __r.__l[0] = __bswap_32(__w.__l[1]); \
- __r.__l[1] = __bswap_32(__w.__l[0]); \
- } \
- __r.__ll; \
- }))
-#endif
-
-#endif /* _BITS_BYTESWAP_H */
diff --git a/libc/sysdeps/linux/avr32/bits/fcntl.h b/libc/sysdeps/linux/avr32/bits/fcntl.h
index 6dcb61ba7..5e325122d 100644
--- a/libc/sysdeps/linux/avr32/bits/fcntl.h
+++ b/libc/sysdeps/linux/avr32/bits/fcntl.h
@@ -30,6 +30,8 @@
# define O_DIRECTORY 00200000 /* direct disk access */
# define O_NOFOLLOW 00400000 /* don't follow links */
# define O_NOATIME 01000000 /* don't set atime */
+# define O_CLOEXEC 02000000 /* set close_on_exec */
+# define O_PATH 010000000 /* Resolve pathname but do not open file. */
#endif
#ifdef __USE_LARGEFILE64
@@ -167,8 +169,8 @@ struct flock64 {
# define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */
#endif
-#ifdef __USE_GNU
+#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
@@ -190,6 +192,9 @@ struct flock64 {
__BEGIN_DECLS
+/* 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);
diff --git a/libc/sysdeps/linux/avr32/bits/kernel_stat.h b/libc/sysdeps/linux/avr32/bits/kernel_stat.h
index f97d23bc5..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.
@@ -21,18 +17,13 @@ struct kernel_stat {
unsigned long st_size;
unsigned long st_blksize;
unsigned long st_blocks;
- unsigned long st_atime;
- unsigned long st_atime_nsec;
- unsigned long st_mtime;
- unsigned long st_mtime_nsec;
- unsigned long st_ctime;
- unsigned long st_ctime_nsec;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
unsigned long __unused4;
unsigned long __unused5;
};
-#define STAT_HAVE_NSEC 1
-
struct kernel_stat64 {
unsigned long long st_dev;
@@ -51,14 +42,9 @@ struct kernel_stat64 {
unsigned long long st_blocks;
- unsigned long st_atime;
- unsigned long st_atime_nsec;
-
- unsigned long st_mtime;
- unsigned long st_mtime_nsec;
-
- unsigned long st_ctime;
- unsigned long st_ctime_nsec;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
unsigned long __unused1;
unsigned long __unused2;
diff --git a/libc/sysdeps/linux/avr32/bits/kernel_types.h b/libc/sysdeps/linux/avr32/bits/kernel_types.h
index f7d8b5298..c551d5785 100644
--- a/libc/sysdeps/linux/avr32/bits/kernel_types.h
+++ b/libc/sysdeps/linux/avr32/bits/kernel_types.h
@@ -39,6 +39,8 @@ typedef unsigned int __kernel_gid32_t;
typedef unsigned short __kernel_old_uid_t;
typedef unsigned short __kernel_old_gid_t;
typedef unsigned short __kernel_old_dev_t;
+typedef long __kernel_long_t;
+typedef unsigned long __kernel_ulong_t;
#ifdef __GNUC__
typedef long long __kernel_loff_t;
diff --git a/libc/sysdeps/linux/avr32/bits/mman.h b/libc/sysdeps/linux/avr32/bits/mman.h
deleted file mode 100644
index 5f6e3c37a..000000000
--- a/libc/sysdeps/linux/avr32/bits/mman.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/* Definitions for POSIX memory map interface. Linux/AVR32 version.
- Copyright (C) 1997, 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 _SYS_MMAN_H
-# error "Never include this file directly. Use <sys/mman.h> instead"
-#endif
-
-/* The following definitions basically come from the kernel headers.
- But the kernel header is not namespace clean. */
-
-
-/* Protections are chosen from these bits, OR'd together. The
- implementation does not necessarily support PROT_EXEC or PROT_WRITE
- without PROT_READ. The only guarantees are that no writing will be
- allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
-
-#define PROT_READ 0x1 /* Page can be read. */
-#define PROT_WRITE 0x2 /* Page can be written. */
-#define PROT_EXEC 0x4 /* Page can be executed. */
-#define PROT_NONE 0x0 /* Page can not be accessed. */
-#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of
- growsdown vma (mprotect only). */
-#define PROT_GROWSUP 0x02000000 /* Extend change to start of
- growsup vma (mprotect only). */
-
-/* Sharing types (must choose one and only one of these). */
-#define MAP_SHARED 0x01 /* Share changes. */
-#define MAP_PRIVATE 0x02 /* Changes are private. */
-#ifdef __USE_MISC
-# define MAP_TYPE 0x0f /* Mask for type of mapping. */
-#endif
-
-/* Other flags. */
-#define MAP_FIXED 0x10 /* Interpret addr exactly. */
-#ifdef __USE_MISC
-# define MAP_FILE 0
-# define MAP_ANONYMOUS 0x20 /* Don't use a file. */
-# define MAP_ANON MAP_ANONYMOUS
-#endif
-
-/* These are Linux-specific. */
-#ifdef __USE_MISC
-# define MAP_GROWSDOWN 0x0100 /* Stack-like segment. */
-# define MAP_DENYWRITE 0x0800 /* ETXTBSY */
-# define MAP_EXECUTABLE 0x1000 /* Mark it as an executable. */
-# define MAP_LOCKED 0x2000 /* Lock the mapping. */
-# define MAP_NORESERVE 0x4000 /* Don't check for reservations. */
-# define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */
-# define MAP_NONBLOCK 0x10000 /* do not block on IO */
-#endif
-
-/* Flags to `msync'. */
-#define MS_ASYNC 1 /* Sync memory asynchronously. */
-#define MS_SYNC 4 /* Synchronous memory sync. */
-#define MS_INVALIDATE 2 /* Invalidate the caches. */
-
-/* Flags for `mlockall'. */
-#define MCL_CURRENT 1 /* Lock all currently mapped pages. */
-#define MCL_FUTURE 2 /* Lock all additions to address
- space. */
-
-/* Flags for `mremap'. */
-#ifdef __USE_GNU
-# define MREMAP_MAYMOVE 1
-# define MREMAP_FIXED 2
-#endif
-
-/* Advise to `madvise'. */
-#ifdef __USE_BSD
-# define MADV_NORMAL 0 /* No further special treatment. */
-# define MADV_RANDOM 1 /* Expect random page references. */
-# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
-# define MADV_WILLNEED 3 /* Will need these pages. */
-# define MADV_DONTNEED 4 /* Don't need these pages. */
-# define MADV_REMOVE 9 /* Remove these pages and resources. */
-# define MADV_DONTFORK 10 /* Do not inherit across fork. */
-# define MADV_DOFORK 11 /* Do inherit across fork. */
-#endif
-
-/* The POSIX people had to invent similar names for the same things. */
-#ifdef __USE_XOPEN2K
-# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
-# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
-# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
-# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
-# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
-#endif
diff --git a/libc/sysdeps/linux/avr32/bits/setjmp.h b/libc/sysdeps/linux/avr32/bits/setjmp.h
index 78348a329..3f8f14f2d 100644
--- a/libc/sysdeps/linux/avr32/bits/setjmp.h
+++ b/libc/sysdeps/linux/avr32/bits/setjmp.h
@@ -12,19 +12,10 @@
# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
#endif
-#ifndef _ASM
/*
* The jump buffer contains r0-r7, sr, sp and lr. Other registers are
* not saved.
*/
typedef int __jmp_buf[11];
-#endif
-
-#define __JMP_BUF_SP 4
-
-/* Test if longjmp to JMPBUF would unwind the frame containing a local
- variable at ADDRESS. */
-#define _JMPBUF_UNWINDS(jmpbuf, address) \
- ((void *)(address) < (void *)(jmpbuf[__JMP_BUF_SP]))
#endif /* _BITS_SETJMP_H */
diff --git a/libc/sysdeps/linux/avr32/bits/stackinfo.h b/libc/sysdeps/linux/avr32/bits/stackinfo.h
index 2c17d30a7..9e912452e 100644
--- a/libc/sysdeps/linux/avr32/bits/stackinfo.h
+++ b/libc/sysdeps/linux/avr32/bits/stackinfo.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* This file contains a bit of information about the stack allocation
of the processor. */
diff --git a/libc/sysdeps/linux/avr32/bits/syscalls.h b/libc/sysdeps/linux/avr32/bits/syscalls.h
index ff5d1a7be..70dc1d958 100644
--- a/libc/sysdeps/linux/avr32/bits/syscalls.h
+++ b/libc/sysdeps/linux/avr32/bits/syscalls.h
@@ -4,140 +4,52 @@
# error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
#endif
-/*
- * This includes the `__NR_<name>' syscall numbers taken from the
- * Linux kernel header files. It also defines the traditional
- * `SYS_<name>' macros for older programs.
- */
-#include <bits/sysnum.h>
-
#ifndef __ASSEMBLER__
#include <errno.h>
-#define SYS_ify(syscall_name) (__NR_##syscall_name)
-
-#undef _syscall0
-#define _syscall0(type,name) \
- type name(void) \
- { \
- return (type)(INLINE_SYSCALL(name, 0)); \
- }
-
-#undef _syscall1
-#define _syscall1(type,name,type1,arg1) \
- type name(type1 arg1) \
- { \
- return (type)(INLINE_SYSCALL(name, 1, arg1)); \
- }
-
-#undef _syscall2
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
- type name(type1 arg1, type2 arg2) \
- { \
- return (type)(INLINE_SYSCALL(name, 2, arg1, arg2)); \
- }
-
-#undef _syscall3
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
- type name(type1 arg1, type2 arg2, type3 arg3) \
- { \
- return (type)(INLINE_SYSCALL(name, 3, arg1, \
- arg2, arg3)); \
- }
-
-#undef _syscall4
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3, \
- type4,arg4) \
- type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
- { \
- return (type)(INLINE_SYSCALL(name, 4, arg1, arg2, \
- arg3, arg4)); \
- }
-
-#undef _syscall5
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3, \
- type4,arg4,type5,arg5) \
- type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
- type5 arg5) \
- { \
- return (type)(INLINE_SYSCALL(name, 5, arg1, arg2, \
- arg3, arg4, arg5)); \
- }
-
-#undef _syscall6
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3, \
- type4,arg4,type5,arg5,type6,arg6) \
- type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
- type5 arg5, type6 arg6) \
- { \
- return (type)(INLINE_SYSCALL(name, 6, arg1, arg2, arg3, \
- arg4, arg5, arg6)); \
- }
-
-#undef unlikely
-#define unlikely(x) __builtin_expect((x), 0)
-
-#undef INLINE_SYSCALL
-#define INLINE_SYSCALL(name, nr, args...) \
+#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+(__extension__ \
({ \
- unsigned _sys_result = INTERNAL_SYSCALL(name, , nr, args); \
- if (unlikely(INTERNAL_SYSCALL_ERROR_P(_sys_result, ))) { \
- __set_errno(INTERNAL_SYSCALL_ERRNO(_sys_result, )); \
- _sys_result = (unsigned int) -1; \
- } \
- (int) _sys_result; \
- })
-
-#undef INTERNAL_SYSCALL_DECL
-#define INTERNAL_SYSCALL_DECL(err) do { } while(0)
-
-#undef INTERNAL_SYSCALL
-#define INTERNAL_SYSCALL(name, err, nr, args...) \
- ({ \
- register int _a1 __asm__("r12"); \
- register int _scno __asm__("r8") = SYS_ify(name); \
+ register int __a1 __asm__("r12"); \
+ register int _scno __asm__("r8") = name; \
LOAD_ARGS_##nr (args); \
__asm__ __volatile__("scall /* syscall " #name " */" \
- : "=r" (_a1) \
+ : "=r" (__a1) \
: "r"(_scno) ASM_ARGS_##nr \
: "cc", "memory"); \
- _a1; \
- })
-
-#undef INTERNAL_SYSCALL_ERROR_P
+ __a1; \
+ }) \
+)
#define INTERNAL_SYSCALL_ERROR_P(val, err) \
((unsigned int)(val) >= 0xfffff001U)
-#undef INTERNAL_SYSCALL_ERRNO
-#define INTERNAL_SYSCALL_ERRNO(val, errr) (-(val))
-
#define LOAD_ARGS_0() do { } while(0)
#define ASM_ARGS_0
#define LOAD_ARGS_1(a1) \
- _a1 = (int) (a1); \
+ __a1 = (int) (a1); \
LOAD_ARGS_0()
-#define ASM_ARGS_1 ASM_ARGS_0, "r"(_a1)
+#define ASM_ARGS_1 ASM_ARGS_0, "r"(__a1)
#define LOAD_ARGS_2(a1, a2) \
- register int _a2 __asm__("r11") = (int)(a2); \
+ register int __a2 __asm__("r11") = (int)(a2); \
LOAD_ARGS_1(a1)
-#define ASM_ARGS_2 ASM_ARGS_1, "r"(_a2)
+#define ASM_ARGS_2 ASM_ARGS_1, "r"(__a2)
#define LOAD_ARGS_3(a1, a2, a3) \
- register int _a3 __asm__("r10") = (int)(a3); \
+ register int __a3 __asm__("r10") = (int)(a3); \
LOAD_ARGS_2(a1, a2)
-#define ASM_ARGS_3 ASM_ARGS_2, "r"(_a3)
+#define ASM_ARGS_3 ASM_ARGS_2, "r"(__a3)
#define LOAD_ARGS_4(a1, a2, a3, a4) \
- register int _a4 __asm__("r9") = (int)(a4); \
+ register int __a4 __asm__("r9") = (int)(a4); \
LOAD_ARGS_3(a1, a2, a3)
-#define ASM_ARGS_4 ASM_ARGS_3, "r"(_a4)
+#define ASM_ARGS_4 ASM_ARGS_3, "r"(__a4)
#define LOAD_ARGS_5(a1, a2, a3, a4, a5) \
- register int _a5 __asm__("r5") = (int)(a5); \
+ register int __a5 __asm__("r5") = (int)(a5); \
LOAD_ARGS_4(a1, a2, a3, a4)
-#define ASM_ARGS_5 ASM_ARGS_4, "r"(_a5)
+#define ASM_ARGS_5 ASM_ARGS_4, "r"(__a5)
#define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6) \
- register int _a6 __asm__("r3") = (int)(a6); \
+ register int __a6 __asm__("r3") = (int)(a6); \
LOAD_ARGS_5(a1, a2, a3, a4, a5)
-#define ASM_ARGS_6 ASM_ARGS_5, "r"(_a6)
+#define ASM_ARGS_6 ASM_ARGS_5, "r"(__a6)
#endif /* __ASSEMBLER__ */
#endif /* _BITS_SYSCALLS_H */
diff --git a/libc/sysdeps/linux/avr32/bits/uClibc_arch_features.h b/libc/sysdeps/linux/avr32/bits/uClibc_arch_features.h
index 679be3038..cb0eae804 100644
--- a/libc/sysdeps/linux/avr32/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/avr32/bits/uClibc_arch_features.h
@@ -12,8 +12,8 @@
/* 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 align 64bit values in register pairs ? (32bit arches only) */
+#undef __UCLIBC_SYSCALL_ALIGN_64BIT__
/* does your target have a broken create_module() ? */
#undef __UCLIBC_BROKEN_CREATE_MODULE__
@@ -24,19 +24,19 @@
/* 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 */
+#undef __UCLIBC_ASM_LINE_SEP__
+
#endif /* _BITS_UCLIBC_ARCH_FEATURES_H */
diff --git a/libc/sysdeps/linux/avr32/brk.c b/libc/sysdeps/linux/avr32/brk.c
index a54b49a61..58f04f95d 100644
--- a/libc/sysdeps/linux/avr32/brk.c
+++ b/libc/sysdeps/linux/avr32/brk.c
@@ -9,7 +9,6 @@
#include <unistd.h>
#include <sys/syscall.h>
-libc_hidden_proto(brk)
void *__curbrk attribute_hidden = 0;
diff --git a/libc/sysdeps/linux/avr32/clone.c b/libc/sysdeps/linux/avr32/clone.c
index e43b0f3bf..06e3388b8 100644
--- a/libc/sysdeps/linux/avr32/clone.c
+++ b/libc/sysdeps/linux/avr32/clone.c
@@ -5,6 +5,7 @@
* Public License. See the file "COPYING.LIB" in the main directory of this
* archive for more details.
*/
+#include <sched.h>
#include <errno.h>
#include <sys/syscall.h>
#include <unistd.h>
@@ -14,7 +15,7 @@
* parameters are preserved when returning as the child. If the
* compiler stores them in registers (r0-r7), they should be.
*/
-int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg)
+int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg, ...)
{
register int (*_fn)(void *arg) = fn;
register void *_arg = arg;
diff --git a/libc/sysdeps/linux/avr32/crtn.S b/libc/sysdeps/linux/avr32/crtn.S
index f7d104070..c37f7d201 100644
--- a/libc/sysdeps/linux/avr32/crtn.S
+++ b/libc/sysdeps/linux/avr32/crtn.S
@@ -4,11 +4,9 @@
.global _init
.type _init, @function
ldm sp++, r6, pc
- .size _init, . - _init
.section .fini
.align 2
.global _fini
.type _fini, @function
ldm sp++, r6, pc
- .size _fini, . - _fini
diff --git a/libc/sysdeps/linux/avr32/jmpbuf-offsets.h b/libc/sysdeps/linux/avr32/jmpbuf-offsets.h
new file mode 100644
index 000000000..70b8113e3
--- /dev/null
+++ b/libc/sysdeps/linux/avr32/jmpbuf-offsets.h
@@ -0,0 +1,9 @@
+/* Private macros for accessing __jmp_buf contents. avr32 version.
+ * Copyright (C) 2004-2005 Atmel Corporation
+ *
+ * This file is subject to the terms and conditions of the GNU Lesser General
+ * Public License. See the file "COPYING.LIB" in the main directory of this
+ * archive for more details.
+ */
+
+#define __JMP_BUF_SP 4
diff --git a/libc/sysdeps/linux/avr32/jmpbuf-unwind.h b/libc/sysdeps/linux/avr32/jmpbuf-unwind.h
new file mode 100644
index 000000000..5caa2ee44
--- /dev/null
+++ b/libc/sysdeps/linux/avr32/jmpbuf-unwind.h
@@ -0,0 +1,14 @@
+/*
+ * Copyright (C) 2004-2005 Atmel Corporation
+ *
+ * This file is subject to the terms and conditions of the GNU Lesser General
+ * Public License. See the file "COPYING.LIB" in the main directory of this
+ * archive for more details.
+ */
+#include <setjmp.h>
+#include <jmpbuf-offsets.h>
+
+/* Test if longjmp to JMPBUF would unwind the frame containing a local
+ variable at ADDRESS. */
+#define _JMPBUF_UNWINDS(jmpbuf, address) \
+ ((void *)(address) < (void *)(jmpbuf[__JMP_BUF_SP]))
diff --git a/libc/sysdeps/linux/avr32/mmap.c b/libc/sysdeps/linux/avr32/mmap.c
index 2ee025a26..cd3315810 100644
--- a/libc/sysdeps/linux/avr32/mmap.c
+++ b/libc/sysdeps/linux/avr32/mmap.c
@@ -11,12 +11,11 @@
#include <sys/mman.h>
#include <sys/syscall.h>
-libc_hidden_proto(mmap)
-static _syscall6(__ptr_t, mmap2, __ptr_t, addr, size_t, len, int, prot,
- int, flags, int, fd, __off_t, pgoff);
+static __inline__ _syscall6(void *, mmap2, void *, addr, size_t, len, int, prot,
+ int, flags, int, fd, __off_t, pgoff)
-__ptr_t mmap(__ptr_t addr, size_t len, int prot, int flags, int fd, __off_t offset)
+void *mmap(void *addr, size_t len, int prot, int flags, int fd, __off_t offset)
{
unsigned long page_size = sysconf(_SC_PAGESIZE);
unsigned long pgoff;
diff --git a/libc/sysdeps/linux/avr32/prctl.c b/libc/sysdeps/linux/avr32/prctl.c
new file mode 100644
index 000000000..4e146e35e
--- /dev/null
+++ b/libc/sysdeps/linux/avr32/prctl.c
@@ -0,0 +1,36 @@
+/*
+ * prctl syscall for AVR32 Linux.
+ *
+ * Copyright (C) 2010 Atmel Corporation
+ *
+ * This file is subject to the terms and conditions of the GNU Lesser General
+ * Public License. See the file "COPYING.LIB" in the main directory of this
+ * archive for more details.
+ */
+#include <sys/syscall.h>
+#include <sys/prctl.h>
+#include <stdarg.h>
+
+#ifdef __NR_prctl
+#define __NR___syscall_prctl __NR_prctl
+static inline _syscall5(int, __syscall_prctl, int, option, long, arg2,
+ long, arg3, long, arg4, long, arg5);
+
+int prctl(int __option, ...)
+{
+ long arg2;
+ long arg3;
+ long arg4;
+ long arg5;
+ va_list ap;
+
+ va_start(ap, __option);
+ arg2 = va_arg(ap, long);
+ arg3 = va_arg(ap, long);
+ arg4 = va_arg(ap, long);
+ arg5 = va_arg(ap, long);
+ va_end(ap);
+
+ return INLINE_SYSCALL(prctl, 5, __option, arg2, arg3, arg4, arg5);
+}
+#endif
diff --git a/libc/sysdeps/linux/avr32/setjmp.S b/libc/sysdeps/linux/avr32/setjmp.S
index 7d0354be9..f6e619b90 100644
--- a/libc/sysdeps/linux/avr32/setjmp.S
+++ b/libc/sysdeps/linux/avr32/setjmp.S
@@ -5,9 +5,6 @@
* Public License. See the file "COPYING.LIB" in the main directory of this
* archive for more details.
*/
-#define _SETJMP_H
-#define _ASM
-#include <bits/setjmp.h>
.text
diff --git a/libc/sysdeps/linux/avr32/sigaction.c b/libc/sysdeps/linux/avr32/sigaction.c
index 6b6b3466c..f82d109df 100644
--- a/libc/sysdeps/linux/avr32/sigaction.c
+++ b/libc/sysdeps/linux/avr32/sigaction.c
@@ -14,46 +14,33 @@
#define SA_RESTORER 0x04000000
extern void __default_rt_sa_restorer(void);
-/* Experimentally off - libc_hidden_proto(memcpy) */
-
/*
* 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 signum, const struct sigaction *act,
- struct sigaction *oldact)
+int __libc_sigaction(int sig, const struct sigaction *act,
+ struct sigaction *oact)
{
- struct kernel_sigaction kact, koact;
- int result;
+ struct sigaction kact;
- 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;
- if (kact.sa_flags & SA_RESTORER)
- kact.sa_restorer = act->sa_restorer;
- else
- kact.sa_restorer = __default_rt_sa_restorer;
+ if (act && !(act->sa_flags & SA_RESTORER)) {
+ memcpy(&kact, act, sizeof(kact));
+ kact.sa_restorer = __default_rt_sa_restorer;
kact.sa_flags |= SA_RESTORER;
+ act = &kact;
}
- result = __syscall_rt_sigaction(signum, act ? __ptrvalue(&kact) : NULL,
- oldact ? __ptrvalue(&koact) : NULL,
- _NSIG / 8);
-
- if (oldact && result >= 0) {
- oldact->sa_handler = koact.k_sa_handler;
- memcpy(&oldact->sa_mask, &koact.sa_mask,
- sizeof(oldact->sa_mask));
- oldact->sa_flags = koact.sa_flags;
- oldact->sa_restorer = koact.sa_restorer;
- }
-
- return result;
+ /* NB: kernel (as of 2.6.25) will return EINVAL
+ * if sizeof(act->sa_mask) does not match kernel's sizeof(sigset_t) */
+ return __syscall_rt_sigaction(sig, act, oact, sizeof(act->sa_mask));
}
#ifndef LIBC_SIGACTION
-libc_hidden_proto(sigaction)
-weak_alias(__libc_sigaction, sigaction)
+# ifndef __UCLIBC_HAS_THREADS__
+strong_alias(__libc_sigaction,sigaction)
+libc_hidden_def(sigaction)
+# else
+weak_alias(__libc_sigaction,sigaction)
libc_hidden_weak(sigaction)
+# endif
#endif
diff --git a/libc/sysdeps/linux/avr32/sys/elf.h b/libc/sysdeps/linux/avr32/sys/elf.h
index faa731068..4c06715da 100644
--- a/libc/sysdeps/linux/avr32/sys/elf.h
+++ b/libc/sysdeps/linux/avr32/sys/elf.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_ELF_H
#define _SYS_ELF_H 1
diff --git a/libc/sysdeps/linux/avr32/sys/procfs.h b/libc/sysdeps/linux/avr32/sys/procfs.h
index 3b3736324..14f233a63 100644
--- a/libc/sysdeps/linux/avr32/sys/procfs.h
+++ b/libc/sysdeps/linux/avr32/sys/procfs.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_PROCFS_H
#define _SYS_PROCFS_H 1
diff --git a/libc/sysdeps/linux/avr32/sys/ucontext.h b/libc/sysdeps/linux/avr32/sys/ucontext.h
index 82c7fe24a..66c846198 100644
--- a/libc/sysdeps/linux/avr32/sys/ucontext.h
+++ b/libc/sysdeps/linux/avr32/sys/ucontext.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* Linux/AVR32 ABI compliant context switching support. */
diff --git a/libc/sysdeps/linux/avr32/vfork.S b/libc/sysdeps/linux/avr32/vfork.S
index 03ca99f65..b2c5ceb55 100644
--- a/libc/sysdeps/linux/avr32/vfork.S
+++ b/libc/sysdeps/linux/avr32/vfork.S
@@ -17,10 +17,10 @@
* Fortunately, the Linux kernel preserves LR across system calls.
*/
-#include <features.h>
#include <sys/syscall.h>
.global __vfork
+ .hidden __vfork
.type __vfork,@function
.align 1
__vfork:
@@ -55,4 +55,4 @@ __vfork:
.size __vfork, . - __vfork
weak_alias(__vfork,vfork)
-libc_hidden_weak(vfork)
+libc_hidden_def(vfork)
diff --git a/libc/sysdeps/linux/bfin/Makefile.arch b/libc/sysdeps/linux/bfin/Makefile.arch
index 6c271509e..8e945cdea 100644
--- a/libc/sysdeps/linux/bfin/Makefile.arch
+++ b/libc/sysdeps/linux/bfin/Makefile.arch
@@ -5,11 +5,11 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-CSRC := brk.c bsdsetjmp.c clone.c syscall.c \
+CSRC-y := bsdsetjmp.c clone.c \
sram-alloc.c sram-free.c dma-memcpy.c
-SSRC := __longjmp.S setjmp.S bsd-_setjmp.S vfork.S
+SSRC-y := __longjmp.S setjmp.S bsd-_setjmp.S vfork.S
-ARCH_HEADERS := bfin_l1layout.h bfin_sram.h
+CSRC-$(UCLIBC_LINUX_SPECIFIC) += cacheflush.c
-include $(top_srcdir)libc/sysdeps/linux/Makefile.commonarch
+ARCH_HEADERS := bfin_fixed_code.h bfin_l1layout.h bfin_sram.h
diff --git a/libc/sysdeps/linux/bfin/__longjmp.S b/libc/sysdeps/linux/bfin/__longjmp.S
index 418d591e2..b2fafbb25 100644
--- a/libc/sysdeps/linux/bfin/__longjmp.S
+++ b/libc/sysdeps/linux/bfin/__longjmp.S
@@ -15,7 +15,7 @@
___longjmp:
P0 = R0;
R0 = [P0 + 0x00];
- [--SP] = R0; // Put P0 on the stack
+ [--SP] = R0; /* Put P0 on the stack */
P1 = [P0 + 0x04];
P2 = [P0 + 0x08];
@@ -24,12 +24,12 @@ ___longjmp:
P5 = [P0 + 0x14];
FP = [P0 + 0x18];
- R0 = [SP++]; // Grab P0 from old stack
- SP = [P0 + 0x1C]; // Update Stack Pointer
- [--SP] = R0; // Put P0 on new stack
- [--SP] = R1; // Put VAL arg on new stack
+ R0 = [SP++]; /* Grab P0 from old stack */
+ SP = [P0 + 0x1C]; /* Update Stack Pointer */
+ [--SP] = R0; /* Put P0 on new stack */
+ [--SP] = R1; /* Put VAL arg on new stack */
- R0 = [P0 + 0x20]; // Data Registers
+ R0 = [P0 + 0x20]; /* Data Registers */
R1 = [P0 + 0x24];
R2 = [P0 + 0x28];
R3 = [P0 + 0x2C];
@@ -41,12 +41,12 @@ ___longjmp:
R0 = [P0 + 0x40];
ASTAT = R0;
- R0 = [P0 + 0x44]; // Loop Counters
+ R0 = [P0 + 0x44]; /* Loop Counters */
LC0 = R0;
R0 = [P0 + 0x48];
LC1 = R0;
- R0 = [P0 + 0x4C]; // Accumulators
+ R0 = [P0 + 0x4C]; /* Accumulators */
A0.W = R0;
R0 = [P0 + 0x50];
A0.X = R0;
@@ -55,7 +55,7 @@ ___longjmp:
R0 = [P0 + 0x58];
A1.X = R0;
- R0 = [P0 + 0x5C]; // Index Registers
+ R0 = [P0 + 0x5C]; /* Index Registers */
I0 = R0;
R0 = [P0 + 0x60];
I1 = R0;
@@ -64,7 +64,7 @@ ___longjmp:
R0 = [P0 + 0x68];
I3 = R0;
- R0 = [P0 + 0x6C]; // Modifier Registers
+ R0 = [P0 + 0x6C]; /* Modifier Registers */
M0 = R0;
R0 = [P0 + 0x70];
M1 = R0;
@@ -73,7 +73,7 @@ ___longjmp:
R0 = [P0 + 0x78];
M3 = R0;
- R0 = [P0 + 0x7C]; // Length Registers
+ R0 = [P0 + 0x7C]; /* Length Registers */
L0 = R0;
R0 = [P0 + 0x80];
L1 = R0;
@@ -82,7 +82,7 @@ ___longjmp:
R0 = [P0 + 0x88];
L3 = R0;
- R0 = [P0 + 0x8C]; // Base Registers
+ R0 = [P0 + 0x8C]; /* Base Registers */
B0 = R0;
R0 = [P0 + 0x90];
B1 = R0;
@@ -91,7 +91,7 @@ ___longjmp:
R0 = [P0 + 0x98];
B3 = R0;
- R0 = [P0 + 0x9C]; // Return Address (PC)
+ R0 = [P0 + 0x9C]; /* Return Address (PC) */
RETS = R0;
R0 = [SP++];
@@ -105,3 +105,5 @@ ___longjmp:
.size ___longjmp,.-___longjmp
libc_hidden_def(__longjmp)
+
+.section .note.GNU-stack,"",%progbits
diff --git a/libc/sysdeps/linux/bfin/bfin_fixed_code.h b/libc/sysdeps/linux/bfin/bfin_fixed_code.h
new file mode 100644
index 000000000..914257156
--- /dev/null
+++ b/libc/sysdeps/linux/bfin/bfin_fixed_code.h
@@ -0,0 +1,155 @@
+/* Atomic instructions for userspace.
+ *
+ * The actual implementations can be found in the kernel.
+ *
+ * Copyright (c) 2008 Analog Devices, Inc.
+ *
+ * Licensed under the LGPL v2.1.
+ */
+
+#ifndef __BFIN_FIXED_CODE_H__
+#define __BFIN_FIXED_CODE_H__
+
+#include <stdint.h>
+
+#include <asm/fixed_code.h>
+
+#ifndef __ASSEMBLY__
+
+static inline
+uint32_t bfin_atomic_xchg32(uint32_t *__bfin_ptr, uint32_t __bfin_newval)
+{
+ uint32_t __bfin_ret;
+ /* Input: P0: memory address to use
+ * R1: value to store
+ * Output: R0: old contents of the memory address
+ */
+ __asm__ __volatile__(
+ "CALL (%[__bfin_func])"
+ : "=q0" (__bfin_ret), "=m" (*__bfin_ptr)
+ : [__bfin_func] "a" (ATOMIC_XCHG32), "q1" (__bfin_newval),
+ "qA" (__bfin_ptr), "m" (*__bfin_ptr)
+ : "RETS", "memory"
+ );
+ return __bfin_ret;
+}
+
+static inline
+uint32_t bfin_atomic_cas32(uint32_t *__bfin_ptr, uint32_t __bfin_exp, uint32_t __bfin_newval)
+{
+ uint32_t __bfin_ret;
+ /* Input: P0: memory address to use
+ * R1: compare value
+ * R2: new value to store
+ * Output: R0: old contents of the memory address
+ */
+ __asm__ __volatile__(
+ "CALL (%[__bfin_func])"
+ : "=q0" (__bfin_ret), "=m" (*__bfin_ptr)
+ : [__bfin_func] "a" (ATOMIC_CAS32), "q1" (__bfin_exp), "q2" (__bfin_newval),
+ "qA" (__bfin_ptr), "m" (*__bfin_ptr)
+ : "RETS", "memory"
+ );
+ return __bfin_ret;
+}
+
+static inline
+uint32_t bfin_atomic_add32(uint32_t *__bfin_ptr, uint32_t __bfin_inc)
+{
+ uint32_t __bfin_ret;
+ /* Input: P0: memory address to use
+ * R0: value to add
+ * Output: R0: new contents of the memory address
+ * R1: previous contents of the memory address
+ */
+ __asm__ __volatile__(
+ "CALL (%[__bfin_func])"
+ : "=q0" (__bfin_ret), "=m" (*__bfin_ptr)
+ : [__bfin_func] "a" (ATOMIC_ADD32), "q0" (__bfin_inc),
+ "qA" (__bfin_ptr), "m" (*__bfin_ptr)
+ : "R1", "RETS", "memory"
+ );
+ return __bfin_ret;
+}
+#define bfin_atomic_inc32(ptr) bfin_atomic_add32(ptr, 1)
+
+static inline
+uint32_t bfin_atomic_sub32(uint32_t *__bfin_ptr, uint32_t __bfin_dec)
+{
+ uint32_t __bfin_ret;
+ /* Input: P0: memory address to use
+ * R0: value to subtract
+ * Output: R0: new contents of the memory address
+ * R1: previous contents of the memory address
+ */
+ __asm__ __volatile__(
+ "CALL (%[__bfin_func])"
+ : "=q0" (__bfin_ret), "=m" (*__bfin_ptr)
+ : [__bfin_func] "a" (ATOMIC_SUB32), "q0" (__bfin_dec),
+ "qA" (__bfin_ptr), "m" (*__bfin_ptr)
+ : "R1", "RETS", "memory"
+ );
+ return __bfin_ret;
+}
+#define bfin_atomic_dec32(ptr) bfin_atomic_sub32(ptr, 1)
+
+static inline
+uint32_t bfin_atomic_ior32(uint32_t *__bfin_ptr, uint32_t __bfin_ior)
+{
+ uint32_t __bfin_ret;
+ /* Input: P0: memory address to use
+ * R0: value to ior
+ * Output: R0: new contents of the memory address
+ * R1: previous contents of the memory address
+ */
+ __asm__ __volatile__(
+ "CALL (%[__bfin_func])"
+ : "=q0" (__bfin_ret), "=m" (*__bfin_ptr)
+ : [__bfin_func] "a" (ATOMIC_IOR32), "q0" (__bfin_ior),
+ "qA" (__bfin_ptr), "m" (*__bfin_ptr)
+ : "R1", "RETS", "memory"
+ );
+ return __bfin_ret;
+}
+
+static inline
+uint32_t bfin_atomic_and32(uint32_t *__bfin_ptr, uint32_t __bfin_and)
+{
+ uint32_t __bfin_ret;
+ /* Input: P0: memory address to use
+ * R0: value to and
+ * Output: R0: new contents of the memory address
+ * R1: previous contents of the memory address
+ */
+ __asm__ __volatile__(
+ "CALL (%[__bfin_func])"
+ : "=q0" (__bfin_ret), "=m" (*__bfin_ptr)
+ : [__bfin_func] "a" (ATOMIC_AND32), "q0" (__bfin_and),
+ "qA" (__bfin_ptr), "m" (*__bfin_ptr)
+ : "R1", "RETS", "memory"
+ );
+ return __bfin_ret;
+}
+
+static inline
+uint32_t bfin_atomic_xor32(uint32_t *__bfin_ptr, uint32_t __bfin_xor)
+{
+ uint32_t __bfin_ret;
+ /* Input: P0: memory address to use
+ * R0: value to xor
+ * Output: R0: new contents of the memory address
+ * R1: previous contents of the memory address
+ */
+ __asm__ __volatile__(
+ "CALL (%[__bfin_func])"
+ : "=q0" (__bfin_ret), "=m" (*__bfin_ptr)
+ : [__bfin_func] "a" (ATOMIC_XOR32), "q0" (__bfin_xor),
+ "qA" (__bfin_ptr), "m" (*__bfin_ptr)
+ : "R1", "RETS", "memory"
+ );
+ return __bfin_ret;
+}
+
+#endif
+
+#endif
diff --git a/libc/sysdeps/linux/bfin/bfin_sram.h b/libc/sysdeps/linux/bfin/bfin_sram.h
index eea729b05..278514d5d 100644
--- a/libc/sysdeps/linux/bfin/bfin_sram.h
+++ b/libc/sysdeps/linux/bfin/bfin_sram.h
@@ -18,6 +18,7 @@ __BEGIN_DECLS
#define L1_DATA_A_SRAM 0x00000002
#define L1_DATA_B_SRAM 0x00000004
#define L1_DATA_SRAM 0x00000006
+#define L2_SRAM 0x00000008
extern void *sram_alloc(size_t size, unsigned long flags)
__attribute_malloc__ __attribute_warn_unused_result__;
diff --git a/libc/sysdeps/linux/bfin/bits/byteswap.h b/libc/sysdeps/linux/bfin/bits/byteswap.h
index 74b87d94c..a72700254 100644
--- a/libc/sysdeps/linux/bfin/bits/byteswap.h
+++ b/libc/sysdeps/linux/bfin/bits/byteswap.h
@@ -7,88 +7,28 @@
* Licensed under the GPL-2 or later.
*/
-#if !defined _BYTESWAP_H && !defined _NETINET_IN_H
-# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
-#endif
-
-#ifndef _BITS_BYTESWAP_H
-#define _BITS_BYTESWAP_H 1
+#ifndef _ASM_BITS_BYTESWAP_H
+#define _ASM_BITS_BYTESWAP_H 1
-/* Swap bytes in 16 bit value. */
-#define __bswap_constant_16(x) \
- ((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8))
-
-#ifdef __GNUC__
-# define __bswap_16(x) \
+#define __bswap_non_constant_16(x) \
(__extension__ \
- ({ register unsigned short int __v, __x = (x); \
- if (__builtin_constant_p (__x)) \
- __v = __bswap_constant_16 (__x); \
- else \
- __asm__ ("%0 = PACK (%1.L, %1.L);" \
- "%0 >>= 8;" \
- : "=d" (__v) \
- : "d" (__x)); \
+ ({ register unsigned short int __v; \
+ __asm__ ("%0 = PACK (%1.L, %1.L);" \
+ "%0 >>= 8;" \
+ : "=d" (__v) \
+ : "d" (x)); \
__v; }))
-#else
-static __inline unsigned short int
-__bswap_16 (unsigned short int __bsx)
-{
- return __bswap_constant_16 (__bsx);
-}
-#endif
-/* Swap bytes in 32 bit value. */
-#define __bswap_constant_32(x) \
- ((((x) & 0xff000000u) >> 24) | (((x) & 0x00ff0000u) >> 8) | \
- (((x) & 0x0000ff00u) << 8) | (((x) & 0x000000ffu) << 24))
-
-#ifdef __GNUC__
-# define __bswap_32(x) \
+#define __bswap_non_constant_32(x) \
(__extension__ \
- ({ register unsigned int __v, __x = (x); \
- if (__builtin_constant_p (__x)) \
- __v = __bswap_constant_32 (__x); \
- else \
- __asm__ ("%1 = %0 >> 8 (V);" \
- "%0 = %0 << 8 (V);" \
- "%0 = %0 | %1;" \
- "%1 = PACK(%0.L, %0.H);" \
- : "+d"(__x), "=&d"(__v)); \
+ ({ register unsigned int __v; \
+ __asm__ ("%1 = %0 >> 8 (V);" \
+ "%0 = %0 << 8 (V);" \
+ "%0 = %0 | %1;" \
+ "%1 = PACK(%0.L, %0.H);" \
+ : "+d"(x), "=&d"(__v)); \
__v; }))
-#else
-static __inline unsigned int
-__bswap_32 (unsigned int __bsx)
-{
- return __bswap_constant_32 (__bsx);
-}
-#endif
-#if defined __GNUC__ && __GNUC__ >= 2
-/* Swap bytes in 64 bit value. */
-# define __bswap_constant_64(x) \
- ((((x) & 0xff00000000000000ull) >> 56) \
- | (((x) & 0x00ff000000000000ull) >> 40) \
- | (((x) & 0x0000ff0000000000ull) >> 24) \
- | (((x) & 0x000000ff00000000ull) >> 8) \
- | (((x) & 0x00000000ff000000ull) << 8) \
- | (((x) & 0x0000000000ff0000ull) << 24) \
- | (((x) & 0x000000000000ff00ull) << 40) \
- | (((x) & 0x00000000000000ffull) << 56))
-
-# define __bswap_64(x) \
- (__extension__ \
- ({ union { __extension__ unsigned long long int __ll; \
- unsigned int __l[2]; } __w, __r; \
- if (__builtin_constant_p (x)) \
- __r.__ll = __bswap_constant_64 (x); \
- else \
- { \
- __w.__ll = (x); \
- __r.__l[0] = __bswap_32 (__w.__l[1]); \
- __r.__l[1] = __bswap_32 (__w.__l[0]); \
- } \
- __r.__ll; }))
#endif
-#endif /* _BITS_BYTESWAP_H */
+#include <bits/byteswap-common.h>
diff --git a/libc/sysdeps/linux/bfin/bits/elf-fdpic.h b/libc/sysdeps/linux/bfin/bits/elf-fdpic.h
index 905648054..dddf82ccc 100644
--- a/libc/sysdeps/linux/bfin/bits/elf-fdpic.h
+++ b/libc/sysdeps/linux/bfin/bits/elf-fdpic.h
@@ -22,8 +22,7 @@ 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. */
+not, see <http://www.gnu.org/licenses/>. */
#ifndef _BITS_ELF_FDPIC_H
#define _BITS_ELF_FDPIC_H
@@ -64,7 +63,7 @@ struct elf32_fdpic_loadaddr {
/* Map a pointer's VMA to its corresponding address according to the
load map. */
-inline static void *
+static __always_inline void *
__reloc_pointer (void *p,
const struct elf32_fdpic_loadmap *map)
{
diff --git a/libc/sysdeps/linux/bfin/bits/fcntl.h b/libc/sysdeps/linux/bfin/bits/fcntl.h
index 7e32a04e9..d4412410e 100644
--- a/libc/sysdeps/linux/bfin/bits/fcntl.h
+++ b/libc/sysdeps/linux/bfin/bits/fcntl.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FCNTL_H
# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
@@ -48,7 +47,9 @@
# define O_DIRECTORY 040000 /* Must be a directory. */
# define O_NOFOLLOW 0100000 /* Do not follow links. */
# define O_DIRECT 0200000 /* Direct disk access. */
-# define O_STREAMING 04000000/* streaming access */
+# define O_NOATIME 01000000 /* don't set atime */
+# define O_CLOEXEC 02000000 /* set close_on_exec */
+# define O_PATH 010000000 /* Resolve pathname but do not open file. */
#endif
/* For now Linux has synchronisity options for data and read operations.
@@ -98,6 +99,8 @@
# define F_NOTIFY 1026 /* Request notfications on a directory. */
# define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with
close-on-exit set on new fd. */
+# define F_SETPIPE_SZ 1031 /* Set pipe page size array. */
+# define F_GETPIPE_SZ 1032 /* Get pipe page size array. */
#endif
/* For F_[GET|SET]FL. */
@@ -185,7 +188,7 @@ struct flock64
#endif
-#ifdef __USE_GNU
+#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
@@ -208,7 +211,7 @@ struct flock64
__BEGIN_DECLS
-#ifdef __USE_GNU
+#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)
diff --git a/libc/sysdeps/linux/bfin/bits/huge_val.h b/libc/sysdeps/linux/bfin/bits/huge_val.h
index 9c8b72159..f11facfe6 100644
--- a/libc/sysdeps/linux/bfin/bits/huge_val.h
+++ b/libc/sysdeps/linux/bfin/bits/huge_val.h
@@ -16,9 +16,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _MATH_H
# error "Never use <bits/huge_val.h> directly; include <math.h> instead."
diff --git a/libc/sysdeps/linux/bfin/bits/kernel_stat.h b/libc/sysdeps/linux/bfin/bits/kernel_stat.h
index 8c7ba0533..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... */
@@ -22,12 +18,9 @@ struct kernel_stat {
unsigned long st_size;
unsigned long st_blksize;
unsigned long st_blocks;
- unsigned long st_atime;
- unsigned long __unused1;
- unsigned long st_mtime;
- unsigned long __unused2;
- unsigned long st_ctime;
- unsigned long __unused3;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
unsigned long __unused4;
unsigned long __unused5;
};
@@ -47,12 +40,9 @@ struct kernel_stat64 {
unsigned long st_blksize;
unsigned long st_blocks; /* Number 512-byte blocks allocated. */
unsigned long __pad4; /* future possible st_blocks high bits */
- unsigned long st_atime;
- unsigned long __pad5;
- unsigned long st_mtime;
- unsigned long __pad6;
- unsigned long st_ctime;
- unsigned long __pad7; /* will be high 32 bits of ctime someday */
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
unsigned long long st_ino;
};
diff --git a/libc/sysdeps/linux/bfin/bits/kernel_types.h b/libc/sysdeps/linux/bfin/bits/kernel_types.h
index d69a875d4..9fec5952a 100644
--- a/libc/sysdeps/linux/bfin/bits/kernel_types.h
+++ b/libc/sysdeps/linux/bfin/bits/kernel_types.h
@@ -32,6 +32,8 @@ typedef unsigned short __kernel_old_uid_t;
typedef unsigned short __kernel_old_gid_t;
typedef long long __kernel_loff_t;
typedef __kernel_dev_t __kernel_old_dev_t;
+typedef long __kernel_long_t;
+typedef unsigned long __kernel_ulong_t;
typedef struct {
#ifdef __USE_ALL
diff --git a/libc/sysdeps/linux/bfin/bits/mman.h b/libc/sysdeps/linux/bfin/bits/mman.h
deleted file mode 100644
index c57238726..000000000
--- a/libc/sysdeps/linux/bfin/bits/mman.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/* Definitions for POSIX memory map interface. Linux/m68k version.
- Copyright (C) 1997 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_MMAN_H
-# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
-#endif
-
-/* The following definitions basically come from the kernel headers.
- But the kernel header is not namespace clean. */
-
-
-/* Protections are chosen from these bits, OR'd together. The
- implementation does not necessarily support PROT_EXEC or PROT_WRITE
- without PROT_READ. The only guarantees are that no writing will be
- allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
-
-#define PROT_READ 0x1 /* Page can be read. */
-#define PROT_WRITE 0x2 /* Page can be written. */
-#define PROT_EXEC 0x4 /* Page can be executed. */
-#define PROT_NONE 0x0 /* Page can not be accessed. */
-
-/* Sharing types (must choose one and only one of these). */
-#define MAP_SHARED 0x01 /* Share changes. */
-#define MAP_PRIVATE 0x02 /* Changes are private. */
-#ifdef __USE_MISC
-# define MAP_TYPE 0x0f /* Mask for type of mapping. */
-#endif
-
-/* Other flags. */
-#define MAP_FIXED 0x10 /* Interpret addr exactly. */
-#ifdef __USE_MISC
-# define MAP_FILE 0
-# define MAP_ANONYMOUS 0x20 /* Don't use a file. */
-# define MAP_ANON MAP_ANONYMOUS
-#endif
-
-/* These are Linux-specific. */
-#ifdef __USE_MISC
-# define MAP_GROWSDOWN 0x0100 /* Stack-like segment. */
-# define MAP_DENYWRITE 0x0800 /* ETXTBSY */
-# define MAP_EXECUTABLE 0x1000 /* Mark it as an executable. */
-# define MAP_LOCKED 0x2000 /* Lock the mapping. */
-# define MAP_NORESERVE 0x4000 /* Don't check for reservations. */
-# define MAP_UNINITIALIZE 0x4000000 /* For anonymous mmap, memory could
- be uninitialized. */
-#endif
-
-/* Flags to `msync'. */
-#define MS_ASYNC 1 /* Sync memory asynchronously. */
-#define MS_SYNC 4 /* Synchronous memory sync. */
-#define MS_INVALIDATE 2 /* Invalidate the caches. */
-
-/* Flags for `mlockall'. */
-#define MCL_CURRENT 1 /* Lock all currently mapped pages. */
-#define MCL_FUTURE 2 /* Lock all additions to address
- space. */
-
-/* Flags for `mremap'. */
-#ifdef __USE_GNU
-# define MREMAP_MAYMOVE 1
-# define MREMAP_FIXED 2
-#endif
-
-/* Advice to `madvise'. */
-#ifdef __USE_BSD
-# define MADV_NORMAL 0x0 /* No further special treatment. */
-# define MADV_RANDOM 0x1 /* Expect random page references. */
-# define MADV_SEQUENTIAL 0x2 /* Expect sequential page references. */
-# define MADV_WILLNEED 0x3 /* Will need these pages. */
-# define MADV_DONTNEED 0x4 /* Don't need these pages. */
-#endif
-
-/* The POSIX people had to invent similar names for the same things. */
-#ifdef __USE_XOPEN2K
-# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
-# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
-# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
-# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
-# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
-#endif
diff --git a/libc/sysdeps/linux/bfin/bits/setjmp.h b/libc/sysdeps/linux/bfin/bits/setjmp.h
index ee3f5e787..f9eea395c 100644
--- a/libc/sysdeps/linux/bfin/bits/setjmp.h
+++ b/libc/sysdeps/linux/bfin/bits/setjmp.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* Define the machine-dependent type `jmp_buf'. bfin version. Lineo, Inc. 2001*/
#ifndef _BITS_SETJMP_H
@@ -24,7 +23,6 @@
# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
#endif
-#ifndef _ASM
/* Jump buffer contains r7-r4, p5-p3, fp, sp and pc. Other registers are not saved. */
typedef struct
{
@@ -45,13 +43,4 @@ typedef struct
unsigned long pc;
}__jmp_buf[1];
-#endif
-
-#define __JMP_BUF_SP 8
-
-/* 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])
-
#endif /* bits/setjmp.h */
diff --git a/libc/sysdeps/linux/bfin/bits/sigcontextinfo.h b/libc/sysdeps/linux/bfin/bits/sigcontextinfo.h
index b7e08cfc9..851c21d04 100644
--- a/libc/sysdeps/linux/bfin/bits/sigcontextinfo.h
+++ b/libc/sysdeps/linux/bfin/bits/sigcontextinfo.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#define SIGCONTEXT int _code, struct sigcontext *
#define SIGCONTEXT_EXTRA_ARGS _code,
diff --git a/libc/sysdeps/linux/bfin/bits/stackinfo.h b/libc/sysdeps/linux/bfin/bits/stackinfo.h
index 9e26de13f..d0ee507ab 100644
--- a/libc/sysdeps/linux/bfin/bits/stackinfo.h
+++ b/libc/sysdeps/linux/bfin/bits/stackinfo.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* This file contains a bit of information about the stack allocation
of the processor. */
diff --git a/libc/sysdeps/linux/bfin/bits/syscalls.h b/libc/sysdeps/linux/bfin/bits/syscalls.h
index 0833a1fc1..da549ff58 100644
--- a/libc/sysdeps/linux/bfin/bits/syscalls.h
+++ b/libc/sysdeps/linux/bfin/bits/syscalls.h
@@ -6,133 +6,42 @@
#ifndef __ASSEMBLER__
-#include <errno.h>
-
-#define SYS_ify(syscall_name) (__NR_##syscall_name)
-
-/* user-visible error numbers are in the range -1 - -4095: see <asm-frv/errno.h> */
-#if defined _LIBC && !defined __set_errno
-# define __syscall_return(type, res) \
-do { \
- unsigned long __sr2 = (res); \
- if (__builtin_expect ((unsigned long)(__sr2) \
- >= (unsigned long)(-4095), 0)) { \
- extern int __syscall_error (int); \
- return (type) __syscall_error (__sr2); \
- } \
- return (type) (__sr2); \
-} while (0)
-#else
-# define __syscall_return(type, res) \
-do { \
- unsigned long __sr2 = (res); \
- if (__builtin_expect ((unsigned long)(__sr2) \
- >= (unsigned long)(-4095), 0)) { \
- __set_errno (-__sr2); \
- __sr2 = -1; \
- } \
- return (type) (__sr2); \
-} while (0)
-#endif
-
-#define _syscall0(type,name) \
-type name(void) { \
- long __res; \
- __asm__ __volatile__ ( \
- "excpt 0;\n\t" \
- : "=q0" (__res) \
- : "qA" (__NR_##name) \
- : "memory","CC"); \
- __syscall_return(type,__res); \
-}
-
-#define _syscall1(type,name,type1,arg1) \
-type name(type1 arg1) { \
- long __res; \
- __asm__ __volatile__ ( \
- "excpt 0;\n\t" \
- : "=q0" (__res) \
- : "qA" (__NR_##name), \
- "q0" ((long)(arg1)) \
- : "memory","CC"); \
- __syscall_return(type,__res); \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name(type1 arg1,type2 arg2) { \
- long __res; \
- __asm__ __volatile__ ( \
- "excpt 0;\n\t" \
- "%0=r0;\n\t" \
- : "=q0" (__res) \
- : "qA" (__NR_##name), \
- "q0" ((long)(arg1)), \
- "q1" ((long)(arg2)) \
- : "memory","CC"); \
- __syscall_return(type,__res); \
-}
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name(type1 arg1,type2 arg2,type3 arg3) { \
- long __res; \
- __asm__ __volatile__ ( \
- "excpt 0;\n\t" \
- : "=q0" (__res) \
- : "qA" (__NR_##name), \
- "q0" ((long)(arg1)), \
- "q1" ((long)(arg2)), \
- "q2" ((long)(arg3)) \
- : "memory","CC"); \
- __syscall_return(type,__res); \
-}
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4)\
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \
- long __res; \
- __asm__ __volatile__ ( \
- "excpt 0;\n\t" \
- : "=q0" (__res) \
- : "qA" (__NR_##name), \
- "q0" ((long)(arg1)), \
- "q1" ((long)(arg2)), \
- "q2" ((long)(arg3)), \
- "q3" ((long)(arg4)) \
- : "memory","CC"); \
- __syscall_return(type,__res); \
-}
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) { \
- long __res; \
- __asm__ __volatile__ ( \
- "excpt 0;\n\t" \
- : "=q0" (__res) \
- : "qA" (__NR_##name), \
- "q0" ((long)(arg1)), \
- "q1" ((long)(arg2)), \
- "q2" ((long)(arg3)), \
- "q3" ((long)(arg4)), \
- "q4" ((long)(arg5)) \
- : "memory","CC"); \
- __syscall_return(type,__res); \
-}
-
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) { \
- long __res; \
- __asm__ __volatile__ ( \
- "excpt 0;\n\t" \
- : "=q0" (__res) \
- : "qA" (__NR_##name), \
- "q0" ((long)(arg1)), \
- "q1" ((long)(arg2)), \
- "q2" ((long)(arg3)), \
- "q3" ((long)(arg4)), \
- "q4" ((long)(arg5)), \
- "q5" ((long)(arg6)) \
- : "memory","CC"); \
- __syscall_return(type,__res); \
-}
+#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+(__extension__ \
+ ({ \
+ long __res; \
+ __asm__ __volatile__ ( \
+ "excpt 0;\n\t" \
+ : "=q0" (__res) \
+ : "qA" (name) ASMFMT_##nr(args) \
+ : "memory","CC"); \
+ __res; \
+ }) \
+)
+#define ASMFMT_0()
+
+#define ASMFMT_1(arg1) \
+ , "q0" ((long)(arg1))
+
+#define ASMFMT_2(arg1, arg2) \
+ ASMFMT_1(arg1) \
+ , "q1" ((long)(arg2))
+
+#define ASMFMT_3(arg1, arg2, arg3) \
+ ASMFMT_2(arg1, arg2) \
+ , "q2" ((long)(arg3))
+
+#define ASMFMT_4(arg1, arg2, arg3, arg4) \
+ ASMFMT_3(arg1, arg2, arg3) \
+ , "q3" ((long)(arg4))
+
+#define ASMFMT_5(arg1, arg2, arg3, arg4, arg5) \
+ ASMFMT_4(arg1, arg2, arg3, arg4) \
+ , "q4" ((long)(arg5))
+
+#define ASMFMT_6(arg1, arg2, arg3, arg4, arg5, arg6) \
+ ASMFMT_5(arg1, arg2, arg3, arg4, arg5) \
+ , "q5" ((long)(arg6))
#endif /* __ASSEMBLER__ */
#endif /* _BITS_SYSCALLS_H */
diff --git a/libc/sysdeps/linux/bfin/bits/typesizes.h b/libc/sysdeps/linux/bfin/bits/typesizes.h
index eb61fc99d..829cf44e4 100644
--- a/libc/sysdeps/linux/bfin/bits/typesizes.h
+++ b/libc/sysdeps/linux/bfin/bits/typesizes.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _BITS_TYPES_H
# error "Never include <bits/typesizes.h> directly; use <sys/types.h> instead."
diff --git a/libc/sysdeps/linux/bfin/bits/uClibc_arch_features.h b/libc/sysdeps/linux/bfin/bits/uClibc_arch_features.h
index 39e71c918..9646aac45 100644
--- a/libc/sysdeps/linux/bfin/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/bfin/bits/uClibc_arch_features.h
@@ -6,34 +6,36 @@
#define _BITS_UCLIBC_ARCH_FEATURES_H
/* instruction used when calling abort() to kill yourself */
-/*#define __UCLIBC_ABORT_INSTRUCTION__ "asm instruction"*/
-#undef __UCLIBC_ABORT_INSTRUCTION__
+#define __UCLIBC_ABORT_INSTRUCTION__ ".short 2" /* invalid 116bit insn */
/* 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 align 64bit values in register pairs ? (32bit arches only) */
+#undef __UCLIBC_SYSCALL_ALIGN_64BIT__
/* 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 */
+#undef __UCLIBC_ASM_LINE_SEP__
+
#endif /* _BITS_UCLIBC_ARCH_FEATURES_H */
diff --git a/libc/sysdeps/linux/bfin/bits/wordsize.h b/libc/sysdeps/linux/bfin/bits/wordsize.h
index ba643b60a..ca82fd7d4 100644
--- a/libc/sysdeps/linux/bfin/bits/wordsize.h
+++ b/libc/sysdeps/linux/bfin/bits/wordsize.h
@@ -12,8 +12,7 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#define __WORDSIZE 32
diff --git a/libc/sysdeps/linux/bfin/bsd-_setjmp.S b/libc/sysdeps/linux/bfin/bsd-_setjmp.S
index 8ca2bbec9..c365b4ef6 100644
--- a/libc/sysdeps/linux/bfin/bsd-_setjmp.S
+++ b/libc/sysdeps/linux/bfin/bsd-_setjmp.S
@@ -12,20 +12,20 @@
.align 4;
__setjmp:
- [--SP] = P0; // Save P0
+ [--SP] = P0; /* Save P0 */
P0 = R0;
R0 = [SP++];
- [P0 + 0x00] = R0; // Save saved P0
+ [P0 + 0x00] = R0; /* Save saved P0 */
[P0 + 0x04] = P1;
[P0 + 0x08] = P2;
[P0 + 0x0C] = P3;
[P0 + 0x10] = P4;
[P0 + 0x14] = P5;
- [P0 + 0x18] = FP; // Frame Pointer
- [P0 + 0x1C] = SP; // Stack Pointer
+ [P0 + 0x18] = FP; /* Frame Pointer */
+ [P0 + 0x1C] = SP; /* Stack Pointer */
- [P0 + 0x20] = P0; // Data Registers
+ [P0 + 0x20] = P0; /* Data Registers */
[P0 + 0x24] = R1;
[P0 + 0x28] = R2;
[P0 + 0x2C] = R3;
@@ -37,12 +37,12 @@ __setjmp:
R0 = ASTAT;
[P0 + 0x40] = R0;
- R0 = LC0; // Loop Counters
+ R0 = LC0; /* Loop Counters */
[P0 + 0x44] = R0;
R0 = LC1;
[P0 + 0x48] = R0;
- R0 = A0.W; // Accumulators
+ R0 = A0.W; /* Accumulators */
[P0 + 0x4C] = R0;
R0 = A0.X;
[P0 + 0x50] = R0;
@@ -51,7 +51,7 @@ __setjmp:
R0 = A1.X;
[P0 + 0x58] = R0;
- R0 = I0; // Index Registers
+ R0 = I0; /* Index Registers */
[P0 + 0x5C] = R0;
R0 = I1;
[P0 + 0x60] = R0;
@@ -60,7 +60,7 @@ __setjmp:
R0 = I3;
[P0 + 0x68] = R0;
- R0 = M0; // Modifier Registers
+ R0 = M0; /* Modifier Registers */
[P0 + 0x6C] = R0;
R0 = M1;
[P0 + 0x70] = R0;
@@ -69,7 +69,7 @@ __setjmp:
R0 = M3;
[P0 + 0x78] = R0;
- R0 = L0; // Length Registers
+ R0 = L0; /* Length Registers */
[P0 + 0x7c] = R0;
R0 = L1;
[P0 + 0x80] = R0;
@@ -78,7 +78,7 @@ __setjmp:
R0 = L3;
[P0 + 0x88] = R0;
- R0 = B0; // Base Registers
+ R0 = B0; /* Base Registers */
[P0 + 0x8C] = R0;
R0 = B1;
[P0 + 0x90] = R0;
@@ -95,3 +95,5 @@ __setjmp:
JUMP.L ___sigjmp_save;
.size __setjmp,.-__setjmp
+
+.section .note.GNU-stack,"",%progbits
diff --git a/libc/sysdeps/linux/bfin/cacheflush.c b/libc/sysdeps/linux/bfin/cacheflush.c
new file mode 100644
index 000000000..a4b9f4ae9
--- /dev/null
+++ b/libc/sysdeps/linux/bfin/cacheflush.c
@@ -0,0 +1,15 @@
+/*
+ * 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 <sys/syscall.h>
+
+#ifdef __NR_cacheflush
+# include <sys/cachectl.h>
+
+_syscall3 (int, cacheflush, void *, addr, const int, nbytes, const int, flags)
+#endif
diff --git a/libc/sysdeps/linux/bfin/clone.c b/libc/sysdeps/linux/bfin/clone.c
index 899738e2d..067fdc767 100644
--- a/libc/sysdeps/linux/bfin/clone.c
+++ b/libc/sysdeps/linux/bfin/clone.c
@@ -13,47 +13,33 @@
int
clone (int (*fn)(void *arg), void *child_stack, int flags, void *arg, ...)
{
- register long rval = -1;
+ long rval = -1;
if (fn && child_stack) {
-#ifdef __BFIN_FDPIC__
- __asm__ __volatile__ (
- "excpt 0;" /*Call sys_clone*/
+ __asm__ __volatile__ (
+ "excpt 0;" /* Call sys_clone */
"cc = r0 == 0;"
- "if !cc jump .Lxxx;" /* if (rval != 0) skip to parent */
+ "if !cc jump 1f;" /* if (rval != 0) skip to parent */
"r0 = %4;"
"p0 = %5;"
"fp = 0;"
+#ifdef __BFIN_FDPIC__
"p1 = [p0];"
"p3 = [p0 + 4];"
"call (p1);" /* Call cloned function */
- "p0 = %6;"
- "excpt 0;" /* Call sys_exit */
- ".Lxxx: nop;"
- : "=q0" (rval)
- : "qA" (__NR_clone), "q1" (child_stack), "q0" (flags), "a" (arg), "a" (fn), "i" (__NR_exit)
- : "CC");
#else
- __asm__ __volatile__ (
- "excpt 0;" /*Call sys_clone*/
- "cc = r0 == 0;"
- "if !cc jump .Lxxx;" /* if (rval != 0) skip to parent */
- "r0 = %4;"
- "p0 = %5;"
- "fp = 0;"
"call (p0);" /* Call cloned function */
+#endif
"p0 = %6;"
"excpt 0;" /* Call sys_exit */
- ".Lxxx: nop;"
+ "1: nop;"
: "=q0" (rval)
: "qA" (__NR_clone), "q1" (child_stack), "q0" (flags), "a" (arg), "a" (fn), "i" (__NR_exit)
: "CC");
-#endif
- } else {
+ } else
__set_errno(EINVAL);
- }
return rval;
}
diff --git a/libc/sysdeps/linux/bfin/crt1.S b/libc/sysdeps/linux/bfin/crt1.S
index 38e68c9ac..f091a733d 100644
--- a/libc/sysdeps/linux/bfin/crt1.S
+++ b/libc/sysdeps/linux/bfin/crt1.S
@@ -14,8 +14,7 @@ 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., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
+not, see <http://www.gnu.org/licenses/>. */
/* When we enter this piece of code, the user stack looks like this:
@@ -109,12 +108,11 @@ __start:
[SP + 20] = R7;
/* Ok, now run uClibc's main() -- shouldn't return */
-#if defined L_crt1 && defined __UCLIBC_CTOR_DTOR__
+#if (defined L_crt1 || defined L_Scrt1) && defined __UCLIBC_CTOR_DTOR__
#ifdef __BFIN_FDPIC__
R3 = [P3 + __init@FUNCDESC_GOT17M4];
#elif defined USE_GOT
- P5 = [P5 + _current_shared_library_p5_offset_];
R3 = [P5 + ___shared_flat_init@GOT];
#else
R3.H = __init;
@@ -165,3 +163,5 @@ lib_main:
.hidden _current_shared_library_p5_offset_
#endif
+
+.section .note.GNU-stack,"",%progbits
diff --git a/libc/sysdeps/linux/bfin/crti.S b/libc/sysdeps/linux/bfin/crti.S
index 7c10392d8..f37511ac7 100644
--- a/libc/sysdeps/linux/bfin/crti.S
+++ b/libc/sysdeps/linux/bfin/crti.S
@@ -16,9 +16,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
+along with GCC; see the file COPYING. If not, see
+<http://www.gnu.org/licenses/>. */
/* As a special exception, if you link this library with files
compiled with GCC to produce an executable, this does not cause
@@ -60,3 +59,5 @@ __fini:
#if defined __ID_SHARED_LIB__
P5 = [P5 + _current_shared_library_p5_offset_]
#endif
+
+.section .note.GNU-stack,"",%progbits
diff --git a/libc/sysdeps/linux/bfin/crtn.S b/libc/sysdeps/linux/bfin/crtn.S
index add0b7162..5c8739249 100644
--- a/libc/sysdeps/linux/bfin/crtn.S
+++ b/libc/sysdeps/linux/bfin/crtn.S
@@ -16,9 +16,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
+along with GCC; see the file COPYING. If not, see
+<http://www.gnu.org/licenses/>. */
/* As a special exception, if you link this library with files
compiled with GCC to produce an executable, this does not cause
@@ -51,3 +50,5 @@ Boston, MA 02111-1307, USA. */
P3 = [SP++];
#endif
rts;
+
+.section .note.GNU-stack,"",%progbits
diff --git a/libc/sysdeps/linux/bfin/crtreloc.c b/libc/sysdeps/linux/bfin/crtreloc.c
index 5e038256a..4128abf3a 100644
--- a/libc/sysdeps/linux/bfin/crtreloc.c
+++ b/libc/sysdeps/linux/bfin/crtreloc.c
@@ -23,8 +23,7 @@ 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. */
+not, see <http://www.gnu.org/licenses/>. */
#ifdef __BFIN_FDPIC__
@@ -41,7 +40,7 @@ union word {
/* Compute the runtime address of pointer in the range [p,e), and then
map the pointer pointed by it. */
-inline static void ***
+static __always_inline void ***
reloc_range_indirect (void ***p, void ***e,
const struct elf32_fdpic_loadmap *map)
{
@@ -85,7 +84,7 @@ reloc_range_indirect (void ***p, void ***e,
/* Call __reloc_range_indirect for the given range except for the last
entry, whose contents are only relocated. It's expected to hold
the GOT value. */
-void* attribute_hidden
+attribute_hidden void*
__self_reloc (const struct elf32_fdpic_loadmap *map,
void ***p, void ***e)
{
@@ -102,7 +101,7 @@ __self_reloc (const struct elf32_fdpic_loadmap *map,
need. */
/* Remap pointers in [p,e). */
-inline static void**
+static __always_inline void**
reloc_range (void **p, void **e,
const struct elf32_fdpic_loadmap *map)
{
diff --git a/libc/sysdeps/linux/bfin/dma-memcpy.c b/libc/sysdeps/linux/bfin/dma-memcpy.c
index 6d7a5b855..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/jmpbuf-offsets.h b/libc/sysdeps/linux/bfin/jmpbuf-offsets.h
new file mode 100644
index 000000000..7a91f1887
--- /dev/null
+++ b/libc/sysdeps/linux/bfin/jmpbuf-offsets.h
@@ -0,0 +1,8 @@
+/* Private macros for accessing __jmp_buf contents. BFIN version. */
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define __JMP_BUF_SP 8
diff --git a/libc/sysdeps/linux/bfin/jmpbuf-unwind.h b/libc/sysdeps/linux/bfin/jmpbuf-unwind.h
new file mode 100644
index 000000000..bb7a374fd
--- /dev/null
+++ b/libc/sysdeps/linux/bfin/jmpbuf-unwind.h
@@ -0,0 +1,11 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+#include <setjmp.h>
+
+/* Test if longjmp to JMPBUF would unwind the frame
+ containing a local variable at ADDRESS. */
+#define _JMPBUF_UNWINDS(jmpbuf, address) \
+ ((void *) (address) < (void *) (jmpbuf)->fp)
diff --git a/libc/sysdeps/linux/bfin/setjmp.S b/libc/sysdeps/linux/bfin/setjmp.S
index 1b304f84d..a2b6176d7 100644
--- a/libc/sysdeps/linux/bfin/setjmp.S
+++ b/libc/sysdeps/linux/bfin/setjmp.S
@@ -94,3 +94,5 @@ ___sigsetjmp:
R0 = [P0 + 0x20];
JUMP.L ___sigjmp_save;
.size ___sigsetjmp, .-___sigsetjmp
+
+.section .note.GNU-stack,"",%progbits
diff --git a/libc/sysdeps/linux/bfin/sram-alloc.c b/libc/sysdeps/linux/bfin/sram-alloc.c
index f0e8bce65..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);
-
+_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 02bf5d52e..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..f241e657d
--- /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/bfin/sys/elf.h b/libc/sysdeps/linux/bfin/sys/elf.h
index d959cdca1..9d64e9768 100644
--- a/libc/sysdeps/linux/bfin/sys/elf.h
+++ b/libc/sysdeps/linux/bfin/sys/elf.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_ELF_H
#define _SYS_ELF_H 1
diff --git a/libc/sysdeps/linux/bfin/sys/io.h b/libc/sysdeps/linux/bfin/sys/io.h
index 68639902c..f77177a25 100644
--- a/libc/sysdeps/linux/bfin/sys/io.h
+++ b/libc/sysdeps/linux/bfin/sys/io.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_IO_H
@@ -23,6 +22,7 @@
__BEGIN_DECLS
+#if defined __UCLIBC_LINUX_SPECIFIC__
/* If TURN_ON is TRUE, request for permission to do direct i/o on the
port numbers in the range [FROM,FROM+NUM-1]. Otherwise, turn I/O
permission off for that range. This call requires root privileges. */
@@ -33,6 +33,7 @@ extern int ioperm (unsigned long int __from, unsigned long int __num,
permission to access any I/O port is granted. This call requires
root privileges. */
extern int iopl (int __level) __THROW;
+#endif /* __UCLIBC_LINUX_SPECIFIC__ */
/* The functions that actually perform reads and writes. */
extern unsigned char inb (unsigned long int port) __THROW;
diff --git a/libc/sysdeps/linux/bfin/sys/procfs.h b/libc/sysdeps/linux/bfin/sys/procfs.h
index 45a65f391..81671760d 100644
--- a/libc/sysdeps/linux/bfin/sys/procfs.h
+++ b/libc/sysdeps/linux/bfin/sys/procfs.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_PROCFS_H
#define _SYS_PROCFS_H 1
diff --git a/libc/sysdeps/linux/bfin/sys/reg.h b/libc/sysdeps/linux/bfin/sys/reg.h
deleted file mode 100644
index 4ce6e15aa..000000000
--- a/libc/sysdeps/linux/bfin/sys/reg.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/* Copyright (C) 1998 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_REG_H
-#define _SYS_REG_H 1
-
-/* Index into an array of 4 byte integers returned from ptrace for
- location of the users' stored general purpose registers. */
-
-enum
-{
- PT_IPEND = 0,
-#define PT_IPEND PT_IPEND
- PT_SYSCFG = 4,
-#define PT_SYSCFG PT_SYSCFG
- PT_SR = 8,
-#define PT_SR PT_SR
- PT_RETE = 12,
-#define PT_RETE PT_RETE
- PT_RETN = 16,
-#define PT_RETN PT_RETN
- PT_RETX = 20,
-#define PT_RETX PT_RETX
- PT_PC = 24,
-#define PT_PC PT_PC
- PT_RETS = 28,
-#define PT_RETS PT_RETS
- PT_ASTAT = 32,
-#define PT_ASTAT PT_ASTAT
- PT_LB1 = 40,
-#define PT_LB1 PT_LB1
- PT_LB0 = 44,
-#define PT_LB0 PT_LB0
- PT_LT1 = 48,
-#define PT_LT1 PT_LT1
- PT_LT0 = 52,
-#define PT_LT0 PT_LT0
- PT_LC1 = 56,
-#define PT_LC1 PT_LC1
- PT_LC0 = 60,
-#define PT_LC0 PT_LC0
- PT_A1W = 64,
-#define PT_A1W PT_A1W
- PT_A1X = 68,
-#define PT_A1X PT_A1X
- PT_A0W = 72,
-#define PT_A0W PT_A0W
- PT_A0X = 76,
-#define PT_A0X PT_A0X
- PT_B3 = 80,
-#define PT_B# PT_B3
- PT_B2 = 84,
-#define PT_B2 PT_B2
- PT_B1 = 88,
-#define PT_B1 PT_B1
- PT_B0 = 92,
-#define PT_B0 PT_B0
- PT_L3 = 96,
-#define PT_L3 PT_L3
- PT_L2 = 100,
-#define PT_L2 PT_L2
- PT_L1 = 104,
-#define PT_L1 PT_L1
- PT_L0 = 108,
-#define PT_L0 PT_L0
- PT_M3 = 112,
-#define PT_M3 PT_M3
- PT_M2 = 116,
-#define PT_M2 PT_M2
- PT_M1 = 120,
-#define PT_M1 PT_M1
- PT_M0 = 124,
-#define PT_M0 PT_M0
- PT_I3 = 128,
-#define PT_I3 PT_I3
- PT_I2 = 132,
-#define PT_I2 PT_I2
- PT_I1 = 136,
-#define PT_I1 PT_I1
- PT_I0 = 140,
-#define PT_I0 PT_I0
- PT_USP = 144,
-#define PT_USP PT_USP
- PT_FP = 148,
-#define PT_FP PT_FP
- PT_P5 = 152,
-#define PT_P5 PT_P5
- PT_P4 = 156,
-#define PT_P4 PT_P4
- PT_P3 = 160,
-#define PT_P3 PT_P3
- PT_P2 = 164,
-#define PT_P2 PT_P2
- PT_P1 = 168,
-#define PT_P1 PT_P1
- PT_P0 = 172,
-#define PT_P0 PT_P0
- PT_R7 = 176,
-#define PT_R7 PT_R7
- PT_R6 = 180,
-#define PT_R6 PT_R6
- PT_R5 = 184,
-#define PT_R5 PT_R5
- PT_R4 = 188,
-#define PT_R4 PT_R4
- PT_R3 = 192,
-#define PT_R3 PT_R3
- PT_R2 = 196,
-#define PT_R2 PT_R2
- PT_R1 = 200,
-#define PT_R1 PT_R1
- PT_R0 = 204,
-#define PT_R0 PT_R0
- PT_ORIG_R0 = 208,
-#define PT_ORIG_R0 PT_ORIG_R0
-};
-
-#endif /* _SYS_REG_H */
diff --git a/libc/sysdeps/linux/bfin/sys/ucontext.h b/libc/sysdeps/linux/bfin/sys/ucontext.h
index ac2ef94e2..b6e3a404a 100644
--- a/libc/sysdeps/linux/bfin/sys/ucontext.h
+++ b/libc/sysdeps/linux/bfin/sys/ucontext.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* System V/blackfin ABI compliant context switching support. */
@@ -33,6 +32,11 @@ typedef int greg_t;
/* Container for all general registers. */
typedef greg_t gregset_t[NGREG];
+/* There is no user thread context implementation for bfin, avoid
+ clashing with gcc symbols, see:
+ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47779
+*/
+#if 0
/* Number of each register is the `gregset_t' array. */
enum
{
@@ -131,6 +135,7 @@ enum
REG_SEQSTAT = 46
#define REG_SEQSTAT REG_SEQSTAT
};
+#endif
/* Context to describe whole processor state. */
typedef struct
diff --git a/libc/sysdeps/linux/bfin/sys/user.h b/libc/sysdeps/linux/bfin/sys/user.h
new file mode 100644
index 000000000..558abd6ad
--- /dev/null
+++ b/libc/sysdeps/linux/bfin/sys/user.h
@@ -0,0 +1,57 @@
+#ifndef _SYS_USER_H
+#define _SYS_USER_H
+
+struct user_bfinfp_struct {
+};
+
+/* This is the old layout of "struct pt_regs" as of Linux 1.x, and
+ is still the layout used by user (the new pt_regs doesn't have
+ all registers). */
+struct user_regs_struct {
+ long r0, r1, r2, r3, r4, r5, r6, r7;
+ long p0, p1, p2, p3, p4, p5, usp, fp;
+ long i0, i1, i2, i3;
+ long l0, l1, l2, l3;
+ long b0, b1, b2, b3;
+ long m0, m1, m2, m3;
+ long a0w, a1w;
+ long a0x, a1x;
+ unsigned long rets;
+ unsigned long astat;
+ unsigned long pc;
+ unsigned long orig_p0;
+};
+
+/* When the kernel dumps core, it starts by dumping the user struct -
+ this will be used by gdb to figure out where the data and stack segments
+ are within the file, and what virtual addresses to use. */
+
+struct user {
+/* We start with the registers, to mimic the way that "memory" is returned
+ from the ptrace(3,...) function. */
+
+ struct user_regs_struct regs; /* Where the registers are actually stored */
+
+/* The rest of this junk is to help gdb figure out what goes where */
+ unsigned long int u_tsize; /* Text segment size (pages). */
+ unsigned long int u_dsize; /* Data segment size (pages). */
+ unsigned long int u_ssize; /* Stack segment size (pages). */
+ unsigned long start_code; /* Starting virtual address of text. */
+ unsigned long start_stack; /* Starting virtual address of stack area.
+ This is actually the bottom of the stack,
+ the top of the stack is always found in the
+ esp register. */
+ long int signal; /* Signal that caused the core dump. */
+ int reserved; /* No longer used */
+ unsigned long u_ar0;
+ /* Used by gdb to help find the values for */
+ /* the registers. */
+ unsigned long magic; /* To uniquely identify a core file */
+ char u_comm[32]; /* User command that was responsible */
+};
+#define NBPG PAGE_SIZE
+#define UPAGES 1
+#define HOST_TEXT_START_ADDR (u.start_code)
+#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
+
+#endif
diff --git a/libc/sysdeps/linux/bfin/syscall.c b/libc/sysdeps/linux/bfin/syscall.c
deleted file mode 100644
index 1db873874..000000000
--- a/libc/sysdeps/linux/bfin/syscall.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/* syscall for blackfin/uClibc
- *
- * Copyright (C) 2004-2006 by Analog Devices Inc.
- * Copyright (C) 2002 by Erik Andersen <andersen@uclibc.org>
- *
- * 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 <features.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/syscall.h>
-
-long syscall(long sysnum, long a, long b, long c, long d, long e, long f)
-{
- int _r0 = 0;
-
- __asm__ __volatile__ (
- "R5 = %7;"
- "R4 = %6;"
- "R3 = %5;"
- "R2 = %4;"
- "R1 = %3;"
- "R0 = %2;"
- "P0 = %1;"
- "excpt 0;"
- "%0 = R0;"
- : "=r" (_r0)
- : "rm" (sysnum),
- "rm" (a),
- "rm" (b),
- "rm" (c),
- "rm" (d),
- "rm" (e),
- "rm" (f)
- : "memory","CC","R0","R1","R2","R3","R4","R5","P0");
-
- if (_r0 >= (unsigned long) -4095) {
- (*__errno_location()) = (-_r0);
- _r0 = (unsigned long) -1;
- }
-
- return (long)_r0;
-}
diff --git a/libc/sysdeps/linux/bfin/sysdep.h b/libc/sysdeps/linux/bfin/sysdep.h
index 4080c22a4..352fbf426 100644
--- a/libc/sysdeps/linux/bfin/sysdep.h
+++ b/libc/sysdeps/linux/bfin/sysdep.h
@@ -9,11 +9,12 @@
#ifndef __BFIN_SYSDEP_H__
#define __BFIN_SYSDEP_H__
-#include <features.h>
+#include <common/sysdep.h>
#ifdef __ASSEMBLER__
#define ENTRY(sym) .global sym; .type sym, STT_FUNC; sym:
+#define ENDPROC(sym) .size sym, . - sym
#endif
diff --git a/libc/sysdeps/linux/bfin/vfork.S b/libc/sysdeps/linux/bfin/vfork.S
index 4e9aa844e..d8e65574b 100644
--- a/libc/sysdeps/linux/bfin/vfork.S
+++ b/libc/sysdeps/linux/bfin/vfork.S
@@ -1,6 +1,4 @@
/*
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- *
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
@@ -9,12 +7,12 @@
.text
.global ___vfork
.hidden ___vfork
-.type ___vfork,STT_FUNC;
+.type ___vfork,STT_FUNC;
.align 4
___vfork:
- p0 = __NR_vfork;
- excpt 0;
- rts;
+ p0 = __NR_vfork;
+ excpt 0;
+ rts;
.size ___vfork,.-___vfork
weak_alias(__vfork,vfork)
libc_hidden_weak(vfork)
diff --git a/libc/sysdeps/linux/vax/Makefile b/libc/sysdeps/linux/c6x/Makefile
index b1bf1ef10..633c91f3e 100644
--- a/libc/sysdeps/linux/vax/Makefile
+++ b/libc/sysdeps/linux/c6x/Makefile
@@ -5,9 +5,7 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-TOPDIR=../../../../
-
-top_srcdir=$(TOPDIR)
+top_srcdir=../../../../
top_builddir=../../../../
all: objs
include $(top_builddir)Rules.mak
diff --git a/libc/sysdeps/linux/c6x/Makefile.arch b/libc/sysdeps/linux/c6x/Makefile.arch
new file mode 100644
index 000000000..29c3b5ddf
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/Makefile.arch
@@ -0,0 +1,10 @@
+# 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-y := brk.c syscall.c prctl.c
+
+SSRC-y := __longjmp.S bsd-_setjmp.S bsd-setjmp.S clone.S setjmp.S _vfork.S
diff --git a/libc/sysdeps/linux/c6x/__longjmp.S b/libc/sysdeps/linux/c6x/__longjmp.S
new file mode 100644
index 000000000..bc0b62f94
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/__longjmp.S
@@ -0,0 +1,46 @@
+ ;
+ ; 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, see <http://www.gnu.org/licenses/>.
+ ;
+
+ .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..e89212ff0
--- /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; see the file COPYING.LIB. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+#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..8baeb16be
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/bits/byteswap.h
@@ -0,0 +1,34 @@
+/*
+ * 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; see the file COPYING.LIB. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#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..a4e3e7db3
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/bits/elf-dsbt.h
@@ -0,0 +1,117 @@
+/* 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, see <http://www.gnu.org/licenses/>. */
+
+#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_Half version;
+
+ /* number of segments */
+ Elf32_Half 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/vax/bits/endian.h b/libc/sysdeps/linux/c6x/bits/endian.h
index 9f0c4e2a9..7297f9e2e 100644
--- a/libc/sysdeps/linux/vax/bits/endian.h
+++ b/libc/sysdeps/linux/c6x/bits/endian.h
@@ -1,9 +1,11 @@
-/* VAX is little endian */
+/* 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
-
-/*#define __FLOAT_WORD_ORDER __BIG_ENDIAN*/
+#endif
diff --git a/libc/sysdeps/linux/i960/bits/fcntl.h b/libc/sysdeps/linux/c6x/bits/fcntl.h
index a8efa57ec..651caa916 100644
--- a/libc/sysdeps/linux/i960/bits/fcntl.h
+++ b/libc/sysdeps/linux/c6x/bits/fcntl.h
@@ -1,5 +1,5 @@
/* O_*, F_*, FD_* bit values for Linux.
- Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
+ 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
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FCNTL_H
# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
@@ -23,6 +22,9 @@
#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 */
@@ -40,12 +42,15 @@
#define O_SYNC 010000
#define O_FSYNC O_SYNC
#define O_ASYNC 020000
+#define O_DIRECT 040000
#ifdef __USE_GNU
-# define O_DIRECT 040000 /* Direct disk access. */
+# define O_LARGEFILE 0100000
# define O_DIRECTORY 0200000 /* Must be a directory. */
-# define O_NOFOLLOW 0400000 /* Do not follow links. */
-# define O_STREAMING 04000000/* streaming access */
+# define O_NOFOLLOW 0400000 /* don't follow links */
+# define O_NOATIME 01000000
+# define O_CLOEXEC 02000000/* set close on exec */
+# define O_PATH 010000000/* Resolve pathname but do not open file. */
#endif
/* For now Linux has synchronisity options for data and read operations.
@@ -93,8 +98,6 @@
# 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. */
-# define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with
- close-on-exit set on new fd. */
#endif
/* For F_[GET|SET]FL. */
@@ -181,8 +184,7 @@ struct flock64
# define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */
#endif
-
-#ifdef __USE_GNU
+#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
@@ -205,7 +207,7 @@ struct flock64
__BEGIN_DECLS
-#ifdef __USE_GNU
+#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)
@@ -231,4 +233,3 @@ extern ssize_t tee (int __fdin, int __fdout, size_t __len,
#endif
__END_DECLS
-
diff --git a/libc/sysdeps/linux/vax/bits/ipc.h b/libc/sysdeps/linux/c6x/bits/ipc.h
index c4e37358e..4e9236eb6 100644
--- a/libc/sysdeps/linux/vax/bits/ipc.h
+++ b/libc/sysdeps/linux/c6x/bits/ipc.h
@@ -1,26 +1,25 @@
-/* Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1995-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.
+ 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
- Library General Public License for more details.
+ Lesser 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. */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_IPC_H
# error "Never use <bits/ipc.h> directly; include <sys/ipc.h> instead."
#endif
-#include <sys/types.h>
+#include <bits/types.h>
/* Mode bits for `msgget', `semget', and `shmget'. */
#define IPC_CREAT 01000 /* Create key if key does not exist. */
@@ -31,7 +30,9 @@
#define IPC_RMID 0 /* Remove identifier. */
#define IPC_SET 1 /* Set `ipc_perm' options. */
#define IPC_STAT 2 /* Get `ipc_perm' options. */
-#define IPC_INFO 3 /* See ipcs. */
+#ifdef __USE_GNU
+# define IPC_INFO 3 /* See ipcs. */
+#endif
/* Special key values. */
#define IPC_PRIVATE ((__key_t) 0) /* Private key. */
@@ -41,10 +42,13 @@
struct ipc_perm
{
__key_t __key; /* Key. */
- unsigned short int uid; /* Owner's user ID. */
- unsigned short int gid; /* Owner's group ID. */
- unsigned short int cuid; /* Creator's user ID. */
- unsigned short int cgid; /* Creator's group ID. */
- unsigned short int mode; /* Read/write permission. */
+ __uid_t uid; /* Owner's user ID. */
+ __gid_t gid; /* Owner's group ID. */
+ __uid_t cuid; /* Creator's user ID. */
+ __gid_t cgid; /* Creator's group ID. */
+ __mode_t mode; /* Read/write permission. */
unsigned short int __seq; /* Sequence number. */
+ unsigned short int __pad2;
+ unsigned long int __unused1;
+ unsigned long int __unused2;
};
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/nios/bits/kernel_types.h b/libc/sysdeps/linux/c6x/bits/kernel_types.h
index e66f42d7a..2c363a81d 100644
--- a/libc/sysdeps/linux/nios/bits/kernel_types.h
+++ b/libc/sysdeps/linux/c6x/bits/kernel_types.h
@@ -1,36 +1,41 @@
/* 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
+ * 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 __ARCH_NIOS_POSIX_TYPES_H
-#define __ARCH_NIOS_POSIX_TYPES_H
+#ifndef __ASM_GENERIC_POSIX_TYPES_H
+#define __ASM_GENERIC_POSIX_TYPES_H
-typedef unsigned short __kernel_dev_t;
+typedef unsigned int __kernel_dev_t;
typedef unsigned long __kernel_ino_t;
-typedef unsigned short __kernel_mode_t;
-typedef unsigned short __kernel_nlink_t;
-typedef long __kernel_off_t;
+typedef unsigned int __kernel_mode_t;
+typedef unsigned long __kernel_nlink_t;
typedef int __kernel_pid_t;
-typedef unsigned short __kernel_ipc_pid_t;
-typedef unsigned short __kernel_uid_t;
-typedef unsigned short __kernel_gid_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 long __kernel_long_t;
+typedef unsigned long __kernel_ulong_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_suseconds_t;
typedef long __kernel_clock_t;
-typedef int __kernel_daddr_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 unsigned int __kernel_uid32_t;
-typedef unsigned int __kernel_gid32_t;
-typedef unsigned short __kernel_old_uid_t;
-typedef unsigned short __kernel_old_gid_t;
-typedef long long __kernel_loff_t;
typedef struct {
#ifdef __USE_ALL
@@ -40,4 +45,4 @@ typedef struct {
#endif
} __kernel_fsid_t;
-#endif /* __ARCH_NIOS2_POSIX_TYPES_H */
+#endif /* __ASM_GENERIC_POSIX_TYPES_H */
diff --git a/libc/sysdeps/linux/nios/bits/mathdef.h b/libc/sysdeps/linux/c6x/bits/mathdef.h
index e013e74b7..d8670b8c8 100644
--- a/libc/sysdeps/linux/nios/bits/mathdef.h
+++ b/libc/sysdeps/linux/c6x/bits/mathdef.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999, 2000, 2004 Free Software Foundation, Inc.
+/* 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
@@ -12,25 +12,21 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#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
+#if defined __USE_ISOC99 && defined _MATH_H && !defined _MATH_H_MATHDEF
# define _MATH_H_MATHDEF 1
-/* GCC does not promote `float' values to `double'. */
-typedef float float_t; /* `float' expressions are evaluated as
- `float'. */
-typedef double double_t; /* `double' expressions are evaluated as
- `double'. */
+typedef float float_t;
+typedef double double_t;
/* The values returned by `ilogb' for 0 and NaN respectively. */
-# define FP_ILOGB0 (-2147483647)
+# define FP_ILOGB0 (-2147483647 - 1)
# define FP_ILOGBNAN (2147483647)
#endif /* ISO C99 */
@@ -38,7 +34,5 @@ typedef double double_t; /* `double' expressions are evaluated as
#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. */
-/* XXX The FPA does support this but the patterns in GCC are currently
- turned off. */
# 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..c34b16aaa
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/bits/nan.h
@@ -0,0 +1,56 @@
+/* `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, see
+ <http://www.gnu.org/licenses/>. */
+
+#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/v850/bits/poll.h b/libc/sysdeps/linux/c6x/bits/poll.h
index f7a739315..1d845ebd2 100644
--- a/libc/sysdeps/linux/v850/bits/poll.h
+++ b/libc/sysdeps/linux/c6x/bits/poll.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_POLL_H
# error "Never use <bits/poll.h> directly; include <sys/poll.h> instead."
diff --git a/libc/sysdeps/linux/c6x/bits/resource.h b/libc/sysdeps/linux/c6x/bits/resource.h
new file mode 100644
index 000000000..72b08ce84
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/bits/resource.h
@@ -0,0 +1,208 @@
+/* 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#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..993b1aa55
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/bits/setjmp.h
@@ -0,0 +1,33 @@
+/*
+ * 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; see the file COPYING.LIB. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _BITS_SETJMP_H
+#define _BITS_SETJMP_H 1
+
+#if !defined _SETJMP_H && !defined _PTHREAD_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];
+
+#endif
diff --git a/libc/sysdeps/linux/c6x/bits/sigcontextinfo.h b/libc/sysdeps/linux/c6x/bits/sigcontextinfo.h
new file mode 100644
index 000000000..851c21d04
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/bits/sigcontextinfo.h
@@ -0,0 +1,25 @@
+/* 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#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..952c3a699
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/bits/stackinfo.h
@@ -0,0 +1,27 @@
+/* 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, see
+ <http://www.gnu.org/licenses/>. */
+
+/* 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..70b708d70
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/bits/syscalls.h
@@ -0,0 +1,184 @@
+#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 (unlikely (INTERNAL_SYSCALL_ERROR_P (_inline_sys_result, ))) \
+ { \
+ __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...) \
+(__extension__ \
+ ({ \
+ 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/nios/bits/uClibc_arch_features.h b/libc/sysdeps/linux/c6x/bits/uClibc_arch_features.h
index f4adaf5ad..7b6077e3e 100644
--- a/libc/sysdeps/linux/nios/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/c6x/bits/uClibc_arch_features.h
@@ -10,30 +10,33 @@
#undef __UCLIBC_ABORT_INSTRUCTION__
/* can your target use syscall6() for mmap ? */
-#undef __UCLIBC_MMAP_HAS_6_ARGS__
+#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 align 64bit values in register pairs ? (32bit arches only) */
+#undef __UCLIBC_SYSCALL_ALIGN_64BIT__
/* 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/v850/bits/wordsize.h b/libc/sysdeps/linux/c6x/bits/wordsize.h
index ba643b60a..ca82fd7d4 100644
--- a/libc/sysdeps/linux/v850/bits/wordsize.h
+++ b/libc/sysdeps/linux/c6x/bits/wordsize.h
@@ -12,8 +12,7 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#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..a390c8e11
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/brk.c
@@ -0,0 +1,53 @@
+/*
+ * 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; see the file COPYING.LIB. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#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..f58f85b51
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/bsd-_setjmp.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, see <http://www.gnu.org/licenses/>.
+ ;
+
+ .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..40bdd0c7f
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/bsd-setjmp.S
@@ -0,0 +1,66 @@
+ ;
+ ; 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, see <http://www.gnu.org/licenses/>.
+ ;
+
+ .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..60c8c2765
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/clone.S
@@ -0,0 +1,97 @@
+ ;
+ ; 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, see <http://www.gnu.org/licenses/>.
+ ;
+#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..18efc7241
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/crt1.S
@@ -0,0 +1,66 @@
+;
+; 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, see <http://www.gnu.org/licenses/>.
+;
+
+ .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/jmpbuf-offsets.h b/libc/sysdeps/linux/c6x/jmpbuf-offsets.h
new file mode 100644
index 000000000..266dc2ccf
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/jmpbuf-offsets.h
@@ -0,0 +1,22 @@
+/* Private macros for accessing __jmp_buf contents. c6x version.
+ * 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; see the file COPYING.LIB. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+/* the stack pointer (B15) */
+#define JP_SP 11
diff --git a/libc/sysdeps/linux/c6x/jmpbuf-unwind.h b/libc/sysdeps/linux/c6x/jmpbuf-unwind.h
new file mode 100644
index 000000000..ad2ab5979
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/jmpbuf-unwind.h
@@ -0,0 +1,28 @@
+/*
+ * 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; see the file COPYING.LIB. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+#include <setjmp.h>
+#include <jmpbuf-offsets.h>
+
+/* 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/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/setjmp.s b/libc/sysdeps/linux/c6x/setjmp.s
new file mode 100644
index 000000000..d637ab208
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/setjmp.s
@@ -0,0 +1,42 @@
+ ;
+ ; 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, see <http://www.gnu.org/licenses/>.
+ ;
+
+ .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..a9495b717
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/sigaction.c
@@ -0,0 +1,121 @@
+/*
+ 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,
+ see <http://www.gnu.org/licenses/>.
+
+ 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>
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+# include <pthreadP.h> /* SIGCANCEL */
+#endif
+
+#define SA_RESTORER 0x04000000
+
+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
+# ifndef __UCLIBC_HAS_THREADS__
+strong_alias(__libc_sigaction,sigaction)
+libc_hidden_def(sigaction)
+# else
+weak_alias(__libc_sigaction,sigaction)
+libc_hidden_weak(sigaction)
+# endif
+#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/i960/sys/procfs.h b/libc/sysdeps/linux/c6x/sys/procfs.h
index 27abf8ef5..0d0859fac 100644
--- a/libc/sysdeps/linux/i960/sys/procfs.h
+++ b/libc/sysdeps/linux/c6x/sys/procfs.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_PROCFS_H
#define _SYS_PROCFS_H 1
@@ -42,13 +41,9 @@ typedef unsigned long elf_greg_t;
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 (sizeof (struct user_regs_struct) / sizeof(elf_greg_t))
+#define ELF_NGREG 20
typedef elf_greg_t elf_gregset_t[ELF_NGREG];
-/* Register set for the floating-point registers. */
-typedef struct user_m68kfp_struct elf_fpregset_t;
-
-
/* Signal info. */
struct elf_siginfo
{
@@ -111,7 +106,7 @@ typedef void *psaddr_t;
/* Register sets. Linux has different names. */
typedef elf_gregset_t prgregset_t;
-typedef elf_fpregset_t prfpregset_t;
+typedef elf_gregset_t prfpregset_t;
/* We don't have any differences between processes and threads,
therefore have only one PID type. */
diff --git a/libc/sysdeps/linux/xtensa/sys/ptrace.h b/libc/sysdeps/linux/c6x/sys/ptrace.h
index 7aad929bb..8ca7e15a9 100644
--- a/libc/sysdeps/linux/xtensa/sys/ptrace.h
+++ b/libc/sysdeps/linux/c6x/sys/ptrace.h
@@ -1,6 +1,5 @@
/* `ptrace' debugger support interface. Linux version.
- Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007
- Free Software Foundation, Inc.
+ 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
@@ -14,24 +13,14 @@
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., 51 Franklin Street - Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_PTRACE_H
#define _SYS_PTRACE_H 1
#include <features.h>
-/* Kludge away careless namespace pollution from the kernel. */
-
-#undef PTRACE_GETREGS
-#undef PTRACE_SETREGS
-#undef PTRACE_GETFPREGS
-#undef PTRACE_SETFPREGS
-#undef PTRACE_GETFPREGSIZE
-
-
__BEGIN_DECLS
/* Type of the REQUEST argument to `ptrace.' */
@@ -108,14 +97,35 @@ enum __ptrace_request
PTRACE_DETACH = 17,
#define PT_DETACH PTRACE_DETACH
- /* Get size required for the buffer holding the floating point registers.
+ /* 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_GETFPREGSIZE = 18,
-#define PT_GETFPREGSIZE PTRACE_GETFPREGSIZE
+ PTRACE_SETFPXREGS = 19,
+#define PT_SETFPXREGS PTRACE_SETFPXREGS
/* Continue and stop at the next (return from) syscall. */
- PTRACE_SYSCALL = 24
+ PTRACE_SYSCALL = 24,
#define PT_SYSCALL PTRACE_SYSCALL
+
+ /* 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
};
/* Options set using PTRACE_SETOPTIONS. */
diff --git a/libc/sysdeps/linux/c6x/sys/reg.h b/libc/sysdeps/linux/c6x/sys/reg.h
new file mode 100644
index 000000000..306dd8e24
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/sys/reg.h
@@ -0,0 +1,25 @@
+/*
+ * 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; see the file COPYING.LIB. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+#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..476fc7317
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/sys/ucontext.h
@@ -0,0 +1,38 @@
+/* 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#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..65bef0e73
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/sys/user.h
@@ -0,0 +1,27 @@
+/* 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#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-generic/bits/align64bit.h b/libc/sysdeps/linux/common-generic/bits/align64bit.h
new file mode 100644
index 000000000..ece566ac4
--- /dev/null
+++ b/libc/sysdeps/linux/common-generic/bits/align64bit.h
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#ifndef _ALIGN_64_BIT_H
+#define _ALIGN_64_BIT_H
+
+/* Simple macro for getting the 64-bit struct arch alignment */
+
+struct __longlong_aligned { long long x; };
+
+#define __ARCH_64BIT_ALIGNMENT__ \
+ __attribute__((aligned(__alignof__(struct __longlong_aligned))))
+
+#endif /* bits/align64bit.h */
diff --git a/libc/sysdeps/linux/common-generic/bits/dirent.h b/libc/sysdeps/linux/common-generic/bits/dirent.h
new file mode 100644
index 000000000..74edd305d
--- /dev/null
+++ b/libc/sysdeps/linux/common-generic/bits/dirent.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#ifndef _DIRENT_H
+# error "Never use <bits/dirent.h> directly; include <dirent.h> instead."
+#endif
+
+#include <bits/align64bit.h>
+#include <endian.h>
+
+struct dirent
+ {
+#ifndef __USE_FILE_OFFSET64
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+ __U32_TYPE d_ino;
+ __U32_TYPE __pad1;
+ __S32_TYPE d_off;
+ __S32_TYPE __pad2;
+# else
+ __U32_TYPE __pad1;
+ __U32_TYPE d_ino;
+ __S32_TYPE __pad2;
+ __S32_TYPE d_off;
+# endif /* __LITTLE_ENDIAN */
+#else
+ __U64_TYPE d_ino;
+ __S64_TYPE d_off;
+#endif
+ unsigned short int d_reclen;
+ unsigned char d_type;
+ char d_name[256]; /* We must not include limits.h! */
+ } __ARCH_64BIT_ALIGNMENT__;
+
+#ifdef __USE_LARGEFILE64
+struct dirent64
+ {
+ __U64_TYPE d_ino;
+ __S64_TYPE d_off;
+ unsigned short int d_reclen;
+ unsigned char d_type;
+ char d_name[256]; /* We must not include limits.h! */
+ };
+#endif
+
+#define d_fileno d_ino /* Backwards compatibility. */
+
+#undef _DIRENT_HAVE_D_NAMLEN
+#define _DIRENT_HAVE_D_RECLEN
+#define _DIRENT_HAVE_D_OFF
+#define _DIRENT_HAVE_D_TYPE
diff --git a/libc/sysdeps/linux/common-generic/bits/kernel_stat.h b/libc/sysdeps/linux/common-generic/bits/kernel_stat.h
new file mode 100644
index 000000000..843a1d1a6
--- /dev/null
+++ b/libc/sysdeps/linux/common-generic/bits/kernel_stat.h
@@ -0,0 +1,28 @@
+/*
+ * 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_STAT_STRUCT_H
+#define _BITS_STAT_STRUCT_H
+
+#include <sys/stat.h>
+
+/*
+ * The stat structure defined in
+ * libc/sysdeps/linux/common-generic/bits/stat.h
+ * is the same as the kernel one for new architectures
+ *
+ * For the common-generic ABI we really don't need this file at all
+ * However that requires more #ifndef in relevant wrappers,
+ * further uglifying them
+ */
+#if defined __UCLIBC_HAS_LFS__
+#define kernel_stat64 stat64
+#else
+#define kernel_stat64 stat
+#endif
+
+#endif /* _BITS_STAT_STRUCT_H */
+
diff --git a/libc/sysdeps/linux/common-generic/bits/stat.h b/libc/sysdeps/linux/common-generic/bits/stat.h
new file mode 100644
index 000000000..945c408a0
--- /dev/null
+++ b/libc/sysdeps/linux/common-generic/bits/stat.h
@@ -0,0 +1,195 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#ifndef _SYS_STAT_H
+# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
+#endif
+
+#include <bits/align64bit.h>
+#include <endian.h>
+
+/* Versions of the `struct stat' data structure. */
+#define _STAT_VER_LINUX_OLD 1
+#define _STAT_VER_KERNEL 1
+#define _STAT_VER_SVR4 2
+#define _STAT_VER_LINUX 3
+#define _STAT_VER _STAT_VER_LINUX /* The one defined below. */
+
+/* Versions of the `xmknod' interface. */
+#define _MKNOD_VER_LINUX 1
+#define _MKNOD_VER_SVR4 2
+#define _MKNOD_VER _MKNOD_VER_LINUX /* The bits defined below. */
+
+/*
+ * For 32-bit architectures, this struct is similar to the stat64 but it
+ * uses 32-bit members along with 32-bit padding. For 64-bit architectures
+ * this struct is exactly the same with the stat64 one
+ */
+struct stat
+ {
+#ifndef __USE_FILE_OFFSET64
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+ unsigned long st_dev; /* Device. */
+ unsigned long __pad1;
+ unsigned long st_ino; /* 32bit file serial number. */
+ unsigned long __pad2;
+ 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 __pad3;
+ unsigned long long __pad4;
+ long st_size; /* SIze of file, in bytes. */
+ long __pad5;
+ int st_blksize; /* Optimal block size for I/O. */
+ int __pad6;
+ long st_blocks; /* Number 512-byte blocks allocated */
+ long __pad7;
+# else
+ unsigned long __pad1;
+ unsigned long st_dev; /* Device. */
+ unsigned long __pad2;
+ unsigned long st_ino; /* 32bit 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 __pad3;
+ unsigned long st_rdev; /* Device number, if device. */
+ unsigned long long __pad4;
+ long __pad5;
+ long st_size; /* Size of file, in bytes. */
+ int st_blksize; /* Optimal block size for I/O. */
+ int __pad6;
+ long __pad7;
+ long st_blocks; /* Number 512-byte blocks allocated */
+# endif /* __LITTLE_ENDIAN */
+#else
+ unsigned long long st_dev; /* Device. */
+ unsigned long long st_ino; /* 32bit 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 */
+#endif
+#ifdef __USE_MISC
+ /* Nanosecond resolution timestamps are stored in a format
+ equivalent to 'struct timespec'. This is the type used
+ whenever possible but the Unix namespace rules do not allow the
+ identifier 'timespec' to appear in the <sys/stat.h> header.
+ Therefore we have to handle the use of this header in strictly
+ standard-compliant sources special. */
+ struct timespec st_atim; /* Time of last access. */
+ struct timespec st_mtim; /* Time of last modification. */
+ struct timespec st_ctim; /* Time of last status change. */
+# define st_atime st_atim.tv_sec /* Backward compatibility. */
+# define st_mtime st_mtim.tv_sec
+# define st_ctime st_ctim.tv_sec
+#else
+# ifndef __USE_FILE_OFFSET64
+ long st_atime; /* Time of last access. */
+ unsigned long st_atime_nsec;
+ long st_mtime; /* Time of last modification. */
+ unsigned long st_mtime_nsec;
+ long st_ctime; /* Time of last status change. */
+ unsigned long st_ctime_nsec;
+# else
+ int st_atime; /* Time of last access. */
+ unsigned int st_atime_nsec;
+ int st_mtime; /* Time of last modification. */
+ unsigned int st_mtime_nsec;
+ int st_ctime; /* Time of last status change. */
+ unsigned int st_ctime_nsec;
+# endif
+#endif
+ unsigned int __unused4;
+ unsigned int __unused5;
+ } __ARCH_64BIT_ALIGNMENT__;
+
+
+#ifdef __USE_LARGEFILE64
+struct stat64
+ {
+ unsigned long long st_dev; /* Device. */
+ unsigned long long st_ino; /* 32bit 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 __pad3;
+ long long st_size; /* Size of file, in bytes. */
+ int st_blksize; /* Optimal block size for I/O. */
+ int __pad4;
+ long long st_blocks; /* Number 512-byte blocks allocated */
+# ifdef __USE_MISC
+ /* Nanosecond resolution timestamps are stored in a format
+ equivalent to 'struct timespec'. This is the type used
+ whenever possible but the Unix namespace rules do not allow the
+ identifier 'timespec' to appear in the <sys/stat.h> header.
+ Therefore we have to handle the use of this header in strictly
+ standard-compliant sources special. */
+ struct timespec st_atim; /* Time of last access. */
+ struct timespec st_mtim; /* Time of last modification. */
+ struct timespec st_ctim; /* Time of last status change. */
+# else
+ int st_atime; /* Time of last access. */
+ unsigned int st_atime_nsec;
+ int st_mtime; /* Time of last modification. */
+ unsigned int st_mtime_nsec;
+ int st_ctime; /* Time of last status change. */
+ unsigned int st_ctime_nsec;
+# endif
+ unsigned int __unused4;
+ unsigned int __unused5;
+};
+#endif
+
+/* Tell code we have these members. */
+#define _STATBUF_ST_BLKSIZE
+#define _STATBUF_ST_RDEV
+/* Nanosecond resolution time values are supported. */
+#define _STATBUF_ST_NSEC
+
+/* Encoding of the file mode. */
+
+#define __S_IFMT 0170000 /* These bits determine file type. */
+
+/* File types. */
+#define __S_IFDIR 0040000 /* Directory. */
+#define __S_IFCHR 0020000 /* Character device. */
+#define __S_IFBLK 0060000 /* Block device. */
+#define __S_IFREG 0100000 /* Regular file. */
+#define __S_IFIFO 0010000 /* FIFO. */
+#define __S_IFLNK 0120000 /* Symbolic link. */
+#define __S_IFSOCK 0140000 /* Socket. */
+
+/* POSIX.1b objects. Note that these macros always evaluate to zero. But
+ they do it by enforcing the correct use of the macros. */
+#define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode)
+#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
+#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
+
+/* Protection bits. */
+
+#define __S_ISUID 04000 /* Set user ID on execution. */
+#define __S_ISGID 02000 /* Set group ID on execution. */
+#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
+#define __S_IREAD 0400 /* Read by owner. */
+#define __S_IWRITE 0200 /* Write by owner. */
+#define __S_IEXEC 0100 /* Execute by owner. */
+
+#ifdef __USE_ATFILE
+# define UTIME_NOW ((1l << 30) - 1l)
+# define UTIME_OMIT ((1l << 30) - 2l)
+#endif
diff --git a/libc/sysdeps/linux/common-generic/bits/statfs.h b/libc/sysdeps/linux/common-generic/bits/statfs.h
new file mode 100644
index 000000000..a2767b49a
--- /dev/null
+++ b/libc/sysdeps/linux/common-generic/bits/statfs.h
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#ifndef _SYS_STATFS_H
+# error "Never include <bits/statfs.h> directly; use <sys/statfs.h> instead."
+#endif
+
+#include <endian.h>
+#include <bits/align64bit.h>
+#include <bits/types.h>
+
+
+struct statfs
+ {
+ __U32_TYPE f_type;
+ __U32_TYPE f_bsize;
+#ifndef __USE_FILE_OFFSET64
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+ __U32_TYPE f_blocks;
+ __U32_TYPE __pad1;
+ __U32_TYPE f_bfree;
+ __U32_TYPE __pad2;
+ __U32_TYPE f_bavail;
+ __U32_TYPE __pad3;
+ __U32_TYPE f_files;
+ __U32_TYPE __pad4;
+ __U32_TYPE f_ffree;
+ __U32_TYPE __pad5;
+# else
+ __U32_TYPE __pad1;
+ __U32_TYPE f_blocks;
+ __U32_TYPE __pad2;
+ __U32_TYPE f_bfree;
+ __U32_TYPE __pad3;
+ __U32_TYPE f_bavail;
+ __U32_TYPE __pad4;
+ __U32_TYPE f_files;
+ __U32_TYPE __pad5;
+ __U32_TYPE f_ffree;
+# endif /* __LITTLE_ENDIAN */
+#else
+ __U64_TYPE f_blocks;
+ __U64_TYPE f_bfree;
+ __U64_TYPE f_bavail;
+ __U64_TYPE f_files;
+ __U64_TYPE f_ffree;
+#endif /* __USE_FILE_OFFSET64 */
+ __fsid_t f_fsid;
+ __U32_TYPE f_namelen;
+ __U32_TYPE f_frsize;
+ __U32_TYPE f_flags;
+ __U32_TYPE f_spare[4];
+ } __ARCH_64BIT_ALIGNMENT__;
+
+#ifdef __USE_LARGEFILE64
+struct statfs64
+ {
+ __U32_TYPE f_type;
+ __U32_TYPE f_bsize;
+ __U64_TYPE f_blocks;
+ __U64_TYPE f_bfree;
+ __U64_TYPE f_bavail;
+ __U64_TYPE f_files;
+ __U64_TYPE f_ffree;
+ __fsid_t f_fsid;
+ __U32_TYPE f_namelen;
+ __U32_TYPE f_frsize;
+ __U32_TYPE f_flags;
+ __U32_TYPE f_spare[4];
+ };
+#endif
+
+/* Tell code we have these members. */
+#define _STATFS_F_NAMELEN
+#define _STATFS_F_FRSIZE
diff --git a/libc/sysdeps/linux/common/Makefile.in b/libc/sysdeps/linux/common/Makefile.in
index c55f0fe49..887dc3d62 100644
--- a/libc/sysdeps/linux/common/Makefile.in
+++ b/libc/sysdeps/linux/common/Makefile.in
@@ -1,6 +1,6 @@
# Makefile for uClibc
#
-# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2008 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
@@ -8,84 +8,127 @@
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
-ifeq ($(EXCLUDE_BRK),y)
-CSRC := $(filter-out sbrk.c,$(CSRC))
-endif
-
-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 delete_module.c init_module.c \
- query_module.c get_kernel_syms.c,$(CSRC))
-endif
-
-ifneq ($(UCLIBC_LINUX_SPECIFIC),y)
+CSRC-y := $(filter-out llseek.c $(CSRC_LFS),$(CSRC-y))
+CSRC-$(UCLIBC_HAS_LFS) += llseek.c $(CSRC_LFS)
+CSRC-$(findstring y,$(UCLIBC_HAS_SSP)$(UCLIBC_HAS_FORTIFY)) += ssp.c
+CSRC-$(UCLIBC_LINUX_MODULE_26) += delete_module.c init_module.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 inotify.c ioperm.c iopl.c madvise.c \
- modify_ldt.c personality.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 swapoff.c swapon.c sync_file_range.c \
- sysctl.c sysinfo.c uselib.c vhangup.c,$(CSRC))
+CSRC-$(UCLIBC_LINUX_SPECIFIC) += \
+ bdflush.c \
+ capget.c \
+ capset.c \
+ dup3.c \
+ euidaccess.c \
+ eventfd.c \
+ eventfd_read.c \
+ eventfd_write.c \
+ fanotify.c \
+ getrandom.c \
+ inotify.c \
+ ioperm.c \
+ iopl.c \
+ modify_ldt.c \
+ personality.c \
+ pipe2.c \
+ ppoll.c \
+ prctl.c \
+ readahead.c \
+ reboot.c \
+ remap_file_pages.c \
+ sched_cpucount.c \
+ sched_getaffinity.c \
+ sched_getcpu.c \
+ sched_setaffinity.c \
+ sendfile.c \
+ setfsgid.c \
+ setfsuid.c \
+ setns.c \
+ setresgid.c \
+ setresuid.c \
+ signalfd.c \
+ splice.c \
+ swapoff.c \
+ swapon.c \
+ sync_file_range.c \
+ syncfs.c \
+ sysctl.c \
+ sysinfo.c \
+ tee.c \
+ timerfd.c \
+ umount2.c \
+ umount.c \
+ unshare.c \
+ uselib.c \
+ vhangup.c \
+ vmsplice.c
+CSRC-$(if $(findstring yy,$(UCLIBC_LINUX_SPECIFIC)$(UCLIBC_HAS_LFS)),y) += \
+ sendfile64.c
+# posix_fallocate() needs __libc_fallocate() from fallocate.c
+# posix_fallocate64() needs __libc_fallocate64() from fallocate64.c
+CSRC-$(if $(UCLIBC_LINUX_SPECIFIC)$(UCLIBC_HAS_ADVANCED_REALTIME),y,) += \
+ fallocate.c $(filter fallocate64.c,$(CSRC-y))
+# NPTL needs these internally: madvise.c
+CSRC-$(findstring y,$(UCLIBC_LINUX_SPECIFIC)$(UCLIBC_HAS_THREADS_NATIVE)) += madvise.c
+ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
+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)
+CSRC- += $(if $(findstring =metag=,=$(TARGET_ARCH)=),vfork.c)
endif
-
-ifneq ($(UCLIBC_BSD_SPECIFIC),y)
-# we need these internally: getdomainname.c
-CSRC := $(filter-out mincore.c setdomainname.c,$(CSRC))
+ifneq ($(ARCH_HAS_DEPRECATED_SYSCALLS),y)
+# No conversion is needed for new architectures
+CSRC- += xstatconv.c
endif
-
-ifneq ($(UCLIBC_NTP_LEGACY),y)
-CSRC := $(filter-out ntp_gettime.c,$(CSRC))
-endif
-
-
-ifneq ($(UCLIBC_HAS_REALTIME),y)
-# 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)
+# stubbed out in mman.h
+CSRC-$(ARCH_USE_MMU) += msync.c
+# we need these internally: getdomainname.c
+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|timer_create|timer_delete|timer_getoverrun|timer_gettime|timer_settime
+CSRC-$(UCLIBC_HAS_REALTIME) += clock_adjtime.c clock_getres.c clock_gettime.c clock_settime.c \
+ fdatasync.c mlockall.c mlock.c munlockall.c munlock.c \
+ nanosleep.c __rt_sigtimedwait.c __rt_sigwaitinfo.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_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
+CSRC-$(UCLIBC_HAS_ADVANCED_REALTIME) += posix_fadvise64.c posix_fadvise.c posix_madvise.c \
+ posix_fallocate.c posix_fallocate64.c
+CSRC-$(UCLIBC_SUSV4_LEGACY) += utime.c
+CSRC- += epoll.c # multi-source
+CSRC-$(UCLIBC_HAS_EPOLL) += epoll_create.c epoll_ctl.c epoll_wait.c epoll_pwait.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)=),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-y := $(filter-out $(libc_a_CSRC) $(notdir $(libpthread_libc_OBJS:.o=.c)),$(CSRC-y))
+SSRC-y := $(filter-out $(libc_a_SSRC) $(notdir $(libpthread_libc_OBJS:.o=.S)),$(SSRC-y))
# fails for some reason
-ifneq ($(strip $(ARCH_OBJS)),)
-CSRC := $(filter-out $(notdir $(ARCH_OBJS:.o=.c)),$(CSRC))
+ifneq ($(strip $(ARCH_OBJS-y)),)
+CSRC-y := $(filter-out $(notdir $(ARCH_OBJS-y:.o=.c)) $(ARCH_OBJ_FILTEROUT-y),$(CSRC-y))
endif
+CFLAGS-OMIT-ssp.c := $(CFLAG_-fstack-protector) $(CFLAG_-fstack-protector-all) $(CFLAG_-fstack-protector-strong)
+CFLAGS-OMIT-ssp-local.c := $(CFLAG_-fstack-protector) $(CFLAG_-fstack-protector-all) $(CFLAG_-fstack-protector-strong)
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
@@ -97,7 +140,7 @@ libc-nomulti-y += $(COMMON_OUT)/__syscall_rt_sigaction.o \
$(COMMON_OUT)/stat.o
libc-nomulti-$(UCLIBC_HAS_SSP) += $(COMMON_OUT)/ssp.o
-objclean-y += common_objclean
+objclean-y += CLEAN_libc/sysdeps/linux/common
-common_objclean:
- $(RM) $(COMMON_OUT)/*.{o,os,oS}
+CLEAN_libc/sysdeps/linux/common:
+ $(do_rm) $(addprefix $(COMMON_OUT)/*., o os oS)
diff --git a/libc/sysdeps/linux/common/__rt_sigtimedwait.c b/libc/sysdeps/linux/common/__rt_sigtimedwait.c
index 839532b03..422a95201 100644
--- a/libc/sysdeps/linux/common/__rt_sigtimedwait.c
+++ b/libc/sysdeps/linux/common/__rt_sigtimedwait.c
@@ -2,53 +2,73 @@
/*
* __rt_sigtimedwait() for uClibc
*
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ * Copyright (C) 2006 by Steven Hill <sjhill@realitydiluted.com>
+ * Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org>
*
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ * GNU Library General Public License (LGPL) version 2 or later.
*/
#include <sys/syscall.h>
-#include <signal.h>
-#define __need_NULL
-#include <stddef.h>
-
-libc_hidden_proto(sigwaitinfo)
-libc_hidden_proto(sigtimedwait)
#ifdef __NR_rt_sigtimedwait
-#define __NR___rt_sigtimedwait __NR_rt_sigtimedwait
-static _syscall4(int, __rt_sigtimedwait, const sigset_t *, set, siginfo_t *, info,
- const struct timespec *, timeout, size_t, setsize);
+# include <signal.h>
+# include <cancel.h>
+# ifdef __UCLIBC_HAS_THREADS_NATIVE__
+# include <pthreadP.h> /* SIGCANCEL */
+# endif
+# ifdef SIGCANCEL
+# define __need_NULL
+# include <stddef.h>
+# include <string.h>
+# endif
-int sigwaitinfo(const sigset_t * set, siginfo_t * info)
+int __NC(sigtimedwait)(const sigset_t *set, siginfo_t *info,
+ const struct timespec *timeout)
{
- return __rt_sigtimedwait(set, info, NULL, _NSIG / 8);
-}
+# ifdef SIGCANCEL
+ sigset_t tmpset;
-int sigtimedwait(const sigset_t * set, siginfo_t * info,
- const struct timespec *timeout)
-{
- return __rt_sigtimedwait(set, info, timeout, _NSIG / 8);
-}
-#else
-int sigwaitinfo(const sigset_t * set, siginfo_t * info)
-{
- if (set == NULL)
- __set_errno(EINVAL);
- else
- __set_errno(ENOSYS);
- return -1;
-}
+ if (set != NULL && (unlikely (__sigismember (set, SIGCANCEL))
+# ifdef SIGSETXID
+ || unlikely (__sigismember (set, SIGSETXID))
+# endif
+ ))
+ {
+ /* Create a temporary mask without the bit for SIGCANCEL set. */
+ // We are not copying more than we have to.
+ memcpy (&tmpset, set, _NSIG / 8);
+ __sigdelset (&tmpset, SIGCANCEL);
+# ifdef SIGSETXID
+ __sigdelset (&tmpset, SIGSETXID);
+# endif
+ set = &tmpset;
+ }
+# endif
-int sigtimedwait(const sigset_t * set, siginfo_t * info,
- const struct timespec *timeout)
-{
- if (set == NULL)
- __set_errno(EINVAL);
- else
- __set_errno(ENOSYS);
- return -1;
+/* if this is enabled, enable the disabled section in sigwait.c */
+# if defined SI_TKILL && defined SI_USER
+ /* XXX The size argument hopefully will have to be changed to the
+ real size of the user-level sigset_t. */
+ /* on uClibc we use the kernel sigset_t size */
+ int result = INLINE_SYSCALL(rt_sigtimedwait, 4, set, info,
+ timeout, __SYSCALL_SIGSET_T_SIZE);
+
+ /* The kernel generates a SI_TKILL code in si_code in case tkill is
+ used. tkill is transparently used in raise(). Since having
+ SI_TKILL as a code is useful in general we fold the results
+ here. */
+ if (result != -1 && info != NULL && info->si_code == SI_TKILL)
+ info->si_code = SI_USER;
+
+ return result;
+# else
+ /* on uClibc we use the kernel sigset_t size */
+ return INLINE_SYSCALL(rt_sigtimedwait, 4, set, info,
+ timeout, __SYSCALL_SIGSET_T_SIZE);
+# endif
}
+CANCELLABLE_SYSCALL(int, sigtimedwait,
+ (const sigset_t *set, siginfo_t *info, const struct timespec *timeout),
+ (set, info, timeout))
+lt_libc_hidden(sigtimedwait)
#endif
-libc_hidden_def(sigwaitinfo)
-libc_hidden_def(sigtimedwait)
diff --git a/libc/sysdeps/linux/common/__rt_sigwaitinfo.c b/libc/sysdeps/linux/common/__rt_sigwaitinfo.c
new file mode 100644
index 000000000..ad1a7a890
--- /dev/null
+++ b/libc/sysdeps/linux/common/__rt_sigwaitinfo.c
@@ -0,0 +1,25 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * __rt_sigwaitinfo() for uClibc
+ *
+ * Copyright (C) 2006 by Steven Hill <sjhill@realitydiluted.com>
+ * Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org>
+ *
+ * GNU Library General Public License (LGPL) version 2 or later.
+ */
+
+#include <sys/syscall.h>
+
+#ifdef __NR_rt_sigtimedwait
+# define __need_NULL
+# include <stddef.h>
+# include <signal.h>
+# include <cancel.h>
+
+int sigwaitinfo(const sigset_t *set, siginfo_t *info)
+{
+ return sigtimedwait(set, info, NULL);
+}
+/* cancellation handled by sigtimedwait, noop on uClibc */
+LIBC_CANCEL_HANDLED();
+#endif
diff --git a/libc/sysdeps/linux/common/__socketcall.c b/libc/sysdeps/linux/common/__socketcall.c
index 5a959a63c..a1fc41779 100644
--- a/libc/sysdeps/linux/common/__socketcall.c
+++ b/libc/sysdeps/linux/common/__socketcall.c
@@ -8,8 +8,18 @@
*/
#include <sys/syscall.h>
+
+/* At the time of this writing,
+ * several arches provide the individual calls and do _not_ go through
+ * this demuxer.
+ *
+ * Verify all arches supported by your kernel before you remove the
+ * guard below!
+ */
#ifdef __NR_socketcall
+#include <sys/socket.h>
+
#define __NR___socketcall __NR_socketcall
-int __socketcall(int __call, unsigned long *__args) attribute_hidden;
-_syscall2(int, __socketcall, int, call, unsigned long *, args);
+_syscall2(int, __socketcall, int, call, unsigned long *, args)
+
#endif
diff --git a/libc/sysdeps/linux/common/__syscall_fcntl.c b/libc/sysdeps/linux/common/__syscall_fcntl.c
index e99a66214..17c67182e 100644
--- a/libc/sysdeps/linux/common/__syscall_fcntl.c
+++ b/libc/sysdeps/linux/common/__syscall_fcntl.c
@@ -2,6 +2,7 @@
/*
* __syscall_fcntl() for uClibc
*
+ * Copyright (C) 2006 Steven J. Hill <sjhill@realitydiluted.com>
* Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
@@ -9,51 +10,61 @@
#include <sys/syscall.h>
#include <stdarg.h>
+#include <cancel.h> /* Must come before <fcntl.h>. */
#include <fcntl.h>
#include <bits/wordsize.h>
-extern __typeof(fcntl) __libc_fcntl;
-libc_hidden_proto(__libc_fcntl)
-
-#if defined __UCLIBC_HAS_LFS__ && defined __NR_fcntl64
-extern __typeof(fcntl64) __libc_fcntl64;
-libc_hidden_proto(__libc_fcntl64)
+int __NC(fcntl)(int fd, int cmd, long arg)
+{
+#if __WORDSIZE == 32
+ if (cmd == F_GETLK64 || cmd == F_SETLK64 || cmd == F_SETLKW64) {
+# if (defined __UCLIBC_HAS_LFS__ && defined __NR_fcntl64) || !defined __NR_fcntl
+ return INLINE_SYSCALL(fcntl64, 3, fd, cmd, arg);
+# else
+ __set_errno(ENOSYS);
+ return -1;
+# endif
+ }
#endif
-#define __NR___syscall_fcntl __NR_fcntl
-static inline
-_syscall3(int, __syscall_fcntl, int, fd, int, cmd, long, arg);
+#if defined __NR_fcntl
+ return INLINE_SYSCALL(fcntl, 3, fd, cmd, arg);
+#else
+ __set_errno(ENOSYS);
+ return -1;
+#endif
+}
-int __libc_fcntl(int fd, int cmd, ...)
+int fcntl(int fd, int cmd, ...)
{
+ va_list ap;
long arg;
- va_list list;
- va_start(list, cmd);
- arg = va_arg(list, long);
- va_end(list);
+ va_start (ap, cmd);
+ arg = va_arg (ap, long);
+ va_end (ap);
-#if __WORDSIZE == 32
- if (cmd == F_GETLK64 || cmd == F_SETLK64 || cmd == F_SETLKW64) {
-#if defined __UCLIBC_HAS_LFS__ && defined __NR_fcntl64
- return __libc_fcntl64(fd, cmd, arg);
+ if (SINGLE_THREAD_P || (cmd != F_SETLKW && cmd != F_SETLKW64))
+#if defined __NR_fcntl
+ return __NC(fcntl)(fd, cmd, arg);
#else
- __set_errno(ENOSYS);
- return -1;
+ return INLINE_SYSCALL(fcntl64, 3, fd, cmd, arg);
#endif
- }
+#ifdef __NEW_THREADS
+ int oldtype = LIBC_CANCEL_ASYNC ();
+#if defined __NR_fcntl
+ int result = __NC(fcntl)(fd, cmd, arg);
+#else
+ int result = INLINE_SYSCALL(fcntl64, 3, fd, cmd, arg);
+#endif
+ LIBC_CANCEL_RESET (oldtype);
+ return result;
#endif
-
- return (__syscall_fcntl(fd, cmd, arg));
}
-libc_hidden_def(__libc_fcntl)
-
-libc_hidden_proto(fcntl)
-weak_alias(__libc_fcntl,fcntl)
-libc_hidden_weak(fcntl)
-#if ! defined __NR_fcntl64 && defined __UCLIBC_HAS_LFS__
-strong_alias(__libc_fcntl,__libc_fcntl64)
-libc_hidden_proto(fcntl64)
-weak_alias(__libc_fcntl,fcntl64)
-libc_hidden_weak(fcntl64)
+lt_strong_alias(fcntl)
+lt_libc_hidden(fcntl)
+#if defined __UCLIBC_HAS_LFS__ && !defined __NR_fcntl64 && __WORDSIZE == 32
+strong_alias_untyped(fcntl,fcntl64)
+lt_strong_alias(fcntl64)
+lt_libc_hidden(fcntl64)
#endif
diff --git a/libc/sysdeps/linux/common/__syscall_fcntl64.c b/libc/sysdeps/linux/common/__syscall_fcntl64.c
index 84c2ea2bf..eaef22b3b 100644
--- a/libc/sysdeps/linux/common/__syscall_fcntl64.c
+++ b/libc/sysdeps/linux/common/__syscall_fcntl64.c
@@ -7,17 +7,19 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+#include <_lfs_64.h>
#include <sys/syscall.h>
-#include <stdarg.h>
-#include <fcntl.h>
+#include <bits/wordsize.h>
-#if defined __UCLIBC_HAS_LFS__ && defined __NR_fcntl64
-extern __typeof(fcntl64) __libc_fcntl64;
-libc_hidden_proto(__libc_fcntl64)
+#if defined __NR_fcntl64 && __WORDSIZE == 32
+# include <stdarg.h>
+# include <cancel.h>
+# include <fcntl.h>
-#define __NR___syscall_fcntl64 __NR_fcntl64
-static __inline__ _syscall3(int, __syscall_fcntl64, int, fd, int, cmd, long, arg);
-int __libc_fcntl64(int fd, int cmd, ...)
+# define __NR___fcntl64_nocancel __NR_fcntl64
+_syscall3(int, __NC(fcntl64), int, fd, int, cmd, long, arg)
+
+int fcntl64(int fd, int cmd, ...)
{
long arg;
va_list list;
@@ -26,11 +28,15 @@ int __libc_fcntl64(int fd, int cmd, ...)
arg = va_arg(list, long);
va_end(list);
- return (__syscall_fcntl64(fd, cmd, arg));
+ if (SINGLE_THREAD_P || (cmd != F_SETLKW64))
+ return __NC(fcntl64)(fd, cmd, arg);
+# ifdef __NEW_THREADS
+ int oldtype = LIBC_CANCEL_ASYNC();
+ int result = __NC(fcntl64)(fd, cmd, arg);
+ LIBC_CANCEL_RESET(oldtype);
+ return result;
+# endif
}
-libc_hidden_def(__libc_fcntl64)
-
-libc_hidden_proto(fcntl64)
-strong_alias(__libc_fcntl64,fcntl64)
-libc_hidden_weak(fcntl64)
+lt_strong_alias(fcntl64)
+lt_libc_hidden(fcntl64)
#endif
diff --git a/libc/sysdeps/linux/common/__syscall_rt_sigaction.c b/libc/sysdeps/linux/common/__syscall_rt_sigaction.c
index b11499a56..723bf2e12 100644
--- a/libc/sysdeps/linux/common/__syscall_rt_sigaction.c
+++ b/libc/sysdeps/linux/common/__syscall_rt_sigaction.c
@@ -12,9 +12,8 @@
#ifdef __NR_rt_sigaction
#include <signal.h>
-int __syscall_rt_sigaction (int __signum, const struct sigaction *__act, struct sigaction *__oldact, size_t __size) attribute_hidden;
#define __NR___syscall_rt_sigaction __NR_rt_sigaction
_syscall4(int, __syscall_rt_sigaction, int, signum,
- const struct sigaction *, act, struct sigaction *, oldact,
- size_t, size);
+ const struct sigaction *, act, struct sigaction *, oldact,
+ size_t, size)
#endif
diff --git a/libc/sysdeps/linux/common/__syscall_sigaction.c b/libc/sysdeps/linux/common/__syscall_sigaction.c
index c39b49d00..98e6637ea 100644
--- a/libc/sysdeps/linux/common/__syscall_sigaction.c
+++ b/libc/sysdeps/linux/common/__syscall_sigaction.c
@@ -12,8 +12,7 @@
#ifndef __NR_rt_sigaction
#define __NR___syscall_sigaction __NR_sigaction
#include <signal.h>
-int __syscall_sigaction (int __signum, const struct sigaction *__act, struct sigaction *__oldact) attribute_hidden;
_syscall3(int, __syscall_sigaction, int, signum, const struct sigaction *,
- act, struct sigaction *, oldact);
+ act, struct sigaction *, oldact)
#endif
diff --git a/libc/sysdeps/linux/common/_exit.c b/libc/sysdeps/linux/common/_exit.c
index 945a254b5..c9e73c546 100644
--- a/libc/sysdeps/linux/common/_exit.c
+++ b/libc/sysdeps/linux/common/_exit.c
@@ -7,24 +7,36 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#include <features.h>
-#include <errno.h>
#include <unistd.h>
-#include <sys/types.h>
+#include <stdlib.h>
#include <sys/syscall.h>
+#include <bits/kernel-features.h>
-libc_hidden_proto(_exit)
+#ifdef __UCLIBC_ABORT_INSTRUCTION__
+# define ABORT_INSTRUCTION __asm__(__UCLIBC_ABORT_INSTRUCTION__)
+#else
+# warning "no abort instruction defined for this arch"
+#endif
-#ifndef INLINE_SYSCALL
-#define INLINE_SYSCALL(name, nr, args...) __syscall_exit (args)
-#define __NR___syscall_exit __NR_exit
-static __inline__ _syscall1(void, __syscall_exit, int, status);
+/* have to check for kernel 2.5.35 too, since NR was earlier present */
+#if defined __NR_exit_group && __LINUX_KERNEL_VERSION >= 0x020600 \
+ && defined __UCLIBC_HAS_THREADS__
+# undef __NR_exit
+# define __NR_exit __NR_exit_group
#endif
-void attribute_noreturn _exit(int status)
+void _exit(int status)
{
/* The loop is added only to keep gcc happy. */
while(1)
+ {
INLINE_SYSCALL(exit, 1, status);
+#ifdef ABORT_INSTRUCTION
+ ABORT_INSTRUCTION;
+#endif
+ }
}
libc_hidden_def(_exit)
+#ifdef __USE_ISOC99
+weak_alias(_exit,_Exit)
+#endif
diff --git a/libc/sysdeps/linux/common/access.c b/libc/sysdeps/linux/common/access.c
index 85533bde6..139b7b76b 100644
--- a/libc/sysdeps/linux/common/access.c
+++ b/libc/sysdeps/linux/common/access.c
@@ -9,4 +9,14 @@
#include <sys/syscall.h>
#include <unistd.h>
-_syscall2(int, access, const char *, pathname, int, mode);
+
+#if defined __NR_faccessat && !defined __NR_access
+# include <fcntl.h>
+int access(const char *pathname, int mode)
+{
+ return faccessat(AT_FDCWD, pathname, mode, 0);
+}
+
+#else
+_syscall2(int, access, const char *, pathname, int, mode)
+#endif
diff --git a/libc/sysdeps/linux/common/acct.c b/libc/sysdeps/linux/common/acct.c
index 74156d4de..e0a43200c 100644
--- a/libc/sysdeps/linux/common/acct.c
+++ b/libc/sysdeps/linux/common/acct.c
@@ -10,5 +10,5 @@
#include <sys/syscall.h>
#include <unistd.h>
#if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_UNIX98)
-_syscall1(int, acct, const char *, filename);
+_syscall1(int, acct, const char *, filename)
#endif
diff --git a/libc/sysdeps/linux/common/adjtimex.c b/libc/sysdeps/linux/common/adjtimex.c
index 280f90e5a..199650245 100644
--- a/libc/sysdeps/linux/common/adjtimex.c
+++ b/libc/sysdeps/linux/common/adjtimex.c
@@ -10,10 +10,10 @@
#include <sys/syscall.h>
#include <sys/timex.h>
-libc_hidden_proto(adjtimex)
-_syscall1(int, adjtimex, struct timex *, buf);
+_syscall1(int, adjtimex, struct timex *, buf)
libc_hidden_def(adjtimex)
+weak_alias(adjtimex,__adjtimex)
#if defined __UCLIBC_NTP_LEGACY__
strong_alias(adjtimex,ntp_adjtime)
#endif
diff --git a/libc/sysdeps/linux/common/alarm.c b/libc/sysdeps/linux/common/alarm.c
index 8b499861c..a2dd77be4 100644
--- a/libc/sysdeps/linux/common/alarm.c
+++ b/libc/sysdeps/linux/common/alarm.c
@@ -10,15 +10,10 @@
#include <sys/syscall.h>
#include <unistd.h>
-libc_hidden_proto(alarm)
-
#ifdef __NR_alarm
-#define __NR___alarm __NR_alarm
-_syscall1(unsigned int, alarm, unsigned int, seconds);
+_syscall1(unsigned int, alarm, unsigned int, seconds)
#else
-#include <sys/time.h>
-
-libc_hidden_proto(setitimer)
+# include <sys/time.h>
unsigned int alarm(unsigned int seconds)
{
diff --git a/libc/sysdeps/linux/common/arch_prctl.c b/libc/sysdeps/linux/common/arch_prctl.c
index 6d9927a01..9fc59485c 100644
--- a/libc/sysdeps/linux/common/arch_prctl.c
+++ b/libc/sysdeps/linux/common/arch_prctl.c
@@ -10,6 +10,6 @@
#include <sys/syscall.h>
#ifdef __NR_arch_prctl
-extern int arch_prctl(int code, unsigned long addr);
-_syscall2(int, arch_prctl, int, code, unsigned long, addr);
+int arch_prctl(int code, unsigned long addr);
+_syscall2(int, arch_prctl, int, code, unsigned long, addr)
#endif
diff --git a/libc/sysdeps/linux/common/bdflush.c b/libc/sysdeps/linux/common/bdflush.c
index 6cf007759..c2a05ed88 100644
--- a/libc/sysdeps/linux/common/bdflush.c
+++ b/libc/sysdeps/linux/common/bdflush.c
@@ -11,11 +11,5 @@
#include <sys/kdaemon.h>
#ifdef __NR_bdflush
-_syscall2(int, bdflush, int, __func, long int, __data);
-#else
-int bdflush(int __func, long int __data)
-{
- __set_errno(ENOSYS);
- return -1;
-}
+_syscall2(int, bdflush, int, __func, long int, __data)
#endif
diff --git a/libc/sysdeps/linux/common/bits/atomic.h b/libc/sysdeps/linux/common/bits/atomic.h
index 6245130a9..fa35a2461 100644
--- a/libc/sysdeps/linux/common/bits/atomic.h
+++ b/libc/sysdeps/linux/common/bits/atomic.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _BITS_ATOMIC_H
#define _BITS_ATOMIC_H 1
diff --git a/libc/sysdeps/linux/common/bits/byteswap-common.h b/libc/sysdeps/linux/common/bits/byteswap-common.h
new file mode 100644
index 000000000..4941d4768
--- /dev/null
+++ b/libc/sysdeps/linux/common/bits/byteswap-common.h
@@ -0,0 +1,107 @@
+/* Macros to swap the order of bytes in integer values.
+ Copyright (C) 1997,1998,2000,2001,2002,2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#if !defined _BYTESWAP_H && !defined _NETINET_IN_H
+# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
+#endif
+
+#ifndef _BITS_BYTESWAP_H
+#define _BITS_BYTESWAP_H 1
+
+/* Swap bytes in 16 bit value. */
+#define __bswap_constant_16(x) \
+ ((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8))
+
+#ifndef __bswap_non_constant_16
+# define __bswap_non_constant_16(x) __bswap_constant_16(x)
+#endif
+#ifdef __GNUC__
+# define __bswap_16(x) \
+ (__extension__ \
+ ({ unsigned short int __bsv, __bsx = (x); \
+ if (__builtin_constant_p (__bsx)) \
+ __bsv = __bswap_constant_16 (__bsx); \
+ else \
+ __bsv = __bswap_non_constant_16 (__bsx); \
+ __bsv; }))
+#else
+static __inline unsigned short int
+__bswap_16 (unsigned short int __bsx)
+{
+ return __bswap_constant_16 (__bsx);
+}
+#endif
+
+/* Swap bytes in 32 bit value. */
+#define __bswap_constant_32(x) \
+ ((((x) & 0xff000000u) >> 24) | (((x) & 0x00ff0000u) >> 8) | \
+ (((x) & 0x0000ff00u) << 8) | (((x) & 0x000000ffu) << 24))
+
+#ifndef __bswap_non_constant_32
+# define __bswap_non_constant_32(x) __bswap_constant_32(x)
+#endif
+#ifdef __GNUC__
+# define __bswap_32(x) \
+ (__extension__ \
+ ({ unsigned int __bsv, __bsx = (x); \
+ if (__builtin_constant_p (__bsx)) \
+ __bsv = __bswap_constant_32 (__bsx); \
+ else \
+ __bsv = __bswap_non_constant_32 (__bsx); \
+ __bsv; }))
+#else
+static __inline unsigned int
+__bswap_32 (unsigned int __bsx)
+{
+ return __bswap_constant_32 (__bsx);
+}
+#endif
+
+#if defined __GNUC__ && __GNUC__ >= 2
+/* Swap bytes in 64 bit value. */
+# define __bswap_constant_64(x) \
+ ((((x) & 0xff00000000000000ull) >> 56) \
+ | (((x) & 0x00ff000000000000ull) >> 40) \
+ | (((x) & 0x0000ff0000000000ull) >> 24) \
+ | (((x) & 0x000000ff00000000ull) >> 8) \
+ | (((x) & 0x00000000ff000000ull) << 8) \
+ | (((x) & 0x0000000000ff0000ull) << 24) \
+ | (((x) & 0x000000000000ff00ull) << 40) \
+ | (((x) & 0x00000000000000ffull) << 56))
+
+# ifndef __bswap_non_constant_64
+# define __bswap_non_constant_64(x) \
+ (__extension__ \
+ ({ union { __extension__ unsigned long long int __ll; \
+ unsigned int __l[2]; } __w, __r; \
+ __w.__ll = (x); \
+ __r.__l[0] = __bswap_non_constant_32 (__w.__l[1]); \
+ __r.__l[1] = __bswap_non_constant_32 (__w.__l[0]); \
+ __r.__ll; }))
+# endif
+# define __bswap_64(x) \
+ (__extension__ \
+ ({ __extension__ unsigned long long int __ll; \
+ if (__builtin_constant_p (x)) \
+ __ll = __bswap_constant_64 (x); \
+ else \
+ __ll = __bswap_non_constant_64 (x); \
+ __ll; }))
+#endif
+
+#endif /* _BITS_BYTESWAP_H */
diff --git a/libc/sysdeps/linux/common/bits/byteswap.h b/libc/sysdeps/linux/common/bits/byteswap.h
index 949ed0bc9..3f02506b6 100644
--- a/libc/sysdeps/linux/common/bits/byteswap.h
+++ b/libc/sysdeps/linux/common/bits/byteswap.h
@@ -1,87 +1 @@
-/* Macros to swap the order of bytes in integer values.
- Copyright (C) 1997,1998,2000,2001,2002,2005 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- 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 _BYTESWAP_H && !defined _NETINET_IN_H
-# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
-#endif
-
-#ifndef _BITS_BYTESWAP_H
-#define _BITS_BYTESWAP_H 1
-
-/* Swap bytes in 16 bit value. */
-#define __bswap_constant_16(x) \
- ((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8))
-
-#ifdef __GNUC__
-# define __bswap_16(x) \
- (__extension__ \
- ({ unsigned short int __bsx = (x); __bswap_constant_16 (__bsx); }))
-#else
-static __inline unsigned short int
-__bswap_16 (unsigned short int __bsx)
-{
- return __bswap_constant_16 (__bsx);
-}
-#endif
-
-/* Swap bytes in 32 bit value. */
-#define __bswap_constant_32(x) \
- ((((x) & 0xff000000u) >> 24) | (((x) & 0x00ff0000u) >> 8) | \
- (((x) & 0x0000ff00u) << 8) | (((x) & 0x000000ffu) << 24))
-
-#ifdef __GNUC__
-# define __bswap_32(x) \
- (__extension__ \
- ({ register unsigned int __bsx = (x); __bswap_constant_32 (__bsx); }))
-#else
-static __inline unsigned int
-__bswap_32 (unsigned int __bsx)
-{
- return __bswap_constant_32 (__bsx);
-}
-#endif
-
-#if defined __GNUC__ && __GNUC__ >= 2
-/* Swap bytes in 64 bit value. */
-# define __bswap_constant_64(x) \
- ((((x) & 0xff00000000000000ull) >> 56) \
- | (((x) & 0x00ff000000000000ull) >> 40) \
- | (((x) & 0x0000ff0000000000ull) >> 24) \
- | (((x) & 0x000000ff00000000ull) >> 8) \
- | (((x) & 0x00000000ff000000ull) << 8) \
- | (((x) & 0x0000000000ff0000ull) << 24) \
- | (((x) & 0x000000000000ff00ull) << 40) \
- | (((x) & 0x00000000000000ffull) << 56))
-
-# define __bswap_64(x) \
- (__extension__ \
- ({ union { __extension__ unsigned long long int __ll; \
- unsigned int __l[2]; } __w, __r; \
- if (__builtin_constant_p (x)) \
- __r.__ll = __bswap_constant_64 (x); \
- else \
- { \
- __w.__ll = (x); \
- __r.__l[0] = __bswap_32 (__w.__l[1]); \
- __r.__l[1] = __bswap_32 (__w.__l[0]); \
- } \
- __r.__ll; }))
-#endif
-
-#endif /* _BITS_BYTESWAP_H */
+#include <bits/byteswap-common.h>
diff --git a/libc/sysdeps/linux/common/bits/cmathcalls.h b/libc/sysdeps/linux/common/bits/cmathcalls.h
index 35237b35d..b56064bcd 100644
--- a/libc/sysdeps/linux/common/bits/cmathcalls.h
+++ b/libc/sysdeps/linux/common/bits/cmathcalls.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* NOTE: Because of the special way this file is used by <complex.h>, this
file must NOT be protected from multiple inclusion as header files
@@ -52,81 +51,104 @@
/* Arc cosine of Z. */
__MATHCALL (cacos, (_Mdouble_complex_ __z));
+libm_hidden_proto(cacos)
/* Arc sine of Z. */
__MATHCALL (casin, (_Mdouble_complex_ __z));
+libm_hidden_proto(casin)
/* Arc tangent of Z. */
__MATHCALL (catan, (_Mdouble_complex_ __z));
+libm_hidden_proto(catan)
/* Cosine of Z. */
__MATHCALL (ccos, (_Mdouble_complex_ __z));
+libm_hidden_proto(ccos)
/* Sine of Z. */
__MATHCALL (csin, (_Mdouble_complex_ __z));
+libm_hidden_proto(csin)
/* Tangent of Z. */
__MATHCALL (ctan, (_Mdouble_complex_ __z));
+libm_hidden_proto(ctan)
/* Hyperbolic functions. */
/* Hyperbolic arc cosine of Z. */
__MATHCALL (cacosh, (_Mdouble_complex_ __z));
+libm_hidden_proto(cacosh)
/* Hyperbolic arc sine of Z. */
__MATHCALL (casinh, (_Mdouble_complex_ __z));
+libm_hidden_proto(casinh)
/* Hyperbolic arc tangent of Z. */
__MATHCALL (catanh, (_Mdouble_complex_ __z));
+libm_hidden_proto(catanh)
/* Hyperbolic cosine of Z. */
__MATHCALL (ccosh, (_Mdouble_complex_ __z));
+libm_hidden_proto(ccosh)
/* Hyperbolic sine of Z. */
__MATHCALL (csinh, (_Mdouble_complex_ __z));
+libm_hidden_proto(ccosh)
/* Hyperbolic tangent of Z. */
__MATHCALL (ctanh, (_Mdouble_complex_ __z));
+libm_hidden_proto(ctanh)
/* Exponential and logarithmic functions. */
/* Exponential function of Z. */
__MATHCALL (cexp, (_Mdouble_complex_ __z));
+libm_hidden_proto(cexp)
/* Natural logarithm of Z. */
__MATHCALL (clog, (_Mdouble_complex_ __z));
+libm_hidden_proto(clog)
#ifdef __USE_GNU
/* The base 10 logarithm is not defined by the standard but to implement
the standard C++ library it is handy. */
__MATHCALL (clog10, (_Mdouble_complex_ __z));
+libm_hidden_proto(clog10)
#endif
/* Power functions. */
/* Return X to the Y power. */
__MATHCALL (cpow, (_Mdouble_complex_ __x, _Mdouble_complex_ __y));
+libm_hidden_proto(cpow)
/* Return the square root of Z. */
__MATHCALL (csqrt, (_Mdouble_complex_ __z));
+libm_hidden_proto(csqrt)
/* Absolute value, conjugates, and projection. */
/* Absolute value of Z. */
__MATHDECL (_Mdouble_,cabs, (_Mdouble_complex_ __z));
+libm_hidden_proto(cabs)
/* Argument value of Z. */
__MATHDECL (_Mdouble_,carg, (_Mdouble_complex_ __z));
+libm_hidden_proto(carg)
/* Complex conjugate of Z. */
__MATHCALL (conj, (_Mdouble_complex_ __z));
+libm_hidden_proto(conj)
/* Projection of Z onto the Riemann sphere. */
__MATHCALL (cproj, (_Mdouble_complex_ __z));
+libm_hidden_proto(cproj)
/* Decomposing complex values. */
/* Imaginary part of Z. */
__MATHDECL (_Mdouble_,cimag, (_Mdouble_complex_ __z));
+libm_hidden_proto(cimag)
/* Real part of Z. */
__MATHDECL (_Mdouble_,creal, (_Mdouble_complex_ __z));
+libm_hidden_proto(creal)
/* Now some optimized versions. GCC has handy notations for these
diff --git a/libc/sysdeps/linux/common/bits/confname.h b/libc/sysdeps/linux/common/bits/confname.h
index ab7fdee9d..7cfd285a4 100644
--- a/libc/sysdeps/linux/common/bits/confname.h
+++ b/libc/sysdeps/linux/common/bits/confname.h
@@ -1,5 +1,5 @@
/* `sysconf', `pathconf', and `confstr' NAME values. Generic version.
- Copyright (C) 1993,1995-1998,2000,2001,2003,2004
+ Copyright (C) 1993,1995-1998,2000,2001,2003,2004,2007,2009
Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _UNISTD_H
# error "Never use <bits/confname.h> directly; include <unistd.h> instead."
@@ -498,13 +497,39 @@ enum
_SC_IPV6 = _SC_LEVEL1_ICACHE_SIZE + 50,
#define _SC_IPV6 _SC_IPV6
- _SC_RAW_SOCKETS
+ _SC_RAW_SOCKETS,
#define _SC_RAW_SOCKETS _SC_RAW_SOCKETS
+
+ _SC_V7_ILP32_OFF32,
+#define _SC_V7_ILP32_OFF32 _SC_V7_ILP32_OFF32
+ _SC_V7_ILP32_OFFBIG,
+#define _SC_V7_ILP32_OFFBIG _SC_V7_ILP32_OFFBIG
+ _SC_V7_LP64_OFF64,
+#define _SC_V7_LP64_OFF64 _SC_V7_LP64_OFF64
+ _SC_V7_LPBIG_OFFBIG,
+#define _SC_V7_LPBIG_OFFBIG _SC_V7_LPBIG_OFFBIG
+
+ _SC_SS_REPL_MAX,
+#define _SC_SS_REPL_MAX _SC_SS_REPL_MAX
+
+ _SC_TRACE_EVENT_NAME_MAX,
+#define _SC_TRACE_EVENT_NAME_MAX _SC_TRACE_EVENT_NAME_MAX
+ _SC_TRACE_NAME_MAX,
+#define _SC_TRACE_NAME_MAX _SC_TRACE_NAME_MAX
+ _SC_TRACE_SYS_MAX,
+#define _SC_TRACE_SYS_MAX _SC_TRACE_SYS_MAX
+ _SC_TRACE_USER_EVENT_MAX,
+#define _SC_TRACE_USER_EVENT_MAX _SC_TRACE_USER_EVENT_MAX
+
+ _SC_XOPEN_STREAMS,
+#define _SC_XOPEN_STREAMS _SC_XOPEN_STREAMS
+
+ _SC_THREAD_ROBUST_PRIO_INHERIT,
+#define _SC_THREAD_ROBUST_PRIO_INHERIT _SC_THREAD_ROBUST_PRIO_INHERIT
+ _SC_THREAD_ROBUST_PRIO_PROTECT
+#define _SC_THREAD_ROBUST_PRIO_PROTECT _SC_THREAD_ROBUST_PRIO_PROTECT
};
-#if (defined __USE_POSIX2 || defined __USE_UNIX98 \
- || defined __USE_FILE_OFFSET64 || defined __USE_LARGEFILE64 \
- || defined __USE_LARGEFILE)
/* Values for the NAME argument to `confstr'. */
enum
{
@@ -512,7 +537,21 @@ enum
#define _CS_PATH _CS_PATH
_CS_V6_WIDTH_RESTRICTED_ENVS,
-# define _CS_V6_WIDTH_RESTRICTED_ENVS _CS_V6_WIDTH_RESTRICTED_ENVS
+#define _CS_V6_WIDTH_RESTRICTED_ENVS _CS_V6_WIDTH_RESTRICTED_ENVS
+#define _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS _CS_V6_WIDTH_RESTRICTED_ENVS
+
+ _CS_GNU_LIBC_VERSION,
+#define _CS_GNU_LIBC_VERSION _CS_GNU_LIBC_VERSION
+ _CS_GNU_LIBPTHREAD_VERSION,
+#define _CS_GNU_LIBPTHREAD_VERSION _CS_GNU_LIBPTHREAD_VERSION
+
+ _CS_V5_WIDTH_RESTRICTED_ENVS,
+#define _CS_V5_WIDTH_RESTRICTED_ENVS _CS_V5_WIDTH_RESTRICTED_ENVS
+#define _CS_POSIX_V5_WIDTH_RESTRICTED_ENVS _CS_V5_WIDTH_RESTRICTED_ENVS
+
+ _CS_V7_WIDTH_RESTRICTED_ENVS,
+#define _CS_V7_WIDTH_RESTRICTED_ENVS _CS_V7_WIDTH_RESTRICTED_ENVS
+#define _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS _CS_V7_WIDTH_RESTRICTED_ENVS
# if (defined __USE_FILE_OFFSET64 || defined __USE_LARGEFILE64 \
|| defined __USE_LARGEFILE)
@@ -568,6 +607,7 @@ enum
_CS_XBS5_LPBIG_OFFBIG_LINTFLAGS,
#define _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS
# endif
+
# ifdef __USE_XOPEN2K
_CS_POSIX_V6_ILP32_OFF32_CFLAGS,
#define _CS_POSIX_V6_ILP32_OFF32_CFLAGS _CS_POSIX_V6_ILP32_OFF32_CFLAGS
@@ -599,8 +639,42 @@ enum
#define _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS
_CS_POSIX_V6_LPBIG_OFFBIG_LIBS,
#define _CS_POSIX_V6_LPBIG_OFFBIG_LIBS _CS_POSIX_V6_LPBIG_OFFBIG_LIBS
- _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS
+ _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS,
#define _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS
# endif
+
+# ifdef __USE_XOPEN2K8
+ _CS_POSIX_V7_ILP32_OFF32_CFLAGS,
+#define _CS_POSIX_V7_ILP32_OFF32_CFLAGS _CS_POSIX_V7_ILP32_OFF32_CFLAGS
+ _CS_POSIX_V7_ILP32_OFF32_LDFLAGS,
+#define _CS_POSIX_V7_ILP32_OFF32_LDFLAGS _CS_POSIX_V7_ILP32_OFF32_LDFLAGS
+ _CS_POSIX_V7_ILP32_OFF32_LIBS,
+#define _CS_POSIX_V7_ILP32_OFF32_LIBS _CS_POSIX_V7_ILP32_OFF32_LIBS
+ _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS,
+#define _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS
+ _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS,
+#define _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS
+ _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS,
+#define _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS
+ _CS_POSIX_V7_ILP32_OFFBIG_LIBS,
+#define _CS_POSIX_V7_ILP32_OFFBIG_LIBS _CS_POSIX_V7_ILP32_OFFBIG_LIBS
+ _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS,
+#define _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS
+ _CS_POSIX_V7_LP64_OFF64_CFLAGS,
+#define _CS_POSIX_V7_LP64_OFF64_CFLAGS _CS_POSIX_V7_LP64_OFF64_CFLAGS
+ _CS_POSIX_V7_LP64_OFF64_LDFLAGS,
+#define _CS_POSIX_V7_LP64_OFF64_LDFLAGS _CS_POSIX_V7_LP64_OFF64_LDFLAGS
+ _CS_POSIX_V7_LP64_OFF64_LIBS,
+#define _CS_POSIX_V7_LP64_OFF64_LIBS _CS_POSIX_V7_LP64_OFF64_LIBS
+ _CS_POSIX_V7_LP64_OFF64_LINTFLAGS,
+#define _CS_POSIX_V7_LP64_OFF64_LINTFLAGS _CS_POSIX_V7_LP64_OFF64_LINTFLAGS
+ _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS,
+#define _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS
+ _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS,
+#define _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS
+ _CS_POSIX_V7_LPBIG_OFFBIG_LIBS,
+#define _CS_POSIX_V7_LPBIG_OFFBIG_LIBS _CS_POSIX_V7_LPBIG_OFFBIG_LIBS
+ _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS
+#define _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS
+# endif
};
-#endif
diff --git a/libc/sysdeps/linux/common/bits/dirent.h b/libc/sysdeps/linux/common/bits/dirent.h
index 76794b08d..5728618f2 100644
--- a/libc/sysdeps/linux/common/bits/dirent.h
+++ b/libc/sysdeps/linux/common/bits/dirent.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _DIRENT_H
# error "Never use <bits/dirent.h> directly; include <dirent.h> instead."
diff --git a/libc/sysdeps/linux/common/bits/dlfcn.h b/libc/sysdeps/linux/common/bits/dlfcn.h
index 4bfbbff04..546748cc6 100644
--- a/libc/sysdeps/linux/common/bits/dlfcn.h
+++ b/libc/sysdeps/linux/common/bits/dlfcn.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _DLFCN_H
# error "Never use <bits/dlfcn.h> directly; include <dlfcn.h> instead."
@@ -24,9 +23,9 @@
/* The MODE argument to `dlopen' contains one of the following: */
#define RTLD_LAZY 0x00001 /* Lazy function call binding. */
#define RTLD_NOW 0x00002 /* Immediate function call binding. */
-#if 0 /* uClibc doesnt support these */
-#define RTLD_BINDING_MASK 0x3 /* Mask of binding time value. */
+#define RTLD_BINDING_MASK 0x3 /* Mask of binding time value. */
#define RTLD_NOLOAD 0x00004 /* Do not load the object. */
+#if 0 /* uClibc doesnt support these */
#define RTLD_DEEPBIND 0x00008 /* Use deep binding. */
#endif
diff --git a/libc/sysdeps/linux/common/bits/environments.h b/libc/sysdeps/linux/common/bits/environments.h
index 4617dc45f..eff32b3fe 100644
--- a/libc/sysdeps/linux/common/bits/environments.h
+++ b/libc/sysdeps/linux/common/bits/environments.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999, 2001, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2001, 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
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _UNISTD_H
# error "Never include this file directly. Use <unistd.h> instead"
@@ -27,30 +26,36 @@
`-1' means it is never supported. Undefined means it cannot be
statically decided.
- _POSIX_V6_ILP32_OFF32 32bit int, long, pointers, and off_t type
- _POSIX_V6_ILP32_OFFBIG 32bit int, long, and pointers and larger off_t type
+ _POSIX_V7_ILP32_OFF32 32bit int, long, pointers, and off_t type
+ _POSIX_V7_ILP32_OFFBIG 32bit int, long, and pointers and larger off_t type
- _POSIX_V6_LP64_OFF32 64bit long and pointers and 32bit off_t type
- _POSIX_V6_LPBIG_OFFBIG 64bit long and pointers and large off_t type
+ _POSIX_V7_LP64_OFF32 64bit long and pointers and 32bit off_t type
+ _POSIX_V7_LPBIG_OFFBIG 64bit long and pointers and large off_t type
- The macros _XBS5_ILP32_OFF32, _XBS5_ILP32_OFFBIG, _XBS5_LP64_OFF32, and
- _XBS5_LPBIG_OFFBIG were used in previous versions of the Unix standard
- and are available only for compatibility.
+ The macros _POSIX_V6_ILP32_OFF32, _POSIX_V6_ILP32_OFFBIG,
+ _POSIX_V6_LP64_OFF32, _POSIX_V6_LPBIG_OFFBIG, _XBS5_ILP32_OFF32,
+ _XBS5_ILP32_OFFBIG, _XBS5_LP64_OFF32, and _XBS5_LPBIG_OFFBIG were
+ used in previous versions of the Unix standard and are available
+ only for compatibility.
*/
#if __WORDSIZE == 64
/* We can never provide environments with 32-bit wide pointers. */
+# define _POSIX_V7_ILP32_OFF32 -1
+# define _POSIX_V7_ILP32_OFFBIG -1
# define _POSIX_V6_ILP32_OFF32 -1
# define _POSIX_V6_ILP32_OFFBIG -1
# define _XBS5_ILP32_OFF32 -1
# define _XBS5_ILP32_OFFBIG -1
/* We also have no use (for now) for an environment with bigger pointers
and offsets. */
+# define _POSIX_V7_LPBIG_OFFBIG -1
# define _POSIX_V6_LPBIG_OFFBIG -1
# define _XBS5_LPBIG_OFFBIG -1
/* By default we have 64-bit wide `long int', pointers and `off_t'. */
+# define _POSIX_V7_LP64_OFF64 1
# define _POSIX_V6_LP64_OFF64 1
# define _XBS5_LP64_OFF64 1
@@ -58,15 +63,19 @@
/* By default we have 32-bit wide `int', `long int', pointers and `off_t'
and all platforms support LFS. */
+# define _POSIX_V7_ILP32_OFF32 1
+# define _POSIX_V7_ILP32_OFFBIG 1
# define _POSIX_V6_ILP32_OFF32 1
# define _POSIX_V6_ILP32_OFFBIG 1
# define _XBS5_ILP32_OFF32 1
# define _XBS5_ILP32_OFFBIG 1
/* We optionally provide an environment with the above size but an 64-bit
- side `off_t'. Therefore we don't define _XBS5_ILP32_OFFBIG. */
+ side `off_t'. Therefore we don't define _POSIX_V7_ILP32_OFFBIG. */
/* We can never provide environments with 64-bit wide pointers. */
+# define _POSIX_V7_LP64_OFF64 -1
+# define _POSIX_V7_LPBIG_OFFBIG -1
# define _POSIX_V6_LP64_OFF64 -1
# define _POSIX_V6_LPBIG_OFFBIG -1
# define _XBS5_LP64_OFF64 -1
diff --git a/libc/sysdeps/linux/common/bits/epoll.h b/libc/sysdeps/linux/common/bits/epoll.h
new file mode 100644
index 000000000..0a49b979f
--- /dev/null
+++ b/libc/sysdeps/linux/common/bits/epoll.h
@@ -0,0 +1,29 @@
+/* Copyright (C) 2002-2012 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_EPOLL_H
+# error "Never use <bits/epoll.h> directly; include <sys/epoll.h> instead."
+#endif
+
+/* Flags to be passed to epoll_create1. */
+enum
+ {
+ EPOLL_CLOEXEC = 02000000,
+#define EPOLL_CLOEXEC EPOLL_CLOEXEC
+ EPOLL_NONBLOCK = 00004000
+#define EPOLL_NONBLOCK EPOLL_NONBLOCK
+ };
diff --git a/libc/sysdeps/linux/common/bits/errno.h b/libc/sysdeps/linux/common/bits/errno.h
index a5ac1a47f..7c0aeb179 100644
--- a/libc/sysdeps/linux/common/bits/errno.h
+++ b/libc/sysdeps/linux/common/bits/errno.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifdef _ERRNO_H
@@ -25,7 +24,9 @@
# include <linux/errno.h>
/* Linux has no ENOTSUP error code. */
-# define ENOTSUP EOPNOTSUPP
+# ifndef ENOTSUP
+# define ENOTSUP EOPNOTSUPP
+# endif
/* Older Linux versions also had no ECANCELED error code. */
# ifndef ECANCELED
diff --git a/libc/sysdeps/linux/common/bits/eventfd.h b/libc/sysdeps/linux/common/bits/eventfd.h
new file mode 100644
index 000000000..ef49c617e
--- /dev/null
+++ b/libc/sysdeps/linux/common/bits/eventfd.h
@@ -0,0 +1,31 @@
+/* Copyright (C) 2007-2013 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_EVENTFD_H
+# error "Never use <bits/eventfd.h> directly; include <sys/eventfd.h> instead."
+#endif
+
+/* Flags for eventfd. */
+enum
+ {
+ EFD_SEMAPHORE = 00000001,
+#define EFD_SEMAPHORE EFD_SEMAPHORE
+ EFD_CLOEXEC = 02000000,
+#define EFD_CLOEXEC EFD_CLOEXEC
+ EFD_NONBLOCK = 00004000
+#define EFD_NONBLOCK EFD_NONBLOCK
+ };
diff --git a/libc/sysdeps/linux/common/bits/fenv.h b/libc/sysdeps/linux/common/bits/fenv.h
index a9cb53b40..0248ae110 100644
--- a/libc/sysdeps/linux/common/bits/fenv.h
+++ b/libc/sysdeps/linux/common/bits/fenv.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FENV_H
# error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
@@ -53,4 +52,4 @@ typedef struct
fenv_t;
/* If the default argument is used we use this value. */
-#define FE_DFL_ENV ((__const fenv_t *) -1l)
+#define FE_DFL_ENV ((const fenv_t *) -1l)
diff --git a/libc/sysdeps/linux/common/bits/getopt.h b/libc/sysdeps/linux/common/bits/getopt.h
index a28d0a40b..dababe07d 100644
--- a/libc/sysdeps/linux/common/bits/getopt.h
+++ b/libc/sysdeps/linux/common/bits/getopt.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _GETOPT_H
@@ -26,31 +25,7 @@
# define _GETOPT_H 1
#endif
-/* If __GNU_LIBRARY__ is not already defined, either we are being used
- standalone, or this is the first header included in the source file.
- If we are being used with glibc, we need to include <features.h>, but
- that does not exist if we are standalone. So: if __GNU_LIBRARY__ is
- not defined, include <ctype.h>, which will pull in <features.h> for us
- if it's from glibc. (Why ctype.h? It's guaranteed to exist and it
- doesn't flood the namespace with stuff the way some other headers do.) */
-#if !defined __GNU_LIBRARY__
-# include <ctype.h>
-#endif
-
-#ifndef __THROW
-# ifndef __GNUC_PREREQ
-# define __GNUC_PREREQ(maj, min) (0)
-# endif
-# if defined __cplusplus && __GNUC_PREREQ (2,8)
-# define __THROW throw ()
-# else
-# define __THROW
-# endif
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
+__BEGIN_DECLS
/* For communication from `getopt' to the caller.
When `getopt' finds an option that takes an argument,
@@ -92,7 +67,7 @@ extern int optopt;
The field `has_arg' is:
no_argument (or 0) if the option does not take an argument,
required_argument (or 1) if the option requires an argument,
- optional_argument (or 2) if the option takes an optional argument.
+ optional_argument (or 2) if the option takes an optional argument.
If the field `flag' is not NULL, it points to a variable that is set
to the value given in the field `val' when the option is found, but
@@ -147,17 +122,11 @@ struct option
arguments to the option '\0'. This behavior is specific to the GNU
`getopt'. */
-#if defined __GNU_LIBRARY__ || defined __UCLIBC__
-/* Many other libraries have conflicting prototypes for getopt, with
- differences in the consts, in stdlib.h. To avoid compilation
- errors, only prototype getopt for the GNU C library. */
extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
__THROW;
-#else /* not __GNU_LIBRARY__ */
-extern int getopt ();
-#endif /* __GNU_LIBRARY__ */
+libc_hidden_proto(getopt)
-#if defined __UCLIBC_HAS_GNU_GETOPT__ || defined __UCLIBC_HAS_GETOPT_LONG__
+#if defined __UCLIBC_HAS_GETOPT_LONG__
#ifndef __need_getopt
extern int getopt_long (int ___argc, char *const *___argv,
const char *__shortopts,
@@ -171,9 +140,7 @@ extern int getopt_long_only (int ___argc, char *const *___argv,
#endif
#endif
-#ifdef __cplusplus
-}
-#endif
+__END_DECLS
/* Make sure we later can get all the definitions and declarations. */
#undef __need_getopt
diff --git a/libc/sysdeps/linux/common/bits/getopt_int.h b/libc/sysdeps/linux/common/bits/getopt_int.h
new file mode 100644
index 000000000..291edfe24
--- /dev/null
+++ b/libc/sysdeps/linux/common/bits/getopt_int.h
@@ -0,0 +1,136 @@
+/* Internal declarations for getopt.
+ Copyright (C) 1989-1994,1996-1999,2001,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.
+
+ 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 _GETOPT_INT_H
+#define _GETOPT_INT_H 1
+
+extern int _getopt_internal (int ___argc, char *const *___argv,
+ const char *__shortopts,
+ const struct option *__longopts, int *__longind,
+ int __long_only) attribute_hidden;
+
+
+/* Reentrant versions which can handle parsing multiple argument
+ vectors at the same time. */
+
+/* For __ordering member */
+enum {
+ REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
+};
+
+/* Data type for reentrant functions. */
+
+struct _getopt_data
+{
+ /* These have exactly the same meaning as the corresponding global
+ variables, except that they are used for the reentrant
+ versions of getopt. */
+ int optind;
+ int opterr;
+ char *optarg;
+ smalluint optopt; /* we store characters here, a byte is enough */
+
+ /* Internal members. */
+
+ /* True if the internal members have been initialized. */
+ smallint __initialized;
+
+ /* Describe how to deal with options that follow non-option ARGV-elements.
+
+ If the caller did not specify anything,
+ the default is REQUIRE_ORDER if the environment variable
+ POSIXLY_CORRECT is defined, PERMUTE otherwise.
+
+ REQUIRE_ORDER means don't recognize them as options;
+ stop option processing when the first non-option is seen.
+ This is what Unix does.
+ This mode of operation is selected by either setting the environment
+ variable POSIXLY_CORRECT, or using `+' as the first character
+ of the list of option characters.
+
+ PERMUTE is the default. We permute the contents of ARGV as we
+ scan, so that eventually all the non-options are at the end.
+ This allows options to be given in any order, even with programs
+ that were not written to expect this.
+
+ RETURN_IN_ORDER is an option available to programs that were
+ written to expect options and other ARGV-elements in any order
+ and that care about the ordering of the two. We describe each
+ non-option ARGV-element as if it were the argument of an option
+ with character code 1. Using `-' as the first character of the
+ list of option characters selects this mode of operation.
+
+ The special argument `--' forces an end of option-scanning regardless
+ of the value of `ordering'. In the case of RETURN_IN_ORDER, only
+ `--' can cause `getopt' to return -1 with `optind' != ARGC. */
+ smallint __ordering;
+
+ /* If the POSIXLY_CORRECT environment variable is set. */
+ smallint __posixly_correct;
+
+ /* The next char to be scanned in the option-element
+ in which the last option character we returned was found.
+ This allows us to pick up the scan where we left off.
+
+ If this is zero, or a null string, it means resume the scan
+ by advancing to the next ARGV-element. */
+ char *__nextchar;
+
+
+ /* Handle permutation of arguments. */
+
+ /* Describe the part of ARGV that contains non-options that have
+ been skipped. `first_nonopt' is the index in ARGV of the first
+ of them; `last_nonopt' is the index after the last of them. */
+
+ int __first_nonopt;
+ int __last_nonopt;
+
+#if defined _LIBC && defined USE_NONOPTION_FLAGS
+ int __nonoption_flags_max_len;
+ int __nonoption_flags_len;
+# endif
+};
+
+/* The initializer is necessary to set OPTIND and OPTERR to their
+ default values and to clear the initialization flag. */
+#define _GETOPT_DATA_INITIALIZER { 1, 1 }
+
+#if 0 /* first is static on uClibc, the others not used */
+extern int _getopt_internal_r (int ___argc, char *const *___argv,
+ const char *__shortopts,
+ const struct option *__longopts, int *__longind,
+ int __long_only, struct _getopt_data *__data);
+#endif
+#if defined __UCLIBC_HAS_GNU_GETOPT__ || defined __UCLIBC_HAS_GETOPT_LONG__
+#ifndef __need_getopt
+extern int _getopt_long_r (int ___argc, char *const *___argv,
+ const char *__shortopts,
+ const struct option *__longopts, int *__longind,
+ struct _getopt_data *__data);
+
+extern int _getopt_long_only_r (int ___argc, char *const *___argv,
+ const char *__shortopts,
+ const struct option *__longopts,
+ int *__longind,
+ struct _getopt_data *__data);
+#endif
+#endif
+#endif /* getopt_int.h */
diff --git a/libc/sysdeps/linux/common/bits/huge_val.h b/libc/sysdeps/linux/common/bits/huge_val.h
index 11ca11f18..c4ff6e2d8 100644
--- a/libc/sysdeps/linux/common/bits/huge_val.h
+++ b/libc/sysdeps/linux/common/bits/huge_val.h
@@ -15,9 +15,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _MATH_H
# error "Never use <bits/huge_val.h> directly; include <math.h> instead."
diff --git a/libc/sysdeps/linux/common/bits/huge_valf.h b/libc/sysdeps/linux/common/bits/huge_valf.h
index 1785342cd..a553d110d 100644
--- a/libc/sysdeps/linux/common/bits/huge_valf.h
+++ b/libc/sysdeps/linux/common/bits/huge_valf.h
@@ -15,9 +15,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _MATH_H
# error "Never use <bits/huge_valf.h> directly; include <math.h> instead."
diff --git a/libc/sysdeps/linux/common/bits/huge_vall.h b/libc/sysdeps/linux/common/bits/huge_vall.h
index d5e8e2237..2953165ab 100644
--- a/libc/sysdeps/linux/common/bits/huge_vall.h
+++ b/libc/sysdeps/linux/common/bits/huge_vall.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _MATH_H
# error "Never use <bits/huge_vall.h> directly; include <math.h> instead."
diff --git a/libc/sysdeps/linux/common/bits/in.h b/libc/sysdeps/linux/common/bits/in.h
index 6880a2e63..c67fbf852 100644
--- a/libc/sysdeps/linux/common/bits/in.h
+++ b/libc/sysdeps/linux/common/bits/in.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-1999, 2000, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2013 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
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* Linux version. */
@@ -43,31 +42,49 @@
#define IP_ADD_SOURCE_MEMBERSHIP 39 /* ip_mreq_source: join source group */
#define IP_DROP_SOURCE_MEMBERSHIP 40 /* ip_mreq_source: leave source group */
#define IP_MSFILTER 41
-#define MCAST_JOIN_GROUP 42 /* group_req: join any-source group */
-#define MCAST_BLOCK_SOURCE 43 /* group_source_req: block from given group */
-#define MCAST_UNBLOCK_SOURCE 44 /* group_source_req: unblock from given group*/
-#define MCAST_LEAVE_GROUP 45 /* group_req: leave any-source group */
-#define MCAST_JOIN_SOURCE_GROUP 46 /* group_source_req: join source-spec gr */
-#define MCAST_LEAVE_SOURCE_GROUP 47 /* group_source_req: leave source-spec gr*/
-#define MCAST_MSFILTER 48
-
-#define MCAST_EXCLUDE 0
-#define MCAST_INCLUDE 1
-
-#define IP_ROUTER_ALERT 5 /* bool */
-#define IP_PKTINFO 8 /* bool */
-#define IP_PKTOPTIONS 9
-#define IP_PMTUDISC 10 /* obsolete name? */
-#define IP_MTU_DISCOVER 10 /* int; see below */
-#define IP_RECVERR 11 /* bool */
-#define IP_RECVTTL 12 /* bool */
-#define IP_RECVTOS 13 /* bool */
+#if defined __USE_MISC || defined __USE_GNU
+# define MCAST_JOIN_GROUP 42 /* group_req: join any-source group */
+# define MCAST_BLOCK_SOURCE 43 /* group_source_req: block from given group */
+# define MCAST_UNBLOCK_SOURCE 44 /* group_source_req: unblock from given group*/
+# define MCAST_LEAVE_GROUP 45 /* group_req: leave any-source group */
+# define MCAST_JOIN_SOURCE_GROUP 46 /* group_source_req: join source-spec gr */
+# define MCAST_LEAVE_SOURCE_GROUP 47 /* group_source_req: leave source-spec gr*/
+# define MCAST_MSFILTER 48
+# define IP_MULTICAST_ALL 49
+# define IP_UNICAST_IF 50
+
+# define MCAST_EXCLUDE 0
+# define MCAST_INCLUDE 1
+#endif
+
+#define IP_ROUTER_ALERT 5 /* bool */
+#define IP_PKTINFO 8 /* bool */
+#define IP_PKTOPTIONS 9
+#define IP_PMTUDISC 10 /* obsolete name? */
+#define IP_MTU_DISCOVER 10 /* int; see below */
+#define IP_RECVERR 11 /* bool */
+#define IP_RECVTTL 12 /* bool */
+#define IP_RECVTOS 13 /* bool */
+#define IP_MTU 14 /* int */
+#define IP_FREEBIND 15
+#define IP_IPSEC_POLICY 16
+#define IP_XFRM_POLICY 17
+#define IP_PASSSEC 18
+#define IP_TRANSPARENT 19
+#define IP_MULTICAST_ALL 49 /* bool */
+
+/* TProxy original addresses */
+#define IP_ORIGDSTADDR 20
+#define IP_RECVORIGDSTADDR IP_ORIGDSTADDR
+
+#define IP_MINTTL 21
/* IP_MTU_DISCOVER arguments. */
#define IP_PMTUDISC_DONT 0 /* Never send DF frames. */
#define IP_PMTUDISC_WANT 1 /* Use per route hints. */
#define IP_PMTUDISC_DO 2 /* Always DF. */
+#define IP_PMTUDISC_PROBE 3 /* Ignore dst pmtu. */
/* To select the IP level. */
#define SOL_IP 0
@@ -76,6 +93,7 @@
#define IP_DEFAULT_MULTICAST_LOOP 1
#define IP_MAX_MEMBERSHIPS 20
+#if defined __USE_MISC || defined __USE_GNU
/* Structure used to describe IP options for IP_OPTIONS and IP_RETOPTS.
The `ip_dst' field is used for the first-hop gateway when using a
source route (this gets put into the header proper). */
@@ -100,7 +118,9 @@ struct in_pktinfo
struct in_addr ipi_spec_dst; /* Routing destination address */
struct in_addr ipi_addr; /* Header destination address */
};
+#endif
+#if defined __UCLIBC_HAS_IPV6__ || !defined __UCLIBC_STRICT_HEADERS__
/* Options for use with `getsockopt' and `setsockopt' at the IPv6 level.
The first word in the comment at the right is the data type used;
"bool" means a boolean value stored in an `int'. */
@@ -158,6 +178,7 @@ struct in_pktinfo
#define IPV6_PMTUDISC_DONT 0 /* Never send DF frames. */
#define IPV6_PMTUDISC_WANT 1 /* Use per route hints. */
#define IPV6_PMTUDISC_DO 2 /* Always DF. */
+#define IPV6_PMTUDISC_PROBE 3 /* Ignore dst pmtu. */
/* Socket level values for IPv6. */
#define SOL_IPV6 41
@@ -168,3 +189,4 @@ struct in_pktinfo
#define IPV6_RTHDR_STRICT 1 /* Hop must be a neighbour. */
#define IPV6_RTHDR_TYPE_0 0 /* IPv6 Routing header type 0. */
+#endif /* __UCLIBC_HAS_IPV6__ */
diff --git a/libc/sysdeps/linux/common/bits/inf.h b/libc/sysdeps/linux/common/bits/inf.h
index 1619f756e..5d0412849 100644
--- a/libc/sysdeps/linux/common/bits/inf.h
+++ b/libc/sysdeps/linux/common/bits/inf.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _MATH_H
# error "Never use <bits/inf.h> directly; include <math.h> instead."
diff --git a/libc/sysdeps/linux/common/bits/initspin.h b/libc/sysdeps/linux/common/bits/initspin.h
index a19ec077e..b9e4acf30 100644
--- a/libc/sysdeps/linux/common/bits/initspin.h
+++ b/libc/sysdeps/linux/common/bits/initspin.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
/* Initial value of a spinlock. Most platforms should use zero,
unless they only implement a "test and clear" operation instead of
diff --git a/libc/sysdeps/linux/common/bits/inotify.h b/libc/sysdeps/linux/common/bits/inotify.h
new file mode 100644
index 000000000..291f00862
--- /dev/null
+++ b/libc/sysdeps/linux/common/bits/inotify.h
@@ -0,0 +1,29 @@
+/* Copyright (C) 2005-2012 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_INOTIFY_H
+# error "Never use <bits/inotify.h> directly; include <sys/inotify.h> instead."
+#endif
+
+/* Flags for the parameter of inotify_init1. */
+enum
+ {
+ IN_CLOEXEC = 02000000,
+#define IN_CLOEXEC IN_CLOEXEC
+ IN_NONBLOCK = 00004000
+#define IN_NONBLOCK IN_NONBLOCK
+ };
diff --git a/libc/sysdeps/linux/common/bits/ioctl-types.h b/libc/sysdeps/linux/common/bits/ioctl-types.h
index e856a04b4..45a106349 100644
--- a/libc/sysdeps/linux/common/bits/ioctl-types.h
+++ b/libc/sysdeps/linux/common/bits/ioctl-types.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_IOCTL_H
# error "Never use <bits/ioctl-types.h> directly; include <sys/ioctl.h> instead."
diff --git a/libc/sysdeps/linux/common/bits/ioctls.h b/libc/sysdeps/linux/common/bits/ioctls.h
index 11bb4c485..3664071cf 100644
--- a/libc/sysdeps/linux/common/bits/ioctls.h
+++ b/libc/sysdeps/linux/common/bits/ioctls.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_IOCTL_H
# error "Never use <bits/ioctls.h> directly; include <sys/ioctl.h> instead."
@@ -49,7 +48,7 @@
#define SIOCGIFMTU 0x8921 /* get MTU size */
#define SIOCSIFMTU 0x8922 /* set MTU size */
#define SIOCSIFNAME 0x8923 /* set interface name */
-#define SIOCSIFHWADDR 0x8924 /* set hardware address */
+#define SIOCSIFHWADDR 0x8924 /* set hardware address */
#define SIOCGIFENCAP 0x8925 /* get/set encapsulations */
#define SIOCSIFENCAP 0x8926
#define SIOCGIFHWADDR 0x8927 /* Get hardware address */
@@ -66,10 +65,10 @@
#define SIOCGIFCOUNT 0x8938 /* get number of devices */
#define SIOCGIFBR 0x8940 /* Bridging support */
-#define SIOCSIFBR 0x8941 /* Set bridging options */
+#define SIOCSIFBR 0x8941 /* Set bridging options */
#define SIOCGIFTXQLEN 0x8942 /* Get the tx queue length */
-#define SIOCSIFTXQLEN 0x8943 /* Set the tx queue length */
+#define SIOCSIFTXQLEN 0x8943 /* Set the tx queue length */
/* ARP cache control calls. */
@@ -100,7 +99,7 @@
names as their own. Because these are device dependent it is a good
idea _NOT_ to issue them to random objects and hope. */
-#define SIOCDEVPRIVATE 0x89F0 /* to 89FF */
+#define SIOCDEVPRIVATE 0x89F0 /* to 89FF */
/*
* These 16 ioctl calls are protocol private
diff --git a/libc/sysdeps/linux/common/bits/ipc.h b/libc/sysdeps/linux/common/bits/ipc.h
index f1a043fe5..3bd5f1b6f 100644
--- a/libc/sysdeps/linux/common/bits/ipc.h
+++ b/libc/sysdeps/linux/common/bits/ipc.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_IPC_H
# error "Never use <bits/ipc.h> directly; include <sys/ipc.h> instead."
diff --git a/libc/sysdeps/linux/common/bits/kernel-features.h b/libc/sysdeps/linux/common/bits/kernel-features.h
new file mode 100644
index 000000000..708bb4906
--- /dev/null
+++ b/libc/sysdeps/linux/common/bits/kernel-features.h
@@ -0,0 +1,514 @@
+/* Set flags signalling availability of kernel features based on given
+ kernel version number.
+ Copyright (C) 1999-2003, 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+/* This file must not contain any C code. At least it must be protected
+ to allow using the file also in assembler files. */
+
+#if defined __mips__
+# include <sgidefs.h>
+#endif
+
+#include <linux/version.h>
+#define __LINUX_KERNEL_VERSION LINUX_VERSION_CODE
+
+/* We assume for __LINUX_KERNEL_VERSION the same encoding used in
+ linux/version.h. I.e., the major, minor, and subminor all get a
+ byte with the major number being in the highest byte. This means
+ we can do numeric comparisons.
+
+ In the following we will define certain symbols depending on
+ whether the describes kernel feature is available in the kernel
+ version given by __LINUX_KERNEL_VERSION. We are not always exactly
+ recording the correct versions in which the features were
+ introduced. If somebody cares these values can afterwards be
+ corrected. Most of the numbers here are set corresponding to
+ 2.2.0. */
+
+/* `getcwd' system call. */
+#if __LINUX_KERNEL_VERSION >= 131584
+# define __ASSUME_GETCWD_SYSCALL 1
+#endif
+
+/* When was `poll' introduced? */
+#if __LINUX_KERNEL_VERSION >= 131584
+# define __ASSUME_POLL_SYSCALL 1
+#endif
+
+/* Real-time signal became usable in 2.1.70. */
+#if __LINUX_KERNEL_VERSION >= 131398
+# define __ASSUME_REALTIME_SIGNALS 1
+#endif
+
+/* When were the `pread'/`pwrite' syscalls introduced? */
+#if __LINUX_KERNEL_VERSION >= 131584
+# define __ASSUME_PREAD_SYSCALL 1
+# define __ASSUME_PWRITE_SYSCALL 1
+#endif
+
+/* When was `poll' introduced? */
+#if __LINUX_KERNEL_VERSION >= 131584
+# define __ASSUME_POLL_SYSCALL 1
+#endif
+
+/* The `lchown' syscall was introduced in 2.1.80. */
+#if __LINUX_KERNEL_VERSION >= 131408
+# define __ASSUME_LCHOWN_SYSCALL 1
+#endif
+
+/* When did the `setresuid' sysall became available? */
+#if __LINUX_KERNEL_VERSION >= 131584 && !defined __sparc__
+# define __ASSUME_SETRESUID_SYSCALL 1
+#endif
+
+/* The SIOCGIFNAME ioctl is available starting with 2.1.50. */
+#if __LINUX_KERNEL_VERSION >= 131408
+# define __ASSUME_SIOCGIFNAME 1
+#endif
+
+/* MSG_NOSIGNAL was at least available with Linux 2.2.0. */
+#if __LINUX_KERNEL_VERSION >= 131584
+# define __ASSUME_MSG_NOSIGNAL 1
+#endif
+
+/* On x86 another `getrlimit' syscall was added in 2.3.25. */
+#if __LINUX_KERNEL_VERSION >= 131865 && defined __i386__
+# define __ASSUME_NEW_GETRLIMIT_SYSCALL 1
+#endif
+
+/* On x86 the truncate64/ftruncate64 syscalls were introduced in 2.3.31. */
+#if __LINUX_KERNEL_VERSION >= 131871 && defined __i386__
+# define __ASSUME_TRUNCATE64_SYSCALL 1
+#endif
+
+/* On x86 the mmap2 syscall was introduced in 2.3.31. */
+#if __LINUX_KERNEL_VERSION >= 131871 && defined __i386__
+# define __ASSUME_MMAP2_SYSCALL 1
+#endif
+
+/* On x86 the stat64/lstat64/fstat64 syscalls were introduced in 2.3.34. */
+#if __LINUX_KERNEL_VERSION >= 131874 && defined __i386__
+# define __ASSUME_STAT64_SYSCALL 1
+#endif
+
+/* On sparc and ARM the truncate64/ftruncate64/mmap2/stat64/lstat64/fstat64
+ syscalls were introduced in 2.3.35. */
+#if __LINUX_KERNEL_VERSION >= 131875 && (defined __sparc__ || defined __arm__)
+# define __ASSUME_TRUNCATE64_SYSCALL 1
+# define __ASSUME_MMAP2_SYSCALL 1
+# define __ASSUME_STAT64_SYSCALL 1
+#endif
+
+/* I know for sure that getrlimit are in 2.3.35 on powerpc. */
+#if __LINUX_KERNEL_VERSION >= 131875 && defined __powerpc__
+# define __ASSUME_NEW_GETRLIMIT_SYSCALL 1
+#endif
+
+/* I know for sure that these are in 2.3.35 on powerpc. But PowerPC64 does not
+ support separate 64-bit syscalls, already 64-bit */
+#if __LINUX_KERNEL_VERSION >= 131875 && defined __powerpc__ \
+ && !defined __powerpc64__
+# define __ASSUME_TRUNCATE64_SYSCALL 1
+# define __ASSUME_STAT64_SYSCALL 1
+#endif
+
+/* Linux 2.3.39 introduced 32bit UID/GIDs. Some platforms had 32
+ bit type all along. */
+#if __LINUX_KERNEL_VERSION >= 131879 || defined __powerpc__ || defined __mips__
+# define __ASSUME_32BITUIDS 1
+#endif
+
+/* Linux 2.3.39 sparc added setresuid. */
+#if __LINUX_KERNEL_VERSION >= 131879 && defined __sparc__
+# define __ASSUME_SETRESUID_SYSCALL 1
+#endif
+
+#if __LINUX_KERNEL_VERSION >= 131879
+# define __ASSUME_SETRESGID_SYSCALL 1
+#endif
+
+/* Linux 2.3.39 introduced IPC64. Except for powerpc. */
+#if __LINUX_KERNEL_VERSION >= 131879 && !defined __powerpc__
+# define __ASSUME_IPC64 1
+#endif
+
+/* MIPS platforms had IPC64 all along. */
+#if defined __mips__
+# define __ASSUME_IPC64 1
+#endif
+
+/* We can use the LDTs for threading with Linux 2.3.99 and newer. */
+#if __LINUX_KERNEL_VERSION >= 131939
+# define __ASSUME_LDT_WORKS 1
+#endif
+
+/* Linux 2.4.0 on PPC introduced a correct IPC64. But PowerPC64 does not
+ support a separate 64-bit sys call, already 64-bit */
+#if __LINUX_KERNEL_VERSION >= 132096 && defined __powerpc__ \
+ && !defined __powerpc64__
+# define __ASSUME_IPC64 1
+#endif
+
+/* SH kernels got stat64, mmap2, and truncate64 during 2.4.0-test. */
+#if __LINUX_KERNEL_VERSION >= 132096 && defined __sh__
+# define __ASSUME_TRUNCATE64_SYSCALL 1
+# define __ASSUME_MMAP2_SYSCALL 1
+# define __ASSUME_STAT64_SYSCALL 1
+#endif
+
+/* The changed st_ino field appeared in 2.4.0-test6. But we cannot
+ distinguish this version from other 2.4.0 releases. Therefore play
+ save and assume it available is for 2.4.1 and up. However, SH is lame,
+ and still does not have a 64-bit inode field. */
+#if __LINUX_KERNEL_VERSION >= 132097 && !defined __alpha__ && !defined __sh__
+# define __ASSUME_ST_INO_64_BIT 1
+#endif
+
+/* To support locking of large files a new fcntl() syscall was introduced
+ in 2.4.0-test7. We test for 2.4.1 for the earliest version we know
+ the syscall is available. */
+#if __LINUX_KERNEL_VERSION >= 132097 && (defined __i386__ || defined __sparc__)
+# define __ASSUME_FCNTL64 1
+#endif
+
+/* The AT_CLKTCK auxiliary vector entry was introduction in the 2.4.0
+ series. */
+#if __LINUX_KERNEL_VERSION >= 132097
+# define __ASSUME_AT_CLKTCK 1
+#endif
+
+/* Arm got fcntl64 in 2.4.4, PowerPC and SH have it also in 2.4.4 (I
+ don't know when it got introduced). But PowerPC64 does not support
+ separate FCNTL64 call, FCNTL is already 64-bit */
+#if __LINUX_KERNEL_VERSION >= 132100 \
+ && (defined __arm__ || defined __powerpc__ || defined __sh__) \
+ && !defined __powerpc64__
+# define __ASSUME_FCNTL64 1
+#endif
+
+/* The getdents64 syscall was introduced in 2.4.0-test7. We test for
+ 2.4.1 for the earliest version we know the syscall is available. */
+#if __LINUX_KERNEL_VERSION >= 132097
+# define __ASSUME_GETDENTS64_SYSCALL 1
+#endif
+
+/* When did O_DIRECTORY became available? Early in 2.3 but when?
+ Be safe, use 2.3.99. */
+#if __LINUX_KERNEL_VERSION >= 131939
+# define __ASSUME_O_DIRECTORY 1
+#endif
+
+/* Starting with one of the 2.4.0 pre-releases the Linux kernel passes
+ up the page size information. */
+#if __LINUX_KERNEL_VERSION >= 132097
+# define __ASSUME_AT_PAGESIZE 1
+#endif
+
+/* Starting with at least 2.4.0 the kernel passes the uid/gid unconditionally
+ up to the child. */
+#if __LINUX_KERNEL_VERSION >= 132097
+# define __ASSUME_AT_XID 1
+#endif
+
+/* Starting with 2.4.5 kernels PPC passes the AUXV in the standard way
+ and the vfork syscall made it into the official kernel. */
+#if __LINUX_KERNEL_VERSION >= (132096+5) && defined __powerpc__
+# define __ASSUME_STD_AUXV 1
+# define __ASSUME_VFORK_SYSCALL 1
+#endif
+
+/* Starting with 2.4.5 kernels the mmap2 syscall made it into the official
+ kernel. But PowerPC64 does not support a separate MMAP2 call. */
+#if __LINUX_KERNEL_VERSION >= (132096+5) && defined __powerpc__ \
+ && !defined __powerpc64__
+# define __ASSUME_MMAP2_SYSCALL 1
+#endif
+
+/* Starting with 2.4.21 PowerPC implements the new prctl syscall.
+ This allows applications to get/set the Floating Point Exception Mode. */
+#if __LINUX_KERNEL_VERSION >= (132096+21) && defined __powerpc__
+# define __ASSUME_NEW_PRCTL_SYSCALL 1
+#endif
+
+/* Starting with 2.4.21 the PowerPC32 clone syscall works as expected. */
+#if __LINUX_KERNEL_VERSION >= (132096+21) && defined __powerpc__ \
+ && !defined __powerpc64__
+# define __ASSUME_FIXED_CLONE_SYSCALL 1
+#endif
+
+/* Starting with 2.4.21 PowerPC64 implements the new rt_sigreturn syscall.
+ The new rt_sigreturn takes an ucontext pointer allowing rt_sigreturn
+ to be used in the set/swapcontext implementation. */
+#if __LINUX_KERNEL_VERSION >= (132096+21) && defined __powerpc64__
+# define __ASSUME_NEW_RT_SIGRETURN_SYSCALL 1
+#endif
+
+/* On x86, the set_thread_area syscall was introduced in 2.5.29, but its
+ semantics was changed in 2.5.30, and again after 2.5.31. */
+#if __LINUX_KERNEL_VERSION >= 132384 && defined __i386__
+# define __ASSUME_SET_THREAD_AREA_SYSCALL 1
+#endif
+
+/* The vfork syscall on x86 and arm was definitely available in 2.4. */
+#if __LINUX_KERNEL_VERSION >= 132097 && (defined __i386__ || defined __arm__)
+# define __ASSUME_VFORK_SYSCALL 1
+#endif
+
+/* There are an infinite number of PA-RISC kernel versions numbered
+ 2.4.0. But they've not really been released as such. We require
+ and expect the final version here. */
+#ifdef __hppa__
+# define __ASSUME_32BITUIDS 1
+# define __ASSUME_TRUNCATE64_SYSCALL 1
+# define __ASSUME_MMAP2_SYSCALL 1
+# define __ASSUME_STAT64_SYSCALL 1
+# define __ASSUME_IPC64 1
+# define __ASSUME_ST_INO_64_BIT 1
+# define __ASSUME_FCNTL64 1
+# define __ASSUME_GETDENTS64_SYSCALL 1
+#endif
+
+/* Alpha switched to a 64-bit timeval sometime before 2.2.0. */
+#if __LINUX_KERNEL_VERSION >= 131584 && defined __alpha__
+# define __ASSUME_TIMEVAL64 1
+#endif
+
+#if defined __mips__ && _MIPS_SIM == _ABIN32
+# define __ASSUME_FCNTL64 1
+#endif
+
+/* The late 2.5 kernels saw a lot of new CLONE_* flags. Summarize
+ their availability with one define. The changes were made first
+ for i386 and the have to be done separately for the other archs.
+ For i386 we pick 2.5.50 as the first version with support. */
+#if __LINUX_KERNEL_VERSION >= 132402 && defined __i386__
+# define __ASSUME_CLONE_THREAD_FLAGS 1
+#endif
+
+/* Support for various CLOEXEC and NONBLOCK flags was added for x86,
+ x86-64, PPC, IA-64, SPARC< and S390 in 2.6.23. */
+#if __LINUX_KERNEL_VERSION >= 0x020617 \
+ && (defined __i386__ || defined __x86_64__ || defined __powerpc__ \
+ || defined __ia64__ || defined __sparc__ || defined __s390__)
+# define __ASSUME_O_CLOEXEC 1
+#endif
+
+/* Support for various CLOEXEC and NONBLOCK flags was added for x86,
+ * x86-64, PPC, IA-64, and SPARC in 2.6.27. */
+#if (__LINUX_KERNEL_VERSION >= 0x02061b \
+ && (defined __i386__ || defined __x86_64__ || defined __powerpc__ \
+ || defined __ia64__ || defined __sparc__ || defined __s390__) \
+ ) || (__LINUX_KERNEL_VERSION >= 0x020621 && defined __alpha__) \
+ || defined __aarch64__ || defined __tile__
+/* # define __ASSUME_SOCK_CLOEXEC 1 */
+/* # define __ASSUME_IN_NONBLOCK 1 */
+# define __ASSUME_PIPE2 1
+/* # define __ASSUME_EVENTFD2 1 */
+/* # define __ASSUME_SIGNALFD4 1 */
+/* # define __ASSUME_DUP3 1 */
+#endif
+
+/* These features were surely available with 2.4.12. */
+#if __LINUX_KERNEL_VERSION >= 132108 && defined __mc68000__
+# define __ASSUME_MMAP2_SYSCALL 1
+# define __ASSUME_TRUNCATE64_SYSCALL 1
+# define __ASSUME_STAT64_SYSCALL 1
+# define __ASSUME_FCNTL64 1
+# define __ASSUME_VFORK_SYSCALL 1
+#endif
+
+/* Beginning with 2.5.63 support for realtime and monotonic clocks and
+ timers based on them is available. */
+#if __LINUX_KERNEL_VERSION >= 132415
+# define __ASSUME_POSIX_TIMERS 1
+#endif
+
+/* Beginning with 2.6.12 the clock and timer supports CPU clocks. */
+#if __LINUX_KERNEL_VERSION >= 0x2060c
+# define __ASSUME_POSIX_CPU_TIMERS 1
+#endif
+
+/* The late 2.5 kernels saw a lot of new CLONE_* flags. Summarize
+ their availability with one define. The changes were made first
+ for i386 and the have to be done separately for the other archs.
+ For ia64, s390*, PPC, x86-64 we pick 2.5.64 as the first version
+ with support. */
+#if __LINUX_KERNEL_VERSION >= 132416 \
+ && (defined __ia64__ || defined __s390__ || defined __powerpc__ \
+ || defined __x86_64__ || defined __sh__)
+# define __ASSUME_CLONE_THREAD_FLAGS 1
+#endif
+
+/* With kernel 2.4.17 we always have netlink support. */
+#if __LINUX_KERNEL_VERSION >= (132096+17)
+# define __ASSUME_NETLINK_SUPPORT 1
+#endif
+
+/* The requeue futex functionality was introduced in 2.5.70. */
+#if __LINUX_KERNEL_VERSION >= 132422
+# define __ASSUME_FUTEX_REQUEUE 1
+#endif
+
+/* The statfs64 syscalls are available in 2.5.74. */
+#if __LINUX_KERNEL_VERSION >= 132426
+# define __ASSUME_STATFS64 1
+#endif
+
+/* Starting with at least 2.5.74 the kernel passes the setuid-like exec
+ flag unconditionally up to the child. */
+#if __LINUX_KERNEL_VERSION >= 132426
+# define __ASSUME_AT_SECURE 1
+#endif
+
+/* Starting with the 2.5.75 kernel the kernel fills in the correct value
+ in the si_pid field passed as part of the siginfo_t struct to signal
+ handlers. */
+#if __LINUX_KERNEL_VERSION >= 132427
+# define __ASSUME_CORRECT_SI_PID 1
+#endif
+
+/* The tgkill syscall was instroduced for i386 in 2.5.75. For Alpha
+ it was introduced in 2.6.0-test1 which unfortunately cannot be
+ distinguished from 2.6.0. On x86-64, ppc, and ppc64 it was
+ introduced in 2.6.0-test3. */
+#if (__LINUX_KERNEL_VERSION >= 132427 && defined __i386__) \
+ || (__LINUX_KERNEL_VERSION >= 132609 && defined __alpha__) \
+ || (__LINUX_KERNEL_VERSION >= 132609 && defined __x86_64__) \
+ || (__LINUX_KERNEL_VERSION >= 132609 && defined __powerpc__) \
+ || (__LINUX_KERNEL_VERSION >= 132609 && defined __sh__)
+# define __ASSUME_TGKILL 1
+#endif
+
+/* The utimes syscall has been available for some architectures
+ forever. For x86 it was introduced after 2.5.75, for x86-64,
+ ppc, and ppc64 it was introduced in 2.6.0-test3. */
+#if defined __alpha__ || defined __ia64__ || defined __hppa__ \
+ || defined __sparc__ \
+ || (__LINUX_KERNEL_VERSION > 132427 && defined __i386__) \
+ || (__LINUX_KERNEL_VERSION > 132609 && defined __x86_64__) \
+ || (__LINUX_KERNEL_VERSION >= 132609 && defined __powerpc__) \
+ || (__LINUX_KERNEL_VERSION >= 132609 && defined __sh__)
+# define __ASSUME_UTIMES 1
+#endif
+
+// XXX Disabled for now since the semantics we want is not achieved.
+#if 0
+/* The CLONE_STOPPED flag was introduced in the 2.6.0-test1 series. */
+#if __LINUX_KERNEL_VERSION >= 132609
+# define __ASSUME_CLONE_STOPPED 1
+#endif
+#endif
+
+/* The fixed version of the posix_fadvise64 syscall appeared in
+ 2.6.0-test3. At least for x86. Powerpc support appeared in
+ 2.6.2, but for 32-bit userspace only. */
+#if (__LINUX_KERNEL_VERSION >= 132609 && defined __i386__) \
+ || (__LINUX_KERNEL_VERSION >= 132610 && defined __powerpc__ \
+ && !defined __powerpc64__)
+# define __ASSUME_FADVISE64_64_SYSCALL 1
+#endif
+
+/* The PROT_GROWSDOWN/PROT_GROWSUP flags were introduced in the 2.6.0-test
+ series. */
+#if __LINUX_KERNEL_VERSION >= 132609
+# define __ASSUME_PROT_GROWSUPDOWN 1
+#endif
+
+/* Starting with 2.6.0 PowerPC adds signal/swapcontext support for Vector
+ SIMD (AKA Altivec, VMX) instructions and register state. This changes
+ the overall size of the sigcontext and adds the swapcontext syscall. */
+#if __LINUX_KERNEL_VERSION >= 132608 && defined __powerpc__
+# define __ASSUME_SWAPCONTEXT_SYSCALL 1
+#endif
+
+/* The CLONE_DETACHED flag is not necessary in 2.6.2 kernels, it is
+ implied. */
+#if __LINUX_KERNEL_VERSION >= 132610
+# define __ASSUME_NO_CLONE_DETACHED 1
+#endif
+
+/* Starting with version 2.6.4-rc1 the getdents syscall returns d_type
+ information as well and in between 2.6.5 and 2.6.8 most compat wrappers
+ were fixed too. Except s390{,x} which was fixed in 2.6.11. */
+#if (__LINUX_KERNEL_VERSION >= 0x020608 && !defined __s390__) \
+ || (__LINUX_KERNEL_VERSION >= 0x02060b && defined __s390__)
+# define __ASSUME_GETDENTS32_D_TYPE 1
+#endif
+
+/* Starting with version 2.5.3, the initial location returned by `brk'
+ after exec is always rounded up to the next page. */
+#if __LINUX_KERNEL_VERSION >= 132355
+# define __ASSUME_BRK_PAGE_ROUNDED 1
+#endif
+
+/* Starting with version 2.6.9, the waitid system call is available.
+ Except for powerpc and powerpc64, where it is available in 2.6.12. */
+#if (__LINUX_KERNEL_VERSION >= 0x020609 && !defined __powerpc__) \
+ || (__LINUX_KERNEL_VERSION >= 0x02060c && defined __powerpc__)
+# define __ASSUME_WAITID_SYSCALL 1
+#endif
+
+/* Starting with version 2.6.9, SSI_IEEE_RAISE_EXCEPTION exists. */
+#if __LINUX_KERNEL_VERSION >= 0x020609 && defined __alpha__
+#define __ASSUME_IEEE_RAISE_EXCEPTION 1
+#endif
+
+/* Support for the accept4 syscall was added in 2.6.28. */
+#if __LINUX_KERNEL_VERSION >= 0x02061c \
+ && (defined __i386__ || defined __x86_64__ || defined __powerpc__ \
+ || defined __sparc__ || defined __s390__)
+# define __ASSUME_ACCEPT4 1
+#endif
+
+/* Support for the accept4 syscall for alpha was added after 2.6.33-rc1. */
+#if __LINUX_KERNEL_VERSION >= 0x020621 && defined __alpha__
+# define __ASSUME_ACCEPT4 1
+#endif
+
+/* Support for the FUTEX_CLOCK_REALTIME flag was added in 2.6.29. */
+#if __LINUX_KERNEL_VERSION >= 0x02061d
+# define __ASSUME_FUTEX_CLOCK_REALTIME 1
+#endif
+
+/* Support for PI futexes was added in 2.6.18. */
+#if __LINUX_KERNEL_VERSION >= 0x020612
+# define __ASSUME_FUTEX_LOCK_PI 1
+#endif
+
+/* Support for private futexes was added in 2.6.22. */
+#if __LINUX_KERNEL_VERSION >= 0x020616
+# define __ASSUME_PRIVATE_FUTEX 1
+#endif
+
+/* Support for fallocate was added in 2.6.23,
+ on s390 only after 2.6.23-rc1, on alpha only after 2.6.33-rc1. */
+#if __LINUX_KERNEL_VERSION >= 0x020617 \
+ && (!defined __s390__ || __LINUX_KERNEL_VERSION >= 0x020618) \
+ && (!defined __alpha__ || __LINUX_KERNEL_VERSION >= 0x020621)
+# define __ASSUME_FALLOCATE 1
+#endif
+
+/* getcpu is a syscall for x86-64 since 3.1. */
+#if defined __x86_64__ && __LINUX_KERNEL_VERSION >= 0x030100
+# define __ASSUME_GETCPU_SYSCALL 1
+#endif
+
+/* getrandom syscall (widely) appeared around 4.0.0 */
+#if __LINUX_KERNEL_VERSION >= 0x040000
+# define __ASSUME_GETRANDOM_SYSCALL 1
+#endif
diff --git a/libc/sysdeps/linux/common/bits/kernel_sigaction.h b/libc/sysdeps/linux/common/bits/kernel_sigaction.h
index 99148e608..5c8726058 100644
--- a/libc/sysdeps/linux/common/bits/kernel_sigaction.h
+++ b/libc/sysdeps/linux/common/bits/kernel_sigaction.h
@@ -4,65 +4,21 @@
/* This file provides whatever this particular arch's kernel thinks
* the sigaction struct should look like... */
-#undef NO_OLD_SIGACTION
-#if defined(__mips__)
-#undef HAVE_SA_RESTORER
-/* This is the sigaction structure from the Linux 2.1.24 kernel. */
-#include <sgidefs.h>
-struct old_kernel_sigaction {
- __sighandler_t k_sa_handler;
- unsigned int sa_flags;
- unsigned long sa_mask;
-};
-#define _KERNEL_NSIG 128
-#define _KERNEL_NSIG_BPW 32
-#define _KERNEL_NSIG_WORDS (_KERNEL_NSIG / _KERNEL_NSIG_BPW)
-
-typedef struct {
- unsigned long sig[_KERNEL_NSIG_WORDS];
-} kernel_sigset_t;
+#if defined(__ia64__)
-/* This is the sigaction structure from the Linux 2.1.68 kernel. */
-struct kernel_sigaction {
- unsigned int sa_flags;
- __sighandler_t k_sa_handler;
- kernel_sigset_t sa_mask;
- void (*sa_restorer)(void);
- int s_resv[1]; /* reserved */
-};
-#elif defined(__ia64__)
-#define NO_OLD_SIGACTION
#undef HAVE_SA_RESTORER
-struct kernel_sigaction {
- __sighandler_t k_sa_handler;
- unsigned long sa_flags;
- sigset_t sa_mask;
-};
+
#else
+
#define HAVE_SA_RESTORER
/* This is the sigaction structure from the Linux 2.1.20 kernel. */
struct old_kernel_sigaction {
- __sighandler_t k_sa_handler;
- unsigned long sa_mask;
- unsigned long sa_flags;
- void (*sa_restorer) (void);
-};
-/* This is the sigaction structure from the Linux 2.1.68 kernel. */
-struct kernel_sigaction {
- __sighandler_t k_sa_handler;
- unsigned long sa_flags;
- void (*sa_restorer) (void);
- sigset_t sa_mask;
+ __sighandler_t k_sa_handler;
+ unsigned long sa_mask;
+ unsigned long sa_flags;
+ void (*sa_restorer)(void);
};
#endif
-#ifndef NO_OLD_SIGACTION
-extern int __syscall_sigaction (int, const struct old_kernel_sigaction *__unbounded,
- struct old_kernel_sigaction *__unbounded) attribute_hidden;
-#endif
-
-extern int __syscall_rt_sigaction (int, const struct kernel_sigaction *__unbounded,
- struct kernel_sigaction *__unbounded, size_t) attribute_hidden;
-
#endif /* _BITS_SIGACTION_STRUCT_H */
diff --git a/libc/sysdeps/linux/common/bits/local_lim.h b/libc/sysdeps/linux/common/bits/local_lim.h
index 023ebf3d0..710de1d98 100644
--- a/libc/sysdeps/linux/common/bits/local_lim.h
+++ b/libc/sysdeps/linux/common/bits/local_lim.h
@@ -1,5 +1,5 @@
/* Minimum guaranteed maximum values for system limits. Linux version.
- Copyright (C) 1993-1998,2000,2002,2003,2004 Free Software Foundation, Inc.
+ Copyright (C) 1993-1998,2000,2002-2004,2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
/* The kernel header pollutes the namespace with the NR_OPEN symbol
and defines LINK_MAX although filesystems have different maxima. A
@@ -31,6 +30,9 @@
#ifndef OPEN_MAX
# define __undef_OPEN_MAX
#endif
+#ifndef ARG_MAX
+# define __undef_ARG_MAX
+#endif
/* The kernel sources contain a file with all the needed information. */
#include <linux/limits.h>
@@ -50,6 +52,11 @@
# undef OPEN_MAX
# undef __undef_OPEN_MAX
#endif
+/* Have to remove ARG_MAX? */
+#ifdef __undef_ARG_MAX
+# undef ARG_MAX
+# undef __undef_ARG_MAX
+#endif
/* The number of data keys per process. */
#define _POSIX_THREAD_KEYS_MAX 128
@@ -63,6 +70,8 @@
/* The number of threads per process. */
#define _POSIX_THREAD_THREADS_MAX 64
+/* We have no predefined limit on the number of threads. */
+#undef PTHREAD_THREADS_MAX
/* Maximum amount by which a process can descrease its asynchronous I/O
priority level. */
@@ -85,3 +94,6 @@
/* Maximum message queue priority level. */
#define MQ_PRIO_MAX 32768
+
+/* Maximum value the semaphore can have. */
+#define SEM_VALUE_MAX (2147483647)
diff --git a/libc/sysdeps/linux/common/bits/locale.h b/libc/sysdeps/linux/common/bits/locale.h
index 5d5178361..aa6949f4e 100644
--- a/libc/sysdeps/linux/common/bits/locale.h
+++ b/libc/sysdeps/linux/common/bits/locale.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#if !defined _LOCALE_H && !defined _LANGINFO_H
# error "Never use <bits/locale.h> directly; include <locale.h> instead."
@@ -33,14 +32,12 @@ enum
__LC_MONETARY = 4,
__LC_MESSAGES = 5,
__LC_ALL = 6,
-#if 0
__LC_PAPER = 7,
__LC_NAME = 8,
__LC_ADDRESS = 9,
__LC_TELEPHONE = 10,
__LC_MEASUREMENT = 11,
__LC_IDENTIFICATION = 12
-#endif
};
#endif /* bits/locale.h */
diff --git a/libc/sysdeps/linux/common/bits/mathcalls.h b/libc/sysdeps/linux/common/bits/mathcalls.h
index c02007284..8ab807578 100644
--- a/libc/sysdeps/linux/common/bits/mathcalls.h
+++ b/libc/sysdeps/linux/common/bits/mathcalls.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* NOTE: Because of the special way this file is used by <math.h>, this
file must NOT be protected from multiple inclusion as header files
@@ -24,7 +23,7 @@
This file provides prototype declarations for the math functions.
Most functions are declared using the macro:
- __MATHCALL (NAME,[_r], (ARGS...));
+ __MATHCALL (NAME,[_r], (ARGS...))
This means there is a function `NAME' returning `double' and a function
`NAMEf' returning `float'. Each place `_Mdouble_' appears in the
@@ -34,7 +33,7 @@
Functions returning other types like `int' are declared using the macro:
- __MATHDECL (TYPE, NAME,[_r], (ARGS...));
+ __MATHDECL (TYPE, NAME,[_r], (ARGS...))
This is just like __MATHCALL but for a function returning `TYPE'
instead of `_Mdouble_'. In all of these cases, there is still
@@ -48,49 +47,76 @@
#endif
+/* __MATHCALLX(type,function,[suffix],args,attrib) and
+ * __MATHCALLI(type,function,[suffix],args) include libm_hidden_proto
+ * (for "double" versions only, xxxf and xxxl do not get this treatment).
+ *
+ * __MATHDECL(type,function,[suffix],args) does not.
+ * __MATHCALL(function,[suffix],args) also does not
+ * (it is just a shortcut to __MATHDECL(_Mdouble_,function,[suffix],args)).
+ *
+ * __MATHDECL_PRIV(type,function,[suffix],args,attrib)
+ * includes libm_hidden_proto (always) and declares __foo, not foo.
+ */
+
+
/* Trigonometric functions. */
_Mdouble_BEGIN_NAMESPACE
/* Arc cosine of X. */
-__MATHCALL (acos,, (_Mdouble_ __x));
+__MATHCALLI (acos,, (_Mdouble_ __x))
/* Arc sine of X. */
-__MATHCALL (asin,, (_Mdouble_ __x));
+__MATHCALLI (asin,, (_Mdouble_ __x))
/* Arc tangent of X. */
-__MATHCALL (atan,, (_Mdouble_ __x));
+__MATHCALLI (atan,, (_Mdouble_ __x))
/* Arc tangent of Y/X. */
-__MATHCALL (atan2,, (_Mdouble_ __y, _Mdouble_ __x));
+__MATHCALLI (atan2,, (_Mdouble_ __y, _Mdouble_ __x))
/* Cosine of X. */
-__MATHCALL (cos,, (_Mdouble_ __x));
+__MATHCALLI (cos,, (_Mdouble_ __x))
+# if defined _LIBC && defined _Mlong_double_
+libm_hidden_proto(cosl)
+# endif
+# if defined _LIBC && defined _Mfloat_
+libm_hidden_proto(cosf)
+# endif
+
/* Sine of X. */
-__MATHCALL (sin,, (_Mdouble_ __x));
+__MATHCALLI (sin,, (_Mdouble_ __x))
+# if defined _LIBC && defined _Mlong_double_
+libm_hidden_proto(sinl)
+# endif
+# if defined _LIBC && defined _Mfloat_
+libm_hidden_proto(sinf)
+# endif
+
/* Tangent of X. */
-__MATHCALL (tan,, (_Mdouble_ __x));
+__MATHCALLI (tan,, (_Mdouble_ __x))
/* Hyperbolic functions. */
/* Hyperbolic cosine of X. */
-__MATHCALL (cosh,, (_Mdouble_ __x));
+__MATHCALLI (cosh,, (_Mdouble_ __x))
/* Hyperbolic sine of X. */
-__MATHCALL (sinh,, (_Mdouble_ __x));
+__MATHCALLI (sinh,, (_Mdouble_ __x))
/* Hyperbolic tangent of X. */
-__MATHCALL (tanh,, (_Mdouble_ __x));
+__MATHCALLI (tanh,, (_Mdouble_ __x))
_Mdouble_END_NAMESPACE
-#if 0 /*def __USE_GNU*/
+#if defined __USE_GNU
/* Cosine and sine of X. */
__MATHDECL (void,sincos,,
- (_Mdouble_ __x, _Mdouble_ *__sinx, _Mdouble_ *__cosx));
+ (_Mdouble_ __x, _Mdouble_ *__sinx, _Mdouble_ *__cosx))
#endif
#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
__BEGIN_NAMESPACE_C99
/* Hyperbolic arc cosine of X. */
-__MATHCALL (acosh,, (_Mdouble_ __x));
+__MATHCALLI (acosh,, (_Mdouble_ __x))
/* Hyperbolic arc sine of X. */
-__MATHCALL (asinh,, (_Mdouble_ __x));
+__MATHCALLI (asinh,, (_Mdouble_ __x))
/* Hyperbolic arc tangent of X. */
-__MATHCALL (atanh,, (_Mdouble_ __x));
+__MATHCALLI (atanh,, (_Mdouble_ __x))
__END_NAMESPACE_C99
#endif
@@ -98,51 +124,54 @@ __END_NAMESPACE_C99
_Mdouble_BEGIN_NAMESPACE
/* Exponential function of X. */
-__MATHCALL (exp,, (_Mdouble_ __x));
+__MATHCALLI (exp,, (_Mdouble_ __x))
+# if defined _LIBC && defined _Mlong_double_
+libm_hidden_proto(expl)
+# endif
/* Break VALUE into a normalized fraction and an integral power of 2. */
-__MATHCALL (frexp,, (_Mdouble_ __x, int *__exponent));
+__MATHCALLI (frexp,, (_Mdouble_ __x, int *__exponent))
/* X times (two to the EXP power). */
-__MATHCALL (ldexp,, (_Mdouble_ __x, int __exponent));
+__MATHCALLI (ldexp,, (_Mdouble_ __x, int __exponent))
/* Natural logarithm of X. */
-__MATHCALL (log,, (_Mdouble_ __x));
+__MATHCALLI (log,, (_Mdouble_ __x))
/* Base-ten logarithm of X. */
-__MATHCALL (log10,, (_Mdouble_ __x));
+__MATHCALLI (log10,, (_Mdouble_ __x))
/* Break VALUE into integral and fractional parts. */
-__MATHCALL (modf,, (_Mdouble_ __x, _Mdouble_ *__iptr));
+__MATHCALLI (modf,, (_Mdouble_ __x, _Mdouble_ *__iptr))
_Mdouble_END_NAMESPACE
-#if 0 /*def __USE_GNU*/
+#if defined __USE_GNU
/* A function missing in all standards: compute exponent to base ten. */
-__MATHCALL (exp10,, (_Mdouble_ __x));
+__MATHCALLI (exp10,, (_Mdouble_ __x))
/* Another name occasionally used. */
-__MATHCALL (pow10,, (_Mdouble_ __x));
+__MATHCALLI (pow10,, (_Mdouble_ __x))
#endif
#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
__BEGIN_NAMESPACE_C99
/* Return exp(X) - 1. */
-__MATHCALL (expm1,, (_Mdouble_ __x));
+__MATHCALLI (expm1,, (_Mdouble_ __x))
/* Return log(1 + X). */
-__MATHCALL (log1p,, (_Mdouble_ __x));
+__MATHCALLI (log1p,, (_Mdouble_ __x))
/* Return the base 2 signed integral exponent of X. */
-__MATHCALL (logb,, (_Mdouble_ __x));
+__MATHCALLI (logb,, (_Mdouble_ __x))
__END_NAMESPACE_C99
#endif
#ifdef __USE_ISOC99
__BEGIN_NAMESPACE_C99
/* Compute base-2 exponential of X. */
-__MATHCALL (exp2,, (_Mdouble_ __x));
+__MATHCALLI (exp2,, (_Mdouble_ __x))
/* Compute base-2 logarithm of X. */
-__MATHCALL (log2,, (_Mdouble_ __x));
+__MATHCALLI (log2,, (_Mdouble_ __x))
__END_NAMESPACE_C99
#endif
@@ -151,23 +180,26 @@ __END_NAMESPACE_C99
_Mdouble_BEGIN_NAMESPACE
/* Return X to the Y power. */
-__MATHCALL (pow,, (_Mdouble_ __x, _Mdouble_ __y));
+__MATHCALLI (pow,, (_Mdouble_ __x, _Mdouble_ __y))
/* Return the square root of X. */
-__MATHCALL (sqrt,, (_Mdouble_ __x));
+__MATHCALLI (sqrt,, (_Mdouble_ __x))
_Mdouble_END_NAMESPACE
#if defined __USE_MISC || defined __USE_XOPEN || defined __USE_ISOC99
__BEGIN_NAMESPACE_C99
/* Return `sqrt(X*X + Y*Y)'. */
-__MATHCALL (hypot,, (_Mdouble_ __x, _Mdouble_ __y));
+__MATHCALLI (hypot,, (_Mdouble_ __x, _Mdouble_ __y))
+# if defined _LIBC && defined _Mlong_double_
+libm_hidden_proto(hypotl)
+# endif
__END_NAMESPACE_C99
#endif
#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
__BEGIN_NAMESPACE_C99
/* Return the cube root of X. */
-__MATHCALL (cbrt,, (_Mdouble_ __x));
+__MATHCALLI (cbrt,, (_Mdouble_ __x))
__END_NAMESPACE_C99
#endif
@@ -176,100 +208,105 @@ __END_NAMESPACE_C99
_Mdouble_BEGIN_NAMESPACE
/* Smallest integral value not less than X. */
-__MATHCALLX (ceil,, (_Mdouble_ __x), (__const__));
+__MATHCALLX (ceil,, (_Mdouble_ __x), (__const__))
/* Absolute value of X. */
-__MATHCALLX (fabs,, (_Mdouble_ __x), (__const__));
+__MATHCALLX (fabs,, (_Mdouble_ __x), (__const__))
/* Largest integer not greater than X. */
-__MATHCALLX (floor,, (_Mdouble_ __x), (__const__));
+__MATHCALLX (floor,, (_Mdouble_ __x), (__const__))
/* Floating-point modulo remainder of X/Y. */
-__MATHCALL (fmod,, (_Mdouble_ __x, _Mdouble_ __y));
+__MATHCALLI (fmod,, (_Mdouble_ __x, _Mdouble_ __y))
/* Return 0 if VALUE is finite or NaN, +1 if it
is +Infinity, -1 if it is -Infinity. */
-__MATHDECL_1 (int,__isinf,, (_Mdouble_ __value)) __attribute__ ((__const__));
+__MATHDECL_PRIV (int,isinf,, (_Mdouble_ __value), (__const__))
/* Return nonzero if VALUE is finite and not NaN. */
-__MATHDECL_1 (int,__finite,, (_Mdouble_ __value)) __attribute__ ((__const__));
+__MATHDECL_PRIV (int,finite,, (_Mdouble_ __value), (__const__))
_Mdouble_END_NAMESPACE
#ifdef __USE_MISC
+#if 0
/* Return 0 if VALUE is finite or NaN, +1 if it
is +Infinity, -1 if it is -Infinity. */
-__MATHDECL_1 (int,isinf,, (_Mdouble_ __value)) __attribute__ ((__const__));
+__MATHDECL_PRIV (int,isinf,, (_Mdouble_ __value), (__const__))
/* Return nonzero if VALUE is finite and not NaN. */
-__MATHDECL_1 (int,finite,, (_Mdouble_ __value)) __attribute__ ((__const__));
-
+__MATHDECL_PRIV (int,finite,, (_Mdouble_ __value), (__const__))
+#endif
/* Return the remainder of X/Y. */
-__MATHCALL (drem,, (_Mdouble_ __x, _Mdouble_ __y));
+__MATHCALL (drem,, (_Mdouble_ __x, _Mdouble_ __y))
/* Return the fractional part of X after dividing out `ilogb (X)'. */
-__MATHCALL (significand,, (_Mdouble_ __x));
+__MATHCALLI (significand,, (_Mdouble_ __x))
#endif /* Use misc. */
#if defined __USE_MISC || defined __USE_ISOC99
__BEGIN_NAMESPACE_C99
/* Return X with its signed changed to Y's. */
-__MATHCALLX (copysign,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
+__MATHCALLX (copysign,, (_Mdouble_ __x, _Mdouble_ __y), (__const__))
__END_NAMESPACE_C99
#endif
#ifdef __USE_ISOC99
__BEGIN_NAMESPACE_C99
/* Return representation of NaN for double type. */
-__MATHCALLX (nan,, (__const char *__tagb), (__const__));
+__MATHCALLX (nan,, (const char *__tagb), (__const__))
__END_NAMESPACE_C99
#endif
-
+#if defined __USE_MISC || defined __USE_XOPEN || defined __USE_ISOC99
/* Return nonzero if VALUE is not a number. */
-__MATHDECL_1 (int,__isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
+__BEGIN_NAMESPACE_C99
+__MATHDECL_PRIV (int,isnan,, (_Mdouble_ __value), (__const__))
+__END_NAMESPACE_C99
+#endif
#if defined __USE_MISC || defined __USE_XOPEN
-/* Return nonzero if VALUE is not a number. */
-__MATHDECL_1 (int,isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
-
+# ifdef __DO_XSI_MATH__
/* Bessel functions. */
-__MATHCALL (j0,, (_Mdouble_));
-__MATHCALL (j1,, (_Mdouble_));
-__MATHCALL (jn,, (int, _Mdouble_));
-__MATHCALL (y0,, (_Mdouble_));
-__MATHCALL (y1,, (_Mdouble_));
-__MATHCALL (yn,, (int, _Mdouble_));
+__MATHCALL (j0,, (_Mdouble_))
+__MATHCALL (j1,, (_Mdouble_))
+__MATHCALL (jn,, (int, _Mdouble_))
+__MATHCALL (y0,, (_Mdouble_))
+__MATHCALL (y1,, (_Mdouble_))
+__MATHCALL (yn,, (int, _Mdouble_))
+# endif
#endif
#if defined __USE_MISC || defined __USE_XOPEN || defined __USE_ISOC99
__BEGIN_NAMESPACE_C99
/* Error and gamma functions. */
-__MATHCALL (erf,, (_Mdouble_));
-__MATHCALL (erfc,, (_Mdouble_));
-__MATHCALL (lgamma,, (_Mdouble_));
+__MATHCALLI (erf,, (_Mdouble_))
+__MATHCALLI (erfc,, (_Mdouble_))
+__MATHCALLI (lgamma,, (_Mdouble_))
__END_NAMESPACE_C99
#endif
#ifdef __USE_ISOC99
__BEGIN_NAMESPACE_C99
/* True gamma function. */
-__MATHCALL (tgamma,, (_Mdouble_));
+__MATHCALLI (tgamma,, (_Mdouble_))
__END_NAMESPACE_C99
#endif
#if defined __USE_MISC || defined __USE_XOPEN
/* Obsolete alias for `lgamma'. */
-__MATHCALL (gamma,, (_Mdouble_));
+__MATHCALLI (gamma,, (_Mdouble_))
#endif
#ifdef __USE_MISC
/* Reentrant version of lgamma. This function uses the global variable
`signgam'. The reentrant version instead takes a pointer and stores
the value through it. */
-__MATHCALL (lgamma,_r, (_Mdouble_, int *__signgamp));
+__MATHCALL (lgamma,_r, (_Mdouble_, int *__signgamp))
+/* __MATHCALLI does not work here, probably due to ,_r, */
+libm_hidden_proto(lgamma_r)
#endif
@@ -277,89 +314,91 @@ __MATHCALL (lgamma,_r, (_Mdouble_, int *__signgamp));
__BEGIN_NAMESPACE_C99
/* Return the integer nearest X in the direction of the
prevailing rounding mode. */
-__MATHCALL (rint,, (_Mdouble_ __x));
+__MATHCALLI (rint,, (_Mdouble_ __x))
/* Return X + epsilon if X < Y, X - epsilon if X > Y. */
-__MATHCALLX (nextafter,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
+__MATHCALLX (nextafter,, (_Mdouble_ __x, _Mdouble_ __y), (__const__))
+# if defined _LIBC && defined _Mlong_double_
+libm_hidden_proto(nextafterl)
+# endif
# if defined __USE_ISOC99 && !defined __LDBL_COMPAT
-__MATHCALLX (nexttoward,, (_Mdouble_ __x, long double __y), (__const__));
+__MATHCALLX (nexttoward,, (_Mdouble_ __x, long double __y), (__const__))
# endif
/* Return the remainder of integer divison X / Y with infinite precision. */
-__MATHCALL (remainder,, (_Mdouble_ __x, _Mdouble_ __y));
+__MATHCALLI (remainder,, (_Mdouble_ __x, _Mdouble_ __y))
# if defined __USE_MISC || defined __USE_ISOC99
/* Return X times (2 to the Nth power). */
-__MATHCALL (scalbn,, (_Mdouble_ __x, int __n));
+__MATHCALLI (scalbn,, (_Mdouble_ __x, int __n))
# endif
/* Return the binary exponent of X, which must be nonzero. */
-__MATHDECL (int,ilogb,, (_Mdouble_ __x));
+__MATHDECLI (int,ilogb,, (_Mdouble_ __x))
#endif
#ifdef __USE_ISOC99
/* Return X times (2 to the Nth power). */
-__MATHCALL (scalbln,, (_Mdouble_ __x, long int __n));
+__MATHCALLI (scalbln,, (_Mdouble_ __x, long int __n))
/* Round X to integral value in floating-point format using current
rounding direction, but do not raise inexact exception. */
-__MATHCALL (nearbyint,, (_Mdouble_ __x));
+__MATHCALLI (nearbyint,, (_Mdouble_ __x))
/* Round X to nearest integral value, rounding halfway cases away from
zero. */
-__MATHCALLX (round,, (_Mdouble_ __x), (__const__));
+__MATHCALLX (round,, (_Mdouble_ __x), (__const__))
/* Round X to the integral value in floating-point format nearest but
not larger in magnitude. */
-__MATHCALLX (trunc,, (_Mdouble_ __x), (__const__));
+__MATHCALLX (trunc,, (_Mdouble_ __x), (__const__))
/* Compute remainder of X and Y and put in *QUO a value with sign of x/y
and magnitude congruent `mod 2^n' to the magnitude of the integral
quotient x/y, with n >= 3. */
-__MATHCALL (remquo,, (_Mdouble_ __x, _Mdouble_ __y, int *__quo));
+__MATHCALLI (remquo,, (_Mdouble_ __x, _Mdouble_ __y, int *__quo))
/* Conversion functions. */
/* Round X to nearest integral value according to current rounding
direction. */
-__MATHDECL (long int,lrint,, (_Mdouble_ __x));
-__MATHDECL (long long int,llrint,, (_Mdouble_ __x));
+__MATHDECLI (long int,lrint,, (_Mdouble_ __x))
+__MATHDECLI (long long int,llrint,, (_Mdouble_ __x))
/* Round X to nearest integral value, rounding halfway cases away from
zero. */
-__MATHDECL (long int,lround,, (_Mdouble_ __x));
-__MATHDECL (long long int,llround,, (_Mdouble_ __x));
+__MATHDECLI (long int,lround,, (_Mdouble_ __x))
+__MATHDECLI (long long int,llround,, (_Mdouble_ __x))
/* Return positive difference between X and Y. */
-__MATHCALL (fdim,, (_Mdouble_ __x, _Mdouble_ __y));
+__MATHCALLI (fdim,, (_Mdouble_ __x, _Mdouble_ __y))
/* Return maximum numeric value from X and Y. */
-__MATHCALL (fmax,, (_Mdouble_ __x, _Mdouble_ __y));
+__MATHCALLI (fmax,, (_Mdouble_ __x, _Mdouble_ __y))
/* Return minimum numeric value from X and Y. */
-__MATHCALL (fmin,, (_Mdouble_ __x, _Mdouble_ __y));
+__MATHCALLI (fmin,, (_Mdouble_ __x, _Mdouble_ __y))
/* Classify given number. */
-__MATHDECL_1 (int, __fpclassify,, (_Mdouble_ __value))
- __attribute__ ((__const__));
+__MATHDECL_PRIV (int, fpclassify,, (_Mdouble_ __value), (__const__))
/* Test for negative number. */
-__MATHDECL_1 (int, __signbit,, (_Mdouble_ __value))
- __attribute__ ((__const__));
+__MATHDECL_PRIV (int, signbit,, (_Mdouble_ __value), (__const__))
/* Multiply-add function computed as a ternary operation. */
-__MATHCALL (fma,, (_Mdouble_ __x, _Mdouble_ __y, _Mdouble_ __z));
+__MATHCALLI (fma,, (_Mdouble_ __x, _Mdouble_ __y, _Mdouble_ __z))
#endif /* Use ISO C99. */
#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
__END_NAMESPACE_C99
#endif
-#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
+#if (defined __USE_MISC || defined __USE_XOPEN_EXTENDED) \
+ && defined __UCLIBC_SUSV3_LEGACY__
/* Return X times (2 to the Nth power). */
-__MATHCALL (scalb,, (_Mdouble_ __x, _Mdouble_ __n));
+__MATHCALLI (scalb,, (_Mdouble_ __x, _Mdouble_ __n))
#endif
diff --git a/libc/sysdeps/linux/common/bits/mathdef.h b/libc/sysdeps/linux/common/bits/mathdef.h
index 00c67241a..ddcf6d40b 100644
--- a/libc/sysdeps/linux/common/bits/mathdef.h
+++ b/libc/sysdeps/linux/common/bits/mathdef.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#if !defined _MATH_H && !defined _COMPLEX_H
# error "Never use <bits/mathdef.h> directly; include <math.h> instead"
diff --git a/libc/sysdeps/linux/common/bits/mathinline.h b/libc/sysdeps/linux/common/bits/mathinline.h
index 5498af6b6..02ec21b43 100644
--- a/libc/sysdeps/linux/common/bits/mathinline.h
+++ b/libc/sysdeps/linux/common/bits/mathinline.h
@@ -1,6 +1,6 @@
/* This file should provide inline versions of math functions.
- Surround GCC-specific parts with #ifdef __GNUC__, and use `extern __inline'.
+ Surround GCC-specific parts with #ifdef __GNUC__, and use `__extern_inline'.
This file should define __MATH_INLINES if functions are actually defined as
inlines. */
diff --git a/libc/sysdeps/linux/arm/bits/mman.h b/libc/sysdeps/linux/common/bits/mman-common.h
index 828ec944c..6cde5daa3 100644
--- a/libc/sysdeps/linux/arm/bits/mman.h
+++ b/libc/sysdeps/linux/common/bits/mman-common.h
@@ -1,5 +1,5 @@
-/* Definitions for POSIX memory map interface. Linux/ARM version.
- Copyright (C) 1997, 2000, 2003, 2005, 2006 Free Software Foundation, Inc.
+/* Definitions for POSIX memory map interface. Linux/generic version.
+ Copyright (C) 1997,2000,2003,2005,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
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_MMAN_H
# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
@@ -63,6 +62,9 @@
# define MAP_NORESERVE 0x04000 /* Don't check for reservations. */
# define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */
# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */
+# define MAP_STACK 0x20000 /* Allocation is for a stack. */
+# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could
+ be uninitialized. */
#endif
/* Flags to `msync'. */
@@ -83,14 +85,17 @@
/* Advice to `madvise'. */
#ifdef __USE_BSD
-# define MADV_NORMAL 0 /* No further special treatment. */
-# define MADV_RANDOM 1 /* Expect random page references. */
-# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
-# define MADV_WILLNEED 3 /* Will need these pages. */
-# define MADV_DONTNEED 4 /* Don't need these pages. */
-# define MADV_REMOVE 9 /* Remove these pages and resources. */
-# define MADV_DONTFORK 10 /* Do not inherit across fork. */
-# define MADV_DOFORK 11 /* Do inherit across fork. */
+# define MADV_NORMAL 0 /* No further special treatment. */
+# define MADV_RANDOM 1 /* Expect random page references. */
+# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
+# define MADV_WILLNEED 3 /* Will need these pages. */
+# define MADV_DONTNEED 4 /* Don't need these pages. */
+# define MADV_REMOVE 9 /* Remove these pages and resources. */
+# define MADV_DONTFORK 10 /* Do not inherit across fork. */
+# define MADV_DOFORK 11 /* Do inherit across fork. */
+# define MADV_MERGEABLE 12 /* KSM may merge identical pages. */
+# define MADV_UNMERGEABLE 13 /* KSM may not merge identical pages. */
+# define MADV_HWPOISON 100 /* Poison a page for testing. */
#endif
/* The POSIX people had to invent similar names for the same things. */
diff --git a/libc/sysdeps/linux/common/bits/mman.h b/libc/sysdeps/linux/common/bits/mman.h
index 0c1590270..11b8e2a8b 100644
--- a/libc/sysdeps/linux/common/bits/mman.h
+++ b/libc/sysdeps/linux/common/bits/mman.h
@@ -1,97 +1 @@
-/* Definitions for BSD-style memory management.
- Copyright (C) 1994-1998,2000,01,02,05 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. */
-
-/* These are the bits used by 4.4 BSD and its derivatives. On systems
- (such as GNU) where these facilities are not system services but can be
- emulated in the C library, these are the definitions we emulate. */
-
-#ifndef _SYS_MMAN_H
-# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
-#endif
-
-/* Protections are chosen from these bits, OR'd together. The
- implementation does not necessarily support PROT_EXEC or PROT_WRITE
- without PROT_READ. The only guarantees are that no writing will be
- allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
-
-#define PROT_NONE 0x00 /* No access. */
-#define PROT_READ 0x04 /* Pages can be read. */
-#define PROT_WRITE 0x02 /* Pages can be written. */
-#define PROT_EXEC 0x01 /* Pages can be executed. */
-
-/* Flags contain mapping type, sharing type and options. */
-
-/* Mapping type (must choose one and only one of these). */
-#ifdef __USE_BSD
-# define MAP_FILE 0x0001 /* Mapped from a file or device. */
-# define MAP_ANON 0x0002 /* Allocated from anonymous virtual memory. */
-# define MAP_TYPE 0x000f /* Mask for type field. */
-# ifdef __USE_MISC
-# define MAP_ANONYMOUS MAP_ANON /* Linux name. */
-# endif
-#endif
-
-/* Sharing types (must choose one and only one of these). */
-#ifdef __USE_BSD
-# define MAP_COPY 0x0020 /* Virtual copy of region at mapping time. */
-#endif
-#define MAP_SHARED 0x0010 /* Share changes. */
-#define MAP_PRIVATE 0x0000 /* Changes private; copy pages on write. */
-
-/* Other flags. */
-#define MAP_FIXED 0x0100 /* Map address must be exactly as requested. */
-#ifdef __USE_BSD
-# define MAP_NOEXTEND 0x0200 /* For MAP_FILE, don't change file size. */
-# define MAP_HASSEMPHORE 0x0400 /* Region may contain semaphores. */
-# define MAP_INHERIT 0x0800 /* Region is retained after exec. */
-#endif
-
-/* Advice to `madvise'. */
-#ifdef __USE_BSD
-# define MADV_NORMAL 0 /* No further special treatment. */
-# define MADV_RANDOM 1 /* Expect random page references. */
-# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
-# define MADV_WILLNEED 3 /* Will need these pages. */
-# define MADV_DONTNEED 4 /* Don't need these pages. */
-#endif
-
-/* The POSIX people had to invent similar names for the same things. */
-#ifdef __USE_XOPEN2K
-# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
-# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
-# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
-# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
-# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
-#endif
-
-/* Flags to `msync'. */
-#define MS_ASYNC 1 /* Sync memory asynchronously. */
-#define MS_SYNC 0 /* Synchronous memory sync. */
-#define MS_INVALIDATE 2 /* Invalidate the caches. */
-
-/* Flags for `mremap'. */
-#ifdef __USE_GNU
-# define MREMAP_MAYMOVE 1 /* Mapping address may change. */
-# define MREMAP_FIXED 2 /* Fifth argument sets new address. */
-#endif
-
-/* Flags for `mlockall' (can be OR'd together). */
-#define MCL_CURRENT 1 /* Lock all currently mapped pages. */
-#define MCL_FUTURE 2 /* Lock all additions to address
- space. */
+#include <bits/mman-common.h>
diff --git a/libc/sysdeps/linux/common/bits/mqueue.h b/libc/sysdeps/linux/common/bits/mqueue.h
index df528f876..e755f8722 100644
--- a/libc/sysdeps/linux/common/bits/mqueue.h
+++ b/libc/sysdeps/linux/common/bits/mqueue.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _MQUEUE_H
# error "Never use <bits/mqueue.h> directly; include <mqueue.h> instead."
diff --git a/libc/sysdeps/linux/common/bits/msq.h b/libc/sysdeps/linux/common/bits/msq.h
index 32a49b592..a1c3ea43d 100644
--- a/libc/sysdeps/linux/common/bits/msq.h
+++ b/libc/sysdeps/linux/common/bits/msq.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_MSG_H
# error "Never use <bits/msq.h> directly; include <sys/msg.h> instead."
diff --git a/libc/sysdeps/linux/common/bits/nan.h b/libc/sysdeps/linux/common/bits/nan.h
index bae97f216..00cb405f1 100644
--- a/libc/sysdeps/linux/common/bits/nan.h
+++ b/libc/sysdeps/linux/common/bits/nan.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _MATH_H
# error "Never use <bits/nan.h> directly; include <math.h> instead."
diff --git a/libc/sysdeps/linux/common/bits/netdb.h b/libc/sysdeps/linux/common/bits/netdb.h
index 41dc73193..0205056b8 100644
--- a/libc/sysdeps/linux/common/bits/netdb.h
+++ b/libc/sysdeps/linux/common/bits/netdb.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _NETDB_H
# error "Never include <bits/netdb.h> directly; use <netdb.h> instead."
diff --git a/libc/sysdeps/linux/common/bits/poll.h b/libc/sysdeps/linux/common/bits/poll.h
index d7996b46c..21d6cf28a 100644
--- a/libc/sysdeps/linux/common/bits/poll.h
+++ b/libc/sysdeps/linux/common/bits/poll.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_POLL_H
# error "Never use <bits/poll.h> directly; include <sys/poll.h> instead."
diff --git a/libc/sysdeps/linux/common/bits/posix1_lim.h b/libc/sysdeps/linux/common/bits/posix1_lim.h
index 3c86dcec1..0186d1311 100644
--- a/libc/sysdeps/linux/common/bits/posix1_lim.h
+++ b/libc/sysdeps/linux/common/bits/posix1_lim.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/*
* POSIX Standard: 2.9.2 Minimum Values Added to <limits.h>
diff --git a/libc/sysdeps/linux/common/bits/posix2_lim.h b/libc/sysdeps/linux/common/bits/posix2_lim.h
index 24483a09d..cd3718826 100644
--- a/libc/sysdeps/linux/common/bits/posix2_lim.h
+++ b/libc/sysdeps/linux/common/bits/posix2_lim.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/*
* Never include this file directly; include <limits.h> instead.
diff --git a/libc/sysdeps/linux/common/bits/posix_opt.h b/libc/sysdeps/linux/common/bits/posix_opt.h
index dfe259b7c..e3d32a0bc 100644
--- a/libc/sysdeps/linux/common/bits/posix_opt.h
+++ b/libc/sysdeps/linux/common/bits/posix_opt.h
@@ -1,5 +1,5 @@
/* Define POSIX options for Linux.
- Copyright (C) 1996-2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1996-2004, 2006, 2008, 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
@@ -13,12 +13,11 @@
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. */
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
-#ifndef _POSIX_OPT_H
-#define _POSIX_OPT_H 1
+#ifndef _BITS_POSIX_OPT_H
+#define _BITS_POSIX_OPT_H 1
/* Job control is supported. */
#define _POSIX_JOB_CONTROL 1
@@ -27,28 +26,28 @@
#define _POSIX_SAVED_IDS 1
/* Priority scheduling is supported. */
-#define _POSIX_PRIORITY_SCHEDULING 200112L
+#define _POSIX_PRIORITY_SCHEDULING 200809L
/* Synchronizing file data is supported. */
-#define _POSIX_SYNCHRONIZED_IO 200112L
+#define _POSIX_SYNCHRONIZED_IO 200809L
/* The fsync function is present. */
-#define _POSIX_FSYNC 200112L
+#define _POSIX_FSYNC 200809L
/* Mapping of files to memory is supported. */
-#define _POSIX_MAPPED_FILES 200112L
+#define _POSIX_MAPPED_FILES 200809L
/* Locking of all memory is supported. */
-#define _POSIX_MEMLOCK 200112L
+#define _POSIX_MEMLOCK 200809L
/* Locking of ranges of memory is supported. */
-#define _POSIX_MEMLOCK_RANGE 200112L
+#define _POSIX_MEMLOCK_RANGE 200809L
/* Setting of memory protections is supported. */
-#define _POSIX_MEMORY_PROTECTION 200112L
+#define _POSIX_MEMORY_PROTECTION 200809L
-/* Only root can change owner of file. */
-#define _POSIX_CHOWN_RESTRICTED 1
+/* Some filesystems allow all users to change file ownership. */
+#define _POSIX_CHOWN_RESTRICTED 0
/* `c_cc' member of 'struct termios' structure can be disabled by
using the value _POSIX_VDISABLE. */
@@ -60,51 +59,67 @@
/* X/Open realtime support is available. */
#define _XOPEN_REALTIME 1
+/* X/Open thread realtime support is available. */
+#define _XOPEN_REALTIME_THREADS 1
+
/* XPG4.2 shared memory is supported. */
#define _XOPEN_SHM 1
/* Tell we have POSIX threads. */
-#define _POSIX_THREADS 200112L
+#define _POSIX_THREADS 200809L
/* We have the reentrant functions described in POSIX. */
#define _POSIX_REENTRANT_FUNCTIONS 1
-#define _POSIX_THREAD_SAFE_FUNCTIONS 200112L
+#define _POSIX_THREAD_SAFE_FUNCTIONS 200809L
/* We provide priority scheduling for threads. */
-#define _POSIX_THREAD_PRIORITY_SCHEDULING 200112L
+#define _POSIX_THREAD_PRIORITY_SCHEDULING 200809L
/* We support user-defined stack sizes. */
-#define _POSIX_THREAD_ATTR_STACKSIZE 200112L
+#define _POSIX_THREAD_ATTR_STACKSIZE 200809L
/* We support user-defined stacks. */
-#define _POSIX_THREAD_ATTR_STACKADDR 200112L
+#define _POSIX_THREAD_ATTR_STACKADDR 200809L
+
+/* We support priority inheritence. */
+#define _POSIX_THREAD_PRIO_INHERIT 200809L
+
+/* We support priority protection, though only for non-robust
+ mutexes. */
+#define _POSIX_THREAD_PRIO_PROTECT 200809L
+
+#ifdef __USE_XOPEN2K8
+/* We support priority inheritence for robust mutexes. */
+# define _POSIX_THREAD_ROBUST_PRIO_INHERIT 200809L
+
+/* We do not support priority protection for robust mutexes. */
+# define _POSIX_THREAD_ROBUST_PRIO_PROTECT -1
+#endif
/* We support POSIX.1b semaphores. */
-#define _POSIX_SEMAPHORES 200112L
+#define _POSIX_SEMAPHORES 200809L
/* Real-time signals are supported. */
-#define _POSIX_REALTIME_SIGNALS 200112L
+#define _POSIX_REALTIME_SIGNALS 200809L
/* We support asynchronous I/O. */
-#define _POSIX_ASYNCHRONOUS_IO 200112L
+#define _POSIX_ASYNCHRONOUS_IO 200809L
#define _POSIX_ASYNC_IO 1
/* Alternative name for Unix98. */
#define _LFS_ASYNCHRONOUS_IO 1
/* Support for prioritization is also available. */
-#define _POSIX_PRIORITIZED_IO 200112L
+#define _POSIX_PRIORITIZED_IO 200809L
/* The LFS support in asynchronous I/O is also available. */
#define _LFS64_ASYNCHRONOUS_IO 1
-#ifdef __UCLIBC_HAS_LFS__
/* The rest of the LFS is also available. */
#define _LFS_LARGEFILE 1
#define _LFS64_LARGEFILE 1
#define _LFS64_STDIO 1
-#endif
/* POSIX shared memory objects are implemented. */
-#define _POSIX_SHARED_MEMORY_OBJECTS 200112L
+#define _POSIX_SHARED_MEMORY_OBJECTS 200809L
/* CPU-time clocks support needs to be checked at runtime. */
#define _POSIX_CPUTIME 0
@@ -116,49 +131,49 @@
#define _POSIX_REGEXP 1
/* Reader/Writer locks are available. */
-#define _POSIX_READER_WRITER_LOCKS 200112L
+#define _POSIX_READER_WRITER_LOCKS 200809L
/* We have a POSIX shell. */
#define _POSIX_SHELL 1
/* We support the Timeouts option. */
-#define _POSIX_TIMEOUTS 200112L
+#define _POSIX_TIMEOUTS 200809L
/* We support spinlocks. */
-#define _POSIX_SPIN_LOCKS 200112L
+#define _POSIX_SPIN_LOCKS 200809L
/* The `spawn' function family is supported. */
-#define _POSIX_SPAWN 200112L
+#define _POSIX_SPAWN 200809L
/* We have POSIX timers. */
-#define _POSIX_TIMERS 200112L
+#define _POSIX_TIMERS 200809L
/* The barrier functions are available. */
-#define _POSIX_BARRIERS 200112L
+#define _POSIX_BARRIERS 200809L
/* POSIX message queues are available. */
-#define _POSIX_MESSAGE_PASSING 200112L
+#define _POSIX_MESSAGE_PASSING 200809L
/* Thread process-shared synchronization is supported. */
-#define _POSIX_THREAD_PROCESS_SHARED 200112L
+#define _POSIX_THREAD_PROCESS_SHARED 200809L
/* The monotonic clock might be available. */
#define _POSIX_MONOTONIC_CLOCK 0
/* The clock selection interfaces are available. */
-#define _POSIX_CLOCK_SELECTION 200112L
+#define _POSIX_CLOCK_SELECTION 200809L
/* Advisory information interfaces are available. */
-#define _POSIX_ADVISORY_INFO 200112L
+#define _POSIX_ADVISORY_INFO 200809L
/* IPv6 support is available. */
-#define _POSIX_IPV6 200112L
+#define _POSIX_IPV6 200809L
/* Raw socket support is available. */
-#define _POSIX_RAW_SOCKETS 200112L
+#define _POSIX_RAW_SOCKETS 200809L
/* We have at least one terminal. */
-#define _POSIX2_CHAR_TERM 200112L
+#define _POSIX2_CHAR_TERM 200809L
/* Neither process nor thread sporadic server interfaces is available. */
#define _POSIX_SPORADIC_SERVER -1
@@ -173,8 +188,4 @@
/* Typed memory objects are not available. */
#define _POSIX_TYPED_MEMORY_OBJECTS -1
-/* No support for priority inheritance or protection so far. */
-#define _POSIX_THREAD_PRIO_INHERIT -1
-#define _POSIX_THREAD_PRIO_PROTECT -1
-
-#endif /* posix_opt.h */
+#endif /* bits/posix_opt.h */
diff --git a/libc/sysdeps/linux/common/bits/resource.h b/libc/sysdeps/linux/common/bits/resource.h
index 526cdaf53..df0ba56d9 100644
--- a/libc/sysdeps/linux/common/bits/resource.h
+++ b/libc/sysdeps/linux/common/bits/resource.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_RESOURCE_H
# error "Never use <bits/resource.h> directly; include <sys/resource.h> instead."
diff --git a/libc/sysdeps/linux/common/bits/sched.h b/libc/sysdeps/linux/common/bits/sched.h
index b48a0c874..9d05314f5 100644
--- a/libc/sysdeps/linux/common/bits/sched.h
+++ b/libc/sysdeps/linux/common/bits/sched.h
@@ -1,6 +1,6 @@
/* Definitions of constants and data structure for POSIX 1003.1b-1993
scheduling interface.
- Copyright (C) 1996-1999,2001-2003,2005,2006 Free Software Foundation, Inc.
+ Copyright (C) 1996-2015 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
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef __need_schedparam
@@ -26,14 +25,17 @@
/* Scheduling algorithms. */
-#define SCHED_OTHER 0
-#define SCHED_FIFO 1
-#define SCHED_RR 2
+#define SCHED_OTHER 0
+#define SCHED_FIFO 1
+#define SCHED_RR 2
#ifdef __USE_GNU
-# define SCHED_BATCH 3
+# define SCHED_BATCH 3
+# define SCHED_IDLE 5
+
+# define SCHED_RESET_ON_FORK 0x40000000
#endif
-#ifdef __USE_MISC
+#ifdef __USE_GNU
/* Cloning flags. */
# define CSIGNAL 0x000000ff /* Signal mask to be sent at exit. */
# define CLONE_VM 0x00000100 /* Set if VM shared between processes. */
@@ -58,7 +60,12 @@
force CLONE_PTRACE on this clone. */
# define CLONE_CHILD_SETTID 0x01000000 /* Store TID in userlevel buffer in
the child. */
-# define CLONE_STOPPED 0x02000000 /* Start in stopped state. */
+# define CLONE_NEWUTS 0x04000000 /* New utsname group. */
+# define CLONE_NEWIPC 0x08000000 /* New ipcs. */
+# define CLONE_NEWUSER 0x10000000 /* New user namespace. */
+# define CLONE_NEWPID 0x20000000 /* New pid namespace. */
+# define CLONE_NEWNET 0x40000000 /* New network namespace. */
+# define CLONE_IO 0x80000000 /* Clone I/O context. */
#endif
/* The official definition. */
@@ -69,16 +76,21 @@ struct sched_param
__BEGIN_DECLS
-#ifdef __USE_MISC
+#ifdef __USE_GNU
/* Clone current process. */
extern int clone (int (*__fn) (void *__arg), void *__child_stack,
int __flags, void *__arg, ...) __THROW;
-#if 0
/* Unshare the specified resources. */
extern int unshare (int __flags) __THROW;
+
+/* Get index of currently used CPU. */
+extern int sched_getcpu (void) __THROW;
+
+/* Switch process to namespace of type NSTYPE indicated by FD. */
+extern int setns (int __fd, int __nstype) __THROW;
#endif
-#endif
+
__END_DECLS
@@ -101,8 +113,9 @@ struct __sched_param
/* Size definition for CPU sets. */
# define __CPU_SETSIZE 1024
# define __NCPUBITS (8 * sizeof (__cpu_mask))
+# include <stdlib.h>
-/* Type for array elements in 'cpu_set'. */
+/* Type for array elements in 'cpu_set_t'. */
typedef unsigned long int __cpu_mask;
/* Basic access functions. */
@@ -116,17 +129,87 @@ typedef struct
} cpu_set_t;
/* Access functions for CPU masks. */
-# define __CPU_ZERO(cpusetp) \
+# if __GNUC_PREREQ (2, 91)
+# define __CPU_ZERO_S(setsize, cpusetp) \
+ do __builtin_memset (cpusetp, '\0', setsize); while (0)
+# else
+# define __CPU_ZERO_S(setsize, cpusetp) \
do { \
- unsigned int __i; \
- cpu_set_t *__arr = (cpusetp); \
- for (__i = 0; __i < sizeof (cpu_set_t) / sizeof (__cpu_mask); ++__i) \
- __arr->__bits[__i] = 0; \
+ size_t __i; \
+ size_t __imax = (setsize) / sizeof (__cpu_mask); \
+ __cpu_mask *__bits = (cpusetp)->__bits; \
+ for (__i = 0; __i < __imax; ++__i) \
+ __bits[__i] = 0; \
} while (0)
-# define __CPU_SET(cpu, cpusetp) \
- ((cpusetp)->__bits[__CPUELT (cpu)] |= __CPUMASK (cpu))
-# define __CPU_CLR(cpu, cpusetp) \
- ((cpusetp)->__bits[__CPUELT (cpu)] &= ~__CPUMASK (cpu))
-# define __CPU_ISSET(cpu, cpusetp) \
- (((cpusetp)->__bits[__CPUELT (cpu)] & __CPUMASK (cpu)) != 0)
+# endif
+# define __CPU_SET_S(cpu, setsize, cpusetp) \
+ (__extension__ \
+ ({ size_t __cpu = (cpu); \
+ __cpu / 8 < (setsize) \
+ ? (((__cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \
+ |= __CPUMASK (__cpu)) \
+ : 0; }))
+# define __CPU_CLR_S(cpu, setsize, cpusetp) \
+ (__extension__ \
+ ({ size_t __cpu = (cpu); \
+ __cpu / 8 < (setsize) \
+ ? (((__cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \
+ &= ~__CPUMASK (__cpu)) \
+ : 0; }))
+# define __CPU_ISSET_S(cpu, setsize, cpusetp) \
+ (__extension__ \
+ ({ size_t __cpu = (cpu); \
+ __cpu / 8 < (setsize) \
+ ? ((((const __cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \
+ & __CPUMASK (__cpu))) != 0 \
+ : 0; }))
+
+# define __CPU_COUNT_S(setsize, cpusetp) \
+ __sched_cpucount (setsize, cpusetp)
+
+# if __GNUC_PREREQ (2, 91)
+# define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
+ (__builtin_memcmp (cpusetp1, cpusetp2, setsize) == 0)
+# else
+# define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
+ (__extension__ \
+ ({ const __cpu_mask *__arr1 = (cpusetp1)->__bits; \
+ const __cpu_mask *__arr2 = (cpusetp2)->__bits; \
+ size_t __imax = (setsize) / sizeof (__cpu_mask); \
+ size_t __i; \
+ for (__i = 0; __i < __imax; ++__i) \
+ if (__arr1[__i] != __arr2[__i]) \
+ break; \
+ __i == __imax; }))
+# endif
+
+# define __CPU_OP_S(setsize, destset, srcset1, srcset2, op) \
+ (__extension__ \
+ ({ cpu_set_t *__dest = (destset); \
+ const __cpu_mask *__arr1 = (srcset1)->__bits; \
+ const __cpu_mask *__arr2 = (srcset2)->__bits; \
+ size_t __imax = (setsize) / sizeof (__cpu_mask); \
+ size_t __i; \
+ for (__i = 0; __i < __imax; ++__i) \
+ ((__cpu_mask *) __dest->__bits)[__i] = __arr1[__i] op __arr2[__i]; \
+ __dest; }))
+
+# define __CPU_ALLOC_SIZE(count) \
+ ((((count) + __NCPUBITS - 1) / __NCPUBITS) * sizeof (__cpu_mask))
+# define __CPU_ALLOC(count) __sched_cpualloc (count)
+# define __CPU_FREE(cpuset) __sched_cpufree (cpuset)
+
+__BEGIN_DECLS
+
+extern int __sched_cpucount (size_t __setsize, const cpu_set_t *__setp)
+ __THROW;
+#if 0 /* in uClibc we use macros */
+extern cpu_set_t *__sched_cpualloc (size_t __count) __THROW __wur;
+extern void __sched_cpufree (cpu_set_t *__set) __THROW;
+#else
+# define __sched_cpualloc(cnt) ((cpu_set_t *)malloc(__CPU_ALLOC_SIZE(cnt)))
+# define __sched_cpufree(__set) free(__set)
+#endif
+__END_DECLS
+
#endif
diff --git a/libc/sysdeps/linux/common/bits/select.h b/libc/sysdeps/linux/common/bits/select.h
index 47e7dedc3..6a6188353 100644
--- a/libc/sysdeps/linux/common/bits/select.h
+++ b/libc/sysdeps/linux/common/bits/select.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_SELECT_H
# error "Never use <bits/select.h> directly; include <sys/select.h> instead."
diff --git a/libc/sysdeps/linux/common/bits/sem.h b/libc/sysdeps/linux/common/bits/sem.h
index 6193501e2..501e0803b 100644
--- a/libc/sysdeps/linux/common/bits/sem.h
+++ b/libc/sysdeps/linux/common/bits/sem.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_SEM_H
# error "Never include <bits/sem.h> directly; use <sys/sem.h> instead."
diff --git a/libc/sysdeps/linux/common/bits/shm.h b/libc/sysdeps/linux/common/bits/shm.h
index 318d601ae..88bf7a8aa 100644
--- a/libc/sysdeps/linux/common/bits/shm.h
+++ b/libc/sysdeps/linux/common/bits/shm.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_SHM_H
# error "Never include <bits/shm.h> directly; use <sys/shm.h> instead."
@@ -66,8 +65,8 @@ struct shmid_ds
#ifdef __USE_MISC
/* ipcs ctl commands */
-# define SHM_STAT 13
-# define SHM_INFO 14
+# define SHM_STAT 13
+# define SHM_INFO 14
/* shm_mode upper byte flags */
# define SHM_DEST 01000 /* segment will be destroyed on last detach */
diff --git a/libc/sysdeps/linux/common/bits/sigaction.h b/libc/sysdeps/linux/common/bits/sigaction.h
index 48cc5312f..08510223f 100644
--- a/libc/sysdeps/linux/common/bits/sigaction.h
+++ b/libc/sysdeps/linux/common/bits/sigaction.h
@@ -13,42 +13,33 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SIGNAL_H
# error "Never include <bits/sigaction.h> directly; use <signal.h> instead."
#endif
-/* Structure describing the action to be taken when a signal arrives. */
-struct sigaction
- {
- /* Signal handler. */
+/* Structure describing the action to be taken when a signal arrives.
+ * In uclibc, it is identical to "new" struct kernel_sigaction
+ * (one from the Linux 2.1.68 kernel).
+ * This minimizes amount of translation in sigaction().
+ */
+struct sigaction {
#ifdef __USE_POSIX199309
- union
- {
- /* Used if SA_SIGINFO is not set. */
- __sighandler_t sa_handler;
- /* Used if SA_SIGINFO is set. */
- void (*sa_sigaction) (int, siginfo_t *, void *);
- }
- __sigaction_handler;
-# define sa_handler __sigaction_handler.sa_handler
-# define sa_sigaction __sigaction_handler.sa_sigaction
+ union {
+ __sighandler_t sa_handler;
+ void (*sa_sigaction)(int, siginfo_t *, void *);
+ } __sigaction_handler;
+# define sa_handler __sigaction_handler.sa_handler
+# define sa_sigaction __sigaction_handler.sa_sigaction
#else
- __sighandler_t sa_handler;
+ __sighandler_t sa_handler;
#endif
-
- /* Additional set of signals to be blocked. */
- __sigset_t sa_mask;
-
- /* Special flags. */
- int sa_flags;
-
- /* Restore handler. */
- void (*sa_restorer) (void);
- };
+ unsigned long sa_flags;
+ void (*sa_restorer)(void);
+ sigset_t sa_mask;
+};
/* Bits in `sa_flags'. */
#define SA_NOCLDSTOP 1 /* Don't send SIGCHLD when children stop. */
diff --git a/libc/sysdeps/linux/common/bits/sigcontext.h b/libc/sysdeps/linux/common/bits/sigcontext.h
index 67dcf9498..8d4fd578f 100644
--- a/libc/sysdeps/linux/common/bits/sigcontext.h
+++ b/libc/sysdeps/linux/common/bits/sigcontext.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H
# error "Never use <bits/sigcontext.h> directly; include <signal.h> instead."
@@ -25,5 +24,8 @@
we need sigcontext. */
# define sigcontext_struct sigcontext
+# ifndef __user
+# define __user
+# endif
# include <asm/sigcontext.h>
#endif
diff --git a/libc/sysdeps/linux/common/bits/sigcontextinfo.h b/libc/sysdeps/linux/common/bits/sigcontextinfo.h
index 40305b488..40df940b2 100644
--- a/libc/sysdeps/linux/common/bits/sigcontextinfo.h
+++ b/libc/sysdeps/linux/common/bits/sigcontextinfo.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* In general we cannot provide any information. */
#define SIGCONTEXT struct sigcontext *
diff --git a/libc/sysdeps/linux/common/bits/siginfo.h b/libc/sysdeps/linux/common/bits/siginfo.h
index 4ce319dc9..724f756cd 100644
--- a/libc/sysdeps/linux/common/bits/siginfo.h
+++ b/libc/sysdeps/linux/common/bits/siginfo.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#if !defined _SIGNAL_H && !defined __need_siginfo_t \
&& !defined __need_sigevent_t
@@ -104,6 +103,14 @@ typedef struct siginfo
long int si_band; /* Band event for SIGPOLL. */
int si_fd;
} _sigpoll;
+
+ /* SIGSYS. */
+ struct
+ {
+ void *_call_addr; /* Calling user insn. */
+ int _syscall; /* Triggering system call number. */
+ unsigned int _arch; /* AUDIT_ARCH_* of syscall. */
+ } _sigsys;
} _sifields;
} siginfo_t;
@@ -122,6 +129,9 @@ typedef struct siginfo
# define si_addr _sifields._sigfault.si_addr
# define si_band _sifields._sigpoll.si_band
# define si_fd _sifields._sigpoll.si_fd
+# define si_call_addr _sifields._sigsys._call_addr
+# define si_syscall _sifields._sigsys._syscall
+# define si_arch _sifields._sigsys._arch
/* Values for `si_code'. Positive values are reserved for kernel-generated
diff --git a/libc/sysdeps/linux/common/bits/signalfd.h b/libc/sysdeps/linux/common/bits/signalfd.h
new file mode 100644
index 000000000..f2c0dde2f
--- /dev/null
+++ b/libc/sysdeps/linux/common/bits/signalfd.h
@@ -0,0 +1,29 @@
+/* Copyright (C) 2007-2012 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_SIGNALFD_H
+# error "Never use <bits/signalfd.h> directly; include <sys/signalfd.h> instead."
+#endif
+
+/* Flags for signalfd. */
+enum
+ {
+ SFD_CLOEXEC = 02000000,
+#define SFD_CLOEXEC SFD_CLOEXEC
+ SFD_NONBLOCK = 00004000
+#define SFD_NONBLOCK SFD_NONBLOCK
+ };
diff --git a/libc/sysdeps/linux/common/bits/signum.h b/libc/sysdeps/linux/common/bits/signum.h
index a18ac113a..8a0f3d075 100644
--- a/libc/sysdeps/linux/common/bits/signum.h
+++ b/libc/sysdeps/linux/common/bits/signum.h
@@ -13,23 +13,11 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifdef _SIGNAL_H
-/* Fake signal functions. */
-#define SIG_ERR ((__sighandler_t) -1) /* Error return. */
-#define SIG_DFL ((__sighandler_t) 0) /* Default action. */
-#define SIG_IGN ((__sighandler_t) 1) /* Ignore signal. */
-
-#ifdef __USE_UNIX98
-# define SIG_HOLD ((__sighandler_t) 2) /* Add signal to hold mask. */
-#endif
-
-
-/* Signals. */
#define SIGHUP 1 /* Hangup (POSIX). */
#define SIGINT 2 /* Interrupt (ANSI). */
#define SIGQUIT 3 /* Quit (POSIX). */
@@ -66,15 +54,4 @@
#define SIGSYS 31 /* Bad system call. */
#define SIGUNUSED 31
-#define _NSIG 65 /* Biggest signal number + 1
- (including real-time signals). */
-
-#define SIGRTMIN (__libc_current_sigrtmin ())
-#define SIGRTMAX (__libc_current_sigrtmax ())
-
-/* These are the hard limits of the kernel. These values should not be
- used directly at user level. */
-#define __SIGRTMIN 32
-#define __SIGRTMAX (_NSIG - 1)
-
#endif /* <signal.h> included. */
diff --git a/libc/sysdeps/linux/common/bits/sigset.h b/libc/sysdeps/linux/common/bits/sigset.h
index 7ccadda45..f220e8171 100644
--- a/libc/sysdeps/linux/common/bits/sigset.h
+++ b/libc/sysdeps/linux/common/bits/sigset.h
@@ -13,22 +13,32 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SIGSET_H_types
# define _SIGSET_H_types 1
typedef int __sig_atomic_t;
-/* A `sigset_t' has a bit for each signal. */
-
-# define _SIGSET_NWORDS (1024 / (8 * sizeof (unsigned long int)))
-typedef struct
- {
- unsigned long int __val[_SIGSET_NWORDS];
- } __sigset_t;
+/* A 'sigset_t' has a bit for each signal.
+ * glibc has space for 1024 signals (!), but most arches supported
+ * by Linux have 64 signals, and only MIPS has 128.
+ * There seems to be some historical baggage in sparc[64]
+ * where they might have (or had in the past) 32 signals only,
+ * I hope it's irrelevant now.
+ * Signal 0 does not exist, so we have signals 1..64, not 0..63.
+ * In uclibc, kernel and userspace sigset_t is always the same.
+ * BTW, struct sigaction is also the same on kernel and userspace side.
+ */
+#if defined(__mips__)
+# define _SIGSET_NWORDS (128 / (8 * sizeof (unsigned long)))
+#else
+# define _SIGSET_NWORDS (64 / (8 * sizeof (unsigned long)))
+#endif
+typedef struct {
+ unsigned long __val[_SIGSET_NWORDS];
+} __sigset_t;
#endif
@@ -42,84 +52,172 @@ typedef struct
#if !defined _SIGSET_H_fns && defined _SIGNAL_H
# define _SIGSET_H_fns 1
-# ifndef _EXTERN_INLINE
-# define _EXTERN_INLINE extern __inline
-# endif
-
/* Return a mask that includes the bit for SIG only. */
+/* Unsigned cast ensures shift/mask insns are used. */
# define __sigmask(sig) \
- (((unsigned long int) 1) << (((sig) - 1) % (8 * sizeof (unsigned long int))))
+ (((unsigned long) 1) << ((unsigned)((sig) - 1) % (8 * sizeof (unsigned long))))
/* Return the word index for SIG. */
-# define __sigword(sig) (((sig) - 1) / (8 * sizeof (unsigned long int)))
+# define __sigword(sig) ((unsigned)((sig) - 1) / (8 * sizeof (unsigned long)))
+
+/* gcc 4.3.1 is not clever enough to optimize for _SIGSET_NWORDS == 1 and 2,
+ * which are about the only values which can be there */
# if defined __GNUC__ && __GNUC__ >= 2
# define __sigemptyset(set) \
- (__extension__ ({ int __cnt = _SIGSET_NWORDS; \
- sigset_t *__set = (set); \
- while (--__cnt >= 0) __set->__val[__cnt] = 0; \
- 0; }))
+(__extension__ ({ \
+ sigset_t *__set = (set); \
+ if (_SIGSET_NWORDS <= 2) { \
+ __set->__val[0] = 0; \
+ if (_SIGSET_NWORDS == 2) \
+ __set->__val[1] = 0; \
+ } else { \
+ int __cnt = _SIGSET_NWORDS; \
+ while (--__cnt >= 0) __set->__val[__cnt] = 0; \
+ } \
+ 0; \
+}))
# define __sigfillset(set) \
- (__extension__ ({ int __cnt = _SIGSET_NWORDS; \
- sigset_t *__set = (set); \
- while (--__cnt >= 0) __set->__val[__cnt] = ~0UL; \
- 0; }))
+(__extension__ ({ \
+ sigset_t *__set = (set); \
+ if (_SIGSET_NWORDS <= 2) { \
+ __set->__val[0] = ~0UL; \
+ if (_SIGSET_NWORDS == 2) \
+ __set->__val[1] = ~0UL; \
+ } else { \
+ int __cnt = _SIGSET_NWORDS; \
+ while (--__cnt >= 0) __set->__val[__cnt] = ~0UL; \
+ } \
+ 0; \
+}))
# ifdef __USE_GNU
/* The POSIX does not specify for handling the whole signal set in one
command. This is often wanted and so we define three more functions
here. */
# define __sigisemptyset(set) \
- (__extension__ ({ int __cnt = _SIGSET_NWORDS; \
- const sigset_t *__set = (set); \
- int __ret = __set->__val[--__cnt]; \
- while (!__ret && --__cnt >= 0) \
- __ret = __set->__val[__cnt]; \
- __ret == 0; }))
+(__extension__ ({ \
+ long __ret; \
+ const sigset_t *__set = (set); \
+ if (_SIGSET_NWORDS == 1) { \
+ __ret = __set->__val[0]; \
+ } else if (_SIGSET_NWORDS == 2) { \
+ __ret = __set->__val[0] | __set->__val[1]; \
+ } else { \
+ int __cnt = _SIGSET_NWORDS; \
+ __ret = __set->__val[--__cnt]; \
+ while (!__ret && --__cnt >= 0) \
+ __ret = __set->__val[__cnt]; \
+ } \
+ __ret == 0; \
+}))
# define __sigandset(dest, left, right) \
- (__extension__ ({ int __cnt = _SIGSET_NWORDS; \
- sigset_t *__dest = (dest); \
- const sigset_t *__left = (left); \
- const sigset_t *__right = (right); \
- while (--__cnt >= 0) \
- __dest->__val[__cnt] = (__left->__val[__cnt] \
- & __right->__val[__cnt]); \
- 0; }))
+(__extension__ ({ \
+ sigset_t *__dest = (dest); \
+ const sigset_t *__left = (left); \
+ const sigset_t *__right = (right); \
+ if (_SIGSET_NWORDS <= 2) { \
+ __dest->__val[0] = __left->__val[0] & __right->__val[0];\
+ if (_SIGSET_NWORDS == 2) \
+ __dest->__val[1] = __left->__val[1] & __right->__val[1];\
+ } else { \
+ int __cnt = _SIGSET_NWORDS; \
+ while (--__cnt >= 0) \
+ __dest->__val[__cnt] = (__left->__val[__cnt] \
+ & __right->__val[__cnt]); \
+ } \
+ 0; \
+}))
# define __sigorset(dest, left, right) \
- (__extension__ ({ int __cnt = _SIGSET_NWORDS; \
- sigset_t *__dest = (dest); \
- const sigset_t *__left = (left); \
- const sigset_t *__right = (right); \
- while (--__cnt >= 0) \
- __dest->__val[__cnt] = (__left->__val[__cnt] \
- | __right->__val[__cnt]); \
- 0; }))
+(__extension__ ({ \
+ sigset_t *__dest = (dest); \
+ const sigset_t *__left = (left); \
+ const sigset_t *__right = (right); \
+ if (_SIGSET_NWORDS <= 2) { \
+ __dest->__val[0] = __left->__val[0] | __right->__val[0];\
+ if (_SIGSET_NWORDS == 2) \
+ __dest->__val[1] = __left->__val[1] | __right->__val[1];\
+ } else { \
+ int __cnt = _SIGSET_NWORDS; \
+ while (--__cnt >= 0) \
+ __dest->__val[__cnt] = (__left->__val[__cnt] \
+ | __right->__val[__cnt]); \
+ } \
+ 0; \
+}))
# endif
# endif
/* These functions needn't check for a bogus signal number -- error
checking is done in the non __ versions. */
-extern int __sigismember (__const __sigset_t *, int);
-extern int __sigaddset (__sigset_t *, int);
-extern int __sigdelset (__sigset_t *, int);
+# if !defined __USE_EXTERN_INLINES || defined __PROVIDE_OUT_OF_LINE_SIGSETFN
+extern int __sigismember (const __sigset_t *, int);
+libc_hidden_proto(__sigismember)
+extern void __sigaddset (__sigset_t *, int);
+libc_hidden_proto(__sigaddset)
+extern void __sigdelset (__sigset_t *, int);
+libc_hidden_proto(__sigdelset)
+# endif
# ifdef __USE_EXTERN_INLINES
-# define __SIGSETFN(NAME, BODY, CONST) \
- _EXTERN_INLINE int \
- NAME (CONST __sigset_t *__set, int __sig) \
- { \
- unsigned long int __mask = __sigmask (__sig); \
- unsigned long int __word = __sigword (__sig); \
- return BODY; \
- }
-
-__SIGSETFN (__sigismember, (__set->__val[__word] & __mask) ? 1 : 0, __const)
-__SIGSETFN (__sigaddset, ((__set->__val[__word] |= __mask), 0), )
-__SIGSETFN (__sigdelset, ((__set->__val[__word] &= ~__mask), 0), )
+# undef _EXTERN_INLINE
+# ifdef __PROVIDE_OUT_OF_LINE_SIGSETFN
+# define _EXTERN_INLINE
+# else /* normal case */
+ /* dropped extern below: otherwise every module with __USE_EXTERN_INLINES
+ * will have its own copy of out-of line function emitted. */
+# define _EXTERN_INLINE /*extern*/ __always_inline
+# endif
+# define __SIGSETFN(RET_TYPE, NAME, BODY, CONST) \
+_EXTERN_INLINE RET_TYPE \
+NAME (CONST __sigset_t *__set, int __sig) \
+{ \
+ unsigned long __mask = __sigmask (__sig); \
+ unsigned __word = __sigword (__sig); \
+ BODY; \
+}
+
+__SIGSETFN (int, __sigismember, return (__set->__val[__word] & __mask) ? 1 : 0,
+ const)
+__SIGSETFN (void, __sigaddset, (__set->__val[__word] |= __mask), )
+__SIGSETFN (void, __sigdelset, (__set->__val[__word] &= ~__mask), )
# undef __SIGSETFN
# endif
+# ifdef _LIBC
+/* It's far too much PITA to __USE_EXTERN_INLINES from within libc.
+ * Especially since we want to inline only calls with const sig,
+ * but __USE_EXTERN_INLINES will inline all calls!
+ */
+static __always_inline unsigned long
+const_sigismember(const __sigset_t *set, int sig)
+{
+ unsigned long mask = __sigmask(sig);
+ unsigned word = __sigword(sig);
+ return (set->__val[word] & mask);
+}
+# define __sigismember(set, sig) \
+ (__builtin_constant_p(sig) ? (const_sigismember(set, sig) != 0) : __sigismember(set, sig))
+static __always_inline void
+const_sigaddset(__sigset_t *set, int sig)
+{
+ unsigned long mask = __sigmask(sig);
+ unsigned word = __sigword(sig);
+ set->__val[word] |= mask;
+}
+# define __sigaddset(set, sig) \
+ (__builtin_constant_p(sig) ? const_sigaddset(set, sig) : __sigaddset(set, sig))
+static __always_inline void
+const_sigdelset(__sigset_t *set, int sig)
+{
+ unsigned long mask = __sigmask(sig);
+ unsigned word = __sigword(sig);
+ set->__val[word] &= ~mask;
+}
+# define __sigdelset(set, sig) \
+ (__builtin_constant_p(sig) ? const_sigdelset(set, sig) : __sigdelset(set, sig))
+# endif
#endif /* ! _SIGSET_H_fns. */
diff --git a/libc/sysdeps/linux/common/bits/sigstack.h b/libc/sysdeps/linux/common/bits/sigstack.h
index 7f260367b..ee25a6b32 100644
--- a/libc/sysdeps/linux/common/bits/sigstack.h
+++ b/libc/sysdeps/linux/common/bits/sigstack.h
@@ -13,21 +13,22 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SIGNAL_H
# error "Never include this file directly. Use <signal.h> instead"
#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..643618aa4 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
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
#ifndef _BITS_SIGTHREAD_H
#define _BITS_SIGTHREAD_H 1
@@ -29,10 +28,16 @@
/* 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,
+ 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;
+#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/sockaddr.h b/libc/sysdeps/linux/common/bits/sockaddr.h
index 3e1d1312d..066c3e935 100644
--- a/libc/sysdeps/linux/common/bits/sockaddr.h
+++ b/libc/sysdeps/linux/common/bits/sockaddr.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/*
* Never include this file directly; use <sys/socket.h> instead.
diff --git a/libc/sysdeps/linux/common/bits/socket.h b/libc/sysdeps/linux/common/bits/socket.h
index 2f3dc797b..4ea13111a 100644
--- a/libc/sysdeps/linux/common/bits/socket.h
+++ b/libc/sysdeps/linux/common/bits/socket.h
@@ -1,5 +1,6 @@
/* System-specific socket constants and types. Linux version.
- Copyright (C) 1991,1992,1994-2001,2004,2006 Free Software Foundation, Inc.
+ Copyright (C) 1991,1992,1994-2001,2004,2006-2012
+ 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
@@ -13,19 +14,17 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef __BITS_SOCKET_H
#define __BITS_SOCKET_H
-#if !defined _SYS_SOCKET_H && !defined _NETINET_IN_H
+#ifndef _SYS_SOCKET_H
# error "Never include <bits/socket.h> directly; use <sys/socket.h> instead."
#endif
#define __need_size_t
-#define __need_NULL
#include <stddef.h>
#include <limits.h>
@@ -37,27 +36,8 @@ typedef __socklen_t socklen_t;
# define __socklen_t_defined
#endif
-/* Types of sockets. */
-enum __socket_type
-{
- SOCK_STREAM = 1, /* Sequenced, reliable, connection-based
- byte streams. */
-#define SOCK_STREAM SOCK_STREAM
- SOCK_DGRAM = 2, /* Connectionless, unreliable datagrams
- of fixed maximum length. */
-#define SOCK_DGRAM SOCK_DGRAM
- SOCK_RAW = 3, /* Raw protocol interface. */
-#define SOCK_RAW SOCK_RAW
- SOCK_RDM = 4, /* Reliably-delivered messages. */
-#define SOCK_RDM SOCK_RDM
- SOCK_SEQPACKET = 5, /* Sequenced, reliable, connection-based,
- datagrams of fixed maximum length. */
-#define SOCK_SEQPACKET SOCK_SEQPACKET
- SOCK_PACKET = 10 /* Linux specific way of getting packets
- at the dev level. For writing rarp and
- other similar things on the user level. */
-#define SOCK_PACKET SOCK_PACKET
-};
+/* Get the architecture-dependent definition of enum __socket_type. */
+#include <bits/socket_type.h>
/* Protocol families. */
#define PF_UNSPEC 0 /* Unspecified. */
@@ -84,12 +64,24 @@ enum __socket_type
#define PF_ASH 18 /* Ash. */
#define PF_ECONET 19 /* Acorn Econet. */
#define PF_ATMSVC 20 /* ATM SVCs. */
+#define PF_RDS 21 /* RDS sockets. */
#define PF_SNA 22 /* Linux SNA Project */
#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_NFC 39 /* NFC sockets. */
+#define PF_MAX 40 /* For now.. */
/* Address families. */
#define AF_UNSPEC PF_UNSPEC
@@ -116,11 +108,23 @@ enum __socket_type
#define AF_ASH PF_ASH
#define AF_ECONET PF_ECONET
#define AF_ATMSVC PF_ATMSVC
+#define AF_RDS PF_RDS
#define AF_SNA PF_SNA
#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_NFC PF_NFC
#define AF_MAX PF_MAX
/* Socket level values. Others are defined in the appropriate headers.
@@ -205,8 +209,14 @@ enum
#define MSG_ERRQUEUE MSG_ERRQUEUE
MSG_NOSIGNAL = 0x4000, /* Do not generate SIGPIPE. */
#define MSG_NOSIGNAL MSG_NOSIGNAL
- MSG_MORE = 0x8000 /* Sender will send more. */
+ MSG_MORE = 0x8000, /* Sender will send more. */
#define MSG_MORE MSG_MORE
+ MSG_WAITFORONE = 0x10000, /* Wait for at least one packet to return.*/
+#define MSG_WAITFORONE MSG_WAITFORONE
+ MSG_CMSG_CLOEXEC = 0x40000000 /* Set close_on_exit for file
+ descriptor received through
+ SCM_RIGHTS. */
+#define MSG_CMSG_CLOEXEC MSG_CMSG_CLOEXEC
};
@@ -260,7 +270,7 @@ struct cmsghdr
#define CMSG_NXTHDR(mhdr, cmsg) __cmsg_nxthdr (mhdr, cmsg)
#define CMSG_FIRSTHDR(mhdr) \
((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) \
- ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) NULL)
+ ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) 0)
#define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) \
& (size_t) ~(sizeof (size_t) - 1))
#define CMSG_SPACE(len) (CMSG_ALIGN (len) \
@@ -269,16 +279,17 @@ struct cmsghdr
extern struct cmsghdr *__cmsg_nxthdr (struct msghdr *__mhdr,
struct cmsghdr *__cmsg) __THROW;
+libc_hidden_proto(__cmsg_nxthdr)
#ifdef __USE_EXTERN_INLINES
# ifndef _EXTERN_INLINE
-# define _EXTERN_INLINE extern __inline
+# define _EXTERN_INLINE __extern_inline
# endif
_EXTERN_INLINE struct cmsghdr *
__NTH (__cmsg_nxthdr (struct msghdr *__mhdr, struct cmsghdr *__cmsg))
{
if ((size_t) __cmsg->cmsg_len < sizeof (struct cmsghdr))
/* The kernel header does this so there may be a reason. */
- return 0;
+ return (struct cmsghdr *) 0;
__cmsg = (struct cmsghdr *) ((unsigned char *) __cmsg
+ CMSG_ALIGN (__cmsg->cmsg_len));
@@ -287,10 +298,10 @@ __NTH (__cmsg_nxthdr (struct msghdr *__mhdr, struct cmsghdr *__cmsg))
|| ((unsigned char *) __cmsg + CMSG_ALIGN (__cmsg->cmsg_len)
> ((unsigned char *) __mhdr->msg_control + __mhdr->msg_controllen)))
/* No more entries. */
- return 0;
+ return (struct cmsghdr *) 0;
return __cmsg;
}
-#endif /* Use `extern inline'. */
+#endif /* Use `__extern_inline'. */
/* Socket level message types. This must match the definitions in
<linux/socket.h>. */
@@ -298,23 +309,30 @@ enum
{
SCM_RIGHTS = 0x01 /* Transfer file descriptors. */
#define SCM_RIGHTS SCM_RIGHTS
-#ifdef __USE_BSD
+#ifdef __USE_GNU
, SCM_CREDENTIALS = 0x02 /* Credentials passing. */
# define SCM_CREDENTIALS SCM_CREDENTIALS
#endif
};
+#ifdef __USE_GNU
/* User visible structure for SCM_CREDENTIALS message */
-
struct ucred
{
pid_t pid; /* PID of sending process. */
uid_t uid; /* UID of sending process. */
gid_t gid; /* GID of sending process. */
};
+#endif
/* Get socket manipulation related informations from kernel headers. */
+#ifndef __GLIBC__
+#define __GLIBC__ 2
+#include <asm/socket.h>
+#undef __GLIBC__
+#else
#include <asm/socket.h>
+#endif
/* Structure used to manipulate the SO_LINGER option. */
diff --git a/libc/sysdeps/linux/common/bits/socket_type.h b/libc/sysdeps/linux/common/bits/socket_type.h
new file mode 100644
index 000000000..65436b087
--- /dev/null
+++ b/libc/sysdeps/linux/common/bits/socket_type.h
@@ -0,0 +1,54 @@
+/* Define enum __socket_type for generic Linux.
+ Copyright (C) 1991-2012 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_SOCKET_H
+# error "Never include <bits/socket_type.h> directly; use <sys/socket.h> instead."
+#endif
+
+/* Types of sockets. */
+enum __socket_type
+{
+ SOCK_STREAM = 1, /* Sequenced, reliable, connection-based
+ byte streams. */
+#define SOCK_STREAM SOCK_STREAM
+ SOCK_DGRAM = 2, /* Connectionless, unreliable datagrams
+ of fixed maximum length. */
+#define SOCK_DGRAM SOCK_DGRAM
+ SOCK_RAW = 3, /* Raw protocol interface. */
+#define SOCK_RAW SOCK_RAW
+ SOCK_RDM = 4, /* Reliably-delivered messages. */
+#define SOCK_RDM SOCK_RDM
+ SOCK_SEQPACKET = 5, /* Sequenced, reliable, connection-based,
+ datagrams of fixed maximum length. */
+#define SOCK_SEQPACKET SOCK_SEQPACKET
+ SOCK_DCCP = 6, /* Datagram Congestion Control Protocol. */
+#define SOCK_DCCP SOCK_DCCP
+ SOCK_PACKET = 10, /* Linux specific way of getting packets
+ at the dev level. For writing rarp and
+ other similar things on the user level. */
+#define SOCK_PACKET SOCK_PACKET
+
+ /* Flags to be ORed into the type parameter of socket and socketpair. */
+
+ SOCK_CLOEXEC = 02000000, /* Atomically set close-on-exec flag for the
+ new descriptor(s). */
+#define SOCK_CLOEXEC SOCK_CLOEXEC
+ SOCK_NONBLOCK = 00004000 /* Atomically mark descriptor(s) as
+ non-blocking. */
+#define SOCK_NONBLOCK SOCK_NONBLOCK
+};
diff --git a/libc/sysdeps/linux/common/bits/stab.def b/libc/sysdeps/linux/common/bits/stab.def
index 3d54774cf..8a2b8f39d 100644
--- a/libc/sysdeps/linux/common/bits/stab.def
+++ b/libc/sysdeps/linux/common/bits/stab.def
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* This contains contribution from Cygnus Support. */
diff --git a/libc/sysdeps/linux/common/bits/stackinfo.h b/libc/sysdeps/linux/common/bits/stackinfo.h
index 1ed7b9503..1f996bea8 100644
--- a/libc/sysdeps/linux/common/bits/stackinfo.h
+++ b/libc/sysdeps/linux/common/bits/stackinfo.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* This file contains a bit of information about the stack allocation
of the processor. Since there is no general truth we can't say
diff --git a/libc/sysdeps/linux/common/bits/stat.h b/libc/sysdeps/linux/common/bits/stat.h
index bd5aae267..19e2f4e13 100644
--- a/libc/sysdeps/linux/common/bits/stat.h
+++ b/libc/sysdeps/linux/common/bits/stat.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 1995-2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 1995-2001, 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
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_STAT_H
# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
@@ -62,7 +61,7 @@ struct stat
#else
__blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
#endif
-#if 0 /*def __USE_MISC*/
+#ifdef __USE_MISC
/* Nanosecond resolution timestamps are stored in a format
equivalent to 'struct timespec'. This is the type used
whenever possible but the Unix namespace rules do not allow the
@@ -108,7 +107,7 @@ struct stat64
__blksize_t st_blksize; /* Optimal block size for I/O. */
__blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
-#if 0 /*def __USE_MISC*/
+#ifdef __USE_MISC
/* Nanosecond resolution timestamps are stored in a format
equivalent to 'struct timespec'. This is the type used
whenever possible but the Unix namespace rules do not allow the
@@ -163,3 +162,8 @@ struct stat64
#define __S_IREAD 0400 /* Read by owner. */
#define __S_IWRITE 0200 /* Write by owner. */
#define __S_IEXEC 0100 /* Execute by owner. */
+
+#ifdef __USE_ATFILE
+# define UTIME_NOW ((1l << 30) - 1l)
+# define UTIME_OMIT ((1l << 30) - 2l)
+#endif
diff --git a/libc/sysdeps/linux/common/bits/statfs.h b/libc/sysdeps/linux/common/bits/statfs.h
index 0e27865e8..bb780a81e 100644
--- a/libc/sysdeps/linux/common/bits/statfs.h
+++ b/libc/sysdeps/linux/common/bits/statfs.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_STATFS_H
# error "Never include <bits/statfs.h> directly; use <sys/statfs.h> instead."
diff --git a/libc/sysdeps/linux/common/bits/statvfs.h b/libc/sysdeps/linux/common/bits/statvfs.h
index cca0871ac..4b3fc5733 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
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_STATVFS_H
# error "Never include <bits/statvfs.h> directly; use <sys/statvfs.h> instead."
@@ -101,7 +100,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/stdio.h b/libc/sysdeps/linux/common/bits/stdio.h
index d0ba46308..9485857e8 100644
--- a/libc/sysdeps/linux/common/bits/stdio.h
+++ b/libc/sysdeps/linux/common/bits/stdio.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _STDIO_H
# error "Never include <bits/stdio.h> directly; use <stdio.h> instead."
diff --git a/libc/sysdeps/linux/common/bits/stdio_lim.h b/libc/sysdeps/linux/common/bits/stdio_lim.h
index c35ee601b..20b68a258 100644
--- a/libc/sysdeps/linux/common/bits/stdio_lim.h
+++ b/libc/sysdeps/linux/common/bits/stdio_lim.h
@@ -12,16 +12,17 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#if !defined _STDIO_H && !defined __need_FOPEN_MAX && !defined __need_IOV_MAX
# error "Never include <bits/stdio_lim.h> directly; use <stdio.h> instead."
#endif
#ifdef _STDIO_H
-# define L_tmpnam 20
+# ifdef __UCLIBC_SUSV4_LEGACY__
+# define L_tmpnam 20
+# endif
# define TMP_MAX 238328
# define FILENAME_MAX 4095
diff --git a/libc/sysdeps/linux/common/bits/syscalls-common.h b/libc/sysdeps/linux/common/bits/syscalls-common.h
new file mode 100644
index 000000000..86fe26c50
--- /dev/null
+++ b/libc/sysdeps/linux/common/bits/syscalls-common.h
@@ -0,0 +1,119 @@
+/*
+ * Common syscall type defines
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#ifndef _SYSCALLS_COMMON_H
+#define _SYSCALLS_COMMON_H 1
+
+#ifndef _SYSCALL_H
+# error "Never use <bits/syscalls-common.h> directly; include <sys/syscall.h> instead."
+#endif
+
+#ifndef SYS_ify
+# define SYS_ify(syscall_name) (__NR_##syscall_name)
+#endif
+
+#ifndef __ASSEMBLER__
+
+#include <errno.h>
+
+#ifndef INTERNAL_SYSCALL_DECL
+# define INTERNAL_SYSCALL_DECL(err) do { } while (0)
+#endif
+#ifndef INTERNAL_SYSCALL_ERROR_P
+# define INTERNAL_SYSCALL_ERROR_P(val, err) ((unsigned long)val >= (unsigned long)(-4095))
+#endif
+#ifndef INTERNAL_SYSCALL_ERRNO
+# define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
+#endif
+
+/* Define a macro which expands into the inline wrapper code for a system call */
+#ifndef INLINE_SYSCALL
+# define INLINE_SYSCALL(name, nr, args...) INLINE_SYSCALL_NCS(__NR_##name, nr, args)
+#endif
+#ifndef INLINE_SYSCALL_NOERR
+# define INLINE_SYSCALL_NOERR(name, nr, args...) INLINE_SYSCALL_NOERR_NCS(__NR_##name, nr, args)
+#endif
+
+/* Just like INLINE_SYSCALL(), but take a non-constant syscall (NCS) argument */
+#ifndef INLINE_SYSCALL_NCS
+# define INLINE_SYSCALL_NCS(num, nr, args...) \
+(__extension__ \
+ ({ \
+ INTERNAL_SYSCALL_DECL(__err); \
+ (__extension__ \
+ ({ \
+ long __res = INTERNAL_SYSCALL_NCS(num, __err, nr, args); \
+ if (unlikely(INTERNAL_SYSCALL_ERROR_P(__res, __err))) { \
+ __set_errno(INTERNAL_SYSCALL_ERRNO(__res, __err)); \
+ __res = -1L; \
+ } \
+ __res; \
+ }) \
+ ); \
+ }) \
+)
+#endif
+#ifndef INLINE_SYSCALL_NOERR_NCS
+# define INLINE_SYSCALL_NOERR_NCS(num, nr, args...) \
+({ \
+ INTERNAL_SYSCALL_DECL(__err); \
+ long __res = INTERNAL_SYSCALL_NCS(num, __err, nr, args); \
+ __res; \
+})
+#endif
+
+/* No point in forcing people to implement both when they only need one */
+#ifndef INTERNAL_SYSCALL
+# define INTERNAL_SYSCALL(name, err, nr, args...) INTERNAL_SYSCALL_NCS(__NR_##name, err, nr, args)
+#endif
+
+#ifndef INTERNAL_SYSCALL_NCS
+# error your port needs to define INTERNAL_SYSCALL_NCS in bits/syscalls.h
+#endif
+
+#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
diff --git a/libc/sysdeps/linux/common/bits/syscalls.h b/libc/sysdeps/linux/common/bits/syscalls.h
index ceba568e5..03d08d1d3 100644
--- a/libc/sysdeps/linux/common/bits/syscalls.h
+++ b/libc/sysdeps/linux/common/bits/syscalls.h
@@ -5,4 +5,5 @@
* forbidden. Don't do it. It is bad for you.
*/
-#error You have not provided architecture specific _syscall[0-6] macros
+#error You have not provided architecture specific bits/syscalls.h
+#error You should need to define only INTERNAL_SYSCALL_NCS
diff --git a/libc/sysdeps/linux/common/bits/termios.h b/libc/sysdeps/linux/common/bits/termios.h
index b648d8000..10f089949 100644
--- a/libc/sysdeps/linux/common/bits/termios.h
+++ b/libc/sysdeps/linux/common/bits/termios.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _TERMIOS_H
# error "Never include <bits/termios.h> directly; use <termios.h> instead."
diff --git a/libc/sysdeps/linux/common/bits/time.h b/libc/sysdeps/linux/common/bits/time.h
index 7ed54bfa7..c4269ae47 100644
--- a/libc/sysdeps/linux/common/bits/time.h
+++ b/libc/sysdeps/linux/common/bits/time.h
@@ -1,5 +1,5 @@
-/* System-dependent timing definitions. Generic version.
- Copyright (C) 1996,1997,1999-2002,2003 Free Software Foundation, Inc.
+/* System-dependent timing definitions. Linux version.
+ Copyright (C) 1996-2014 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
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/*
* Never include this file directly; use <time.h> instead.
@@ -54,6 +53,18 @@
# define CLOCK_PROCESS_CPUTIME_ID 2
/* Thread-specific CPU-time clock. */
# define CLOCK_THREAD_CPUTIME_ID 3
+/* Monotonic system-wide clock, not adjusted for frequency scaling. */
+# define CLOCK_MONOTONIC_RAW 4
+/* Identifier for system-wide realtime clock, updated only on ticks. */
+# define CLOCK_REALTIME_COARSE 5
+/* Monotonic system-wide clock, updated only on ticks. */
+# define CLOCK_MONOTONIC_COARSE 6
+/* Monotonic system-wide clock that includes time spent in suspension. */
+# define CLOCK_BOOTTIME 7
+/* Like CLOCK_REALTIME but also wakes suspended system. */
+# define CLOCK_REALTIME_ALARM 8
+/* Like CLOCK_BOOTTIME but also wakes suspended system. */
+# define CLOCK_BOOTTIME_ALARM 9
/* Flag to indicate time is absolute. */
# define TIMER_ABSTIME 1
diff --git a/libc/sysdeps/linux/common/bits/timerfd.h b/libc/sysdeps/linux/common/bits/timerfd.h
new file mode 100644
index 000000000..93e8c76fb
--- /dev/null
+++ b/libc/sysdeps/linux/common/bits/timerfd.h
@@ -0,0 +1,29 @@
+/* Copyright (C) 2008-2012 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_TIMERFD_H
+# error "Never use <bits/timerfd.h> directly; include <sys/timerfd.h> instead."
+#endif
+
+/* Bits to be set in the FLAGS parameter of `timerfd_create'. */
+enum
+ {
+ TFD_CLOEXEC = 02000000,
+#define TFD_CLOEXEC TFD_CLOEXEC
+ TFD_NONBLOCK = 00004000
+#define TFD_NONBLOCK TFD_NONBLOCK
+ };
diff --git a/libc/sysdeps/linux/common/bits/types.h b/libc/sysdeps/linux/common/bits/types.h
index 755af2ec9..9d72d45e3 100644
--- a/libc/sysdeps/linux/common/bits/types.h
+++ b/libc/sysdeps/linux/common/bits/types.h
@@ -1,5 +1,5 @@
/* bits/types.h -- definitions of __*_t types underlying *_t types.
- Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2005, 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
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/*
* Never include this file directly; use <sys/types.h> instead.
@@ -27,9 +26,9 @@
#include <features.h>
#include <bits/wordsize.h>
-#define __need_size_t
-#include <stddef.h>
+#ifdef _LIBC
#include <bits/kernel_types.h>
+#endif
/* Convenience types. */
typedef unsigned char __u_char;
@@ -47,7 +46,7 @@ typedef unsigned int __uint32_t;
#if __WORDSIZE == 64
typedef signed long int __int64_t;
typedef unsigned long int __uint64_t;
-#elif defined(__GNUC__)
+#elif defined(__GNUC__) || defined __ICC || defined __TenDRA__
__extension__ typedef signed long long int __int64_t;
__extension__ typedef unsigned long long int __uint64_t;
#endif
@@ -56,7 +55,7 @@ __extension__ typedef unsigned long long int __uint64_t;
#if __WORDSIZE == 64
typedef long int __quad_t;
typedef unsigned long int __u_quad_t;
-#elif defined(__GNUC__)
+#elif defined(__GNUC__) || defined __ICC || defined __TenDRA__
__extension__ typedef long long int __quad_t;
__extension__ typedef unsigned long long int __u_quad_t;
#else
@@ -130,7 +129,7 @@ typedef struct
/* No need to mark the typedef with __extension__. */
# define __STD_TYPE typedef
#else
-# error
+# error your machine is neither 32 bit or 64 bit ... it must be magical
#endif
#include <bits/typesizes.h> /* Defines __*_T_TYPE macros. */
@@ -189,6 +188,10 @@ typedef __off64_t __loff_t; /* Type of file sizes and offsets (LFS). */
typedef __quad_t *__qaddr_t;
typedef char *__caddr_t;
+/* Used in XTI. */
+typedef long int __t_scalar_t;
+typedef unsigned long int __t_uscalar_t;
+
/* Duplicates info from stdint.h but this is used in unistd.h. */
__STD_TYPE __SWORD_TYPE __intptr_t;
@@ -198,12 +201,4 @@ __STD_TYPE __U32_TYPE __socklen_t;
#undef __STD_TYPE
-/* Used in `struct shmid_ds'. */
-typedef __kernel_ipc_pid_t __ipc_pid_t;
-
-/* Now add the thread types. */
-#if defined __UCLIBC_HAS_THREADS__ && (defined __USE_POSIX199506 || defined __USE_UNIX98)
-# include <bits/pthreadtypes.h>
-#endif
-
#endif /* bits/types.h */
diff --git a/libc/sysdeps/linux/common/bits/typesizes.h b/libc/sysdeps/linux/common/bits/typesizes.h
index e9226c417..e1c5a27bb 100644
--- a/libc/sysdeps/linux/common/bits/typesizes.h
+++ b/libc/sysdeps/linux/common/bits/typesizes.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _BITS_TYPES_H
# error "Never include <bits/typesizes.h> directly; use <sys/types.h> instead."
diff --git a/libc/sysdeps/linux/common/bits/uClibc_alloc.h b/libc/sysdeps/linux/common/bits/uClibc_alloc.h
new file mode 100644
index 000000000..6a70d27b7
--- /dev/null
+++ b/libc/sysdeps/linux/common/bits/uClibc_alloc.h
@@ -0,0 +1,26 @@
+/*
+ * Macros to transparently switch between the stack and heap for large
+ * allocations. The former is useful on MMU systems as it results in
+ * smaller code, but the latter is required on NoMMU systems. This is
+ * due to small stacks that cannot grow and so doing large allocs will
+ * cause a stack overflow.
+ *
+ * Copyright (C) 2010 Mike Frysinger <vapier@gentoo.org>
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#ifndef _UCLIBC_ALLOC_H
+#define _UCLIBC_ALLOC_H
+
+#include <alloca.h>
+#include <stdlib.h>
+
+#ifdef __ARCH_USE_MMU__
+# define stack_heap_alloc(x) alloca(x)
+# define stack_heap_free(x) do { if (0) free(x); } while (0)
+#else
+# define stack_heap_alloc(x) malloc(x)
+# define stack_heap_free(x) free(x)
+#endif
+
+#endif
diff --git a/libc/sysdeps/linux/common/bits/uClibc_arch_features.h b/libc/sysdeps/linux/common/bits/uClibc_arch_features.h
index 66186edbb..37c7ceb60 100644
--- a/libc/sysdeps/linux/common/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/common/bits/uClibc_arch_features.h
@@ -14,8 +14,8 @@
/* can your target use syscall6() for mmap ? */
#undef __UCLIBC_MMAP_HAS_6_ARGS__
-/* does your target use syscall4() for truncate64 ? (32bit arches only) */
-#undef __UCLIBC_TRUNCATE64_HAS_4_ARGS__
+/* does your target align 64bit values in register pairs ? (32bit arches only) */
+#undef __UCLIBC_SYSCALL_ALIGN_64BIT__
/* does your target have a broken create_module() ? */
#undef __UCLIBC_BROKEN_CREATE_MODULE__
@@ -26,19 +26,19 @@
/* 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 */
+#undef __UCLIBC_ASM_LINE_SEP__
+
#endif /* _BITS_UCLIBC_ARCH_FEATURES_H */
diff --git a/libc/sysdeps/linux/common/bits/uClibc_charclass.h b/libc/sysdeps/linux/common/bits/uClibc_charclass.h
new file mode 100644
index 000000000..50df539b9
--- /dev/null
+++ b/libc/sysdeps/linux/common/bits/uClibc_charclass.h
@@ -0,0 +1,40 @@
+/* Copyright (C) 2008 Denys Vlasenko <vda.linux@googlemail.com>
+ *
+ * This 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.
+ */
+
+#ifndef _BITS_UCLIBC_CHARCLASS_H
+#define _BITS_UCLIBC_CHARCLASS_H
+
+/* Taking advantage of the C99 mutual-exclusion guarantees for the various
+ * (w)ctype classes, including the descriptions of printing and control
+ * (w)chars, we can place each in one of the following mutually-exlusive
+ * subsets. Since there are less than 16, we can store the data for
+ * each (w)chars in a nibble. In contrast, glibc uses an unsigned int
+ * per (w)char, with one bit flag for each is* type. While this allows
+ * a simple '&' operation to determine the type vs. a range test and a
+ * little special handling for the "blank" and "xdigit" types in my
+ * approach, it also uses 8 times the space for the tables on the typical
+ * 32-bit archs we supported.*/
+enum {
+ __CTYPE_unclassified = 0,
+ __CTYPE_alpha_nonupper_nonlower,
+ __CTYPE_alpha_lower,
+ __CTYPE_alpha_upper_lower,
+ __CTYPE_alpha_upper,
+ __CTYPE_digit,
+ __CTYPE_punct,
+ __CTYPE_graph,
+ __CTYPE_print_space_nonblank,
+ __CTYPE_print_space_blank,
+ __CTYPE_space_nonblank_noncntrl,
+ __CTYPE_space_blank_noncntrl,
+ __CTYPE_cntrl_space_nonblank,
+ __CTYPE_cntrl_space_blank,
+ __CTYPE_cntrl_nonspace
+};
+
+#endif
diff --git a/libc/sysdeps/linux/common/bits/uClibc_ctype.h b/libc/sysdeps/linux/common/bits/uClibc_ctype.h
index 0b02c5dbf..03110e001 100644
--- a/libc/sysdeps/linux/common/bits/uClibc_ctype.h
+++ b/libc/sysdeps/linux/common/bits/uClibc_ctype.h
@@ -11,9 +11,8 @@
* 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.
+ * License along with the GNU C Library; see the file COPYING.LIB. If
+ * not, see <http://www.gnu.org/licenses/>.
*/
/* ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION!
@@ -31,57 +30,15 @@
#error Always include <{w}ctype.h> rather than <bits/uClibc_ctype.h>
#endif
-#ifndef _BITS_CTYPE_H
-#define _BITS_CTYPE_H
+#ifndef _BITS_UCLIBC_CTYPE_H
+#define _BITS_UCLIBC_CTYPE_H
#ifdef __UCLIBC_GEN_LOCALE
+/* We are in extra/locale/gen_XXX tools build */
-/* Taking advantage of the C99 mutual-exclusion guarantees for the various
- * (w)ctype classes, including the descriptions of printing and control
- * (w)chars, we can place each in one of the following mutually-exlusive
- * subsets. Since there are less than 16, we can store the data for
- * each (w)chars in a nibble. In contrast, glibc uses an unsigned int
- * per (w)char, with one bit flag for each is* type. While this allows
- * a simple '&' operation to determine the type vs. a range test and a
- * little special handling for the "blank" and "xdigit" types in my
- * approach, it also uses 8 times the space for the tables on the typical
- * 32-bit archs we supported.*/
-enum {
- __CTYPE_unclassified = 0,
- __CTYPE_alpha_nonupper_nonlower,
- __CTYPE_alpha_lower,
- __CTYPE_alpha_upper_lower,
- __CTYPE_alpha_upper,
- __CTYPE_digit,
- __CTYPE_punct,
- __CTYPE_graph,
- __CTYPE_print_space_nonblank,
- __CTYPE_print_space_blank,
- __CTYPE_space_nonblank_noncntrl,
- __CTYPE_space_blank_noncntrl,
- __CTYPE_cntrl_space_nonblank,
- __CTYPE_cntrl_space_blank,
- __CTYPE_cntrl_nonspace
-};
+#include "uClibc_charclass.h"
-/* Some macros that test for various (w)ctype classes when passed one of the
- * designator values enumerated above. */
-#define __CTYPE_isalnum(D) ((unsigned int)(D-1) <= (__CTYPE_digit-1))
-#define __CTYPE_isalpha(D) ((unsigned int)(D-1) <= (__CTYPE_alpha_upper-1))
-#define __CTYPE_isblank(D) \
- ((((unsigned int)(D - __CTYPE_print_space_nonblank)) <= 5) && (D & 1))
-#define __CTYPE_iscntrl(D) (((unsigned int)(D - __CTYPE_cntrl_space_nonblank)) <= 2)
-#define __CTYPE_isdigit(D) (D == __CTYPE_digit)
-#define __CTYPE_isgraph(D) ((unsigned int)(D-1) <= (__CTYPE_graph-1))
-#define __CTYPE_islower(D) (((unsigned int)(D - __CTYPE_alpha_lower)) <= 1)
-#define __CTYPE_isprint(D) ((unsigned int)(D-1) <= (__CTYPE_print_space_blank-1))
-#define __CTYPE_ispunct(D) (D == __CTYPE_punct)
-#define __CTYPE_isspace(D) (((unsigned int)(D - __CTYPE_print_space_nonblank)) <= 5)
-#define __CTYPE_isupper(D) (((unsigned int)(D - __CTYPE_alpha_upper_lower)) <= 1)
-/* #define __CTYPE_isxdigit(D) -- isxdigit is untestable this way.
- * But that's ok as isxdigit() (and isdigit() too) are locale-invariant. */
-
-#else /* __UCLIBC_GEN_LOCALE *****************************************/
+#else
/* Define some ctype macros valid for the C/POSIX locale. */
@@ -128,7 +85,7 @@ enum {
: (((unsigned int)((c) - 0x21)) <= (0x7e - 0x21))))
#define __C_isgraph(c) \
((sizeof(c) == sizeof(char)) \
- ? (((unsigned int)((c) - 0x21)) <= (0x7e - 0x21)) \
+ ? (((unsigned char)((c) - 0x21)) <= (0x7e - 0x21)) \
: (((unsigned int)((c) - 0x21)) <= (0x7e - 0x21)))
#define __C_tolower(c) (__C_isupper(c) ? ((c) | 0x20) : (c))
@@ -137,143 +94,105 @@ enum {
/**********************************************************************/
__BEGIN_DECLS
-extern int isalnum(int c) __THROW;
-extern int isalpha(int c) __THROW;
-#ifdef __USE_ISOC99
-extern int isblank(int c) __THROW;
-#endif
-extern int iscntrl(int c) __THROW;
-extern int isdigit(int c) __THROW;
-extern int isgraph(int c) __THROW;
-extern int islower(int c) __THROW;
-extern int isprint(int c) __THROW;
-extern int ispunct(int c) __THROW;
-extern int isspace(int c) __THROW;
-extern int isupper(int c) __THROW;
-extern int isxdigit(int c) __THROW;
-
-extern int tolower(int c) __THROW;
-extern int toupper(int c) __THROW;
-
-#if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN
-extern int isascii(int c) __THROW;
-extern int toascii(int c) __THROW;
+#ifdef _LIBC
+/* These are uClibc-specific. */
+# define __isdigit_char(c) ((unsigned char)((c) - '0') <= 9)
+# define __isdigit_int(c) ((unsigned int)((c) - '0') <= 9)
#endif
-#if defined _LIBC && (defined NOT_IN_libc || defined IS_IN_libc)
-/* isdigit() is really locale-invariant, so provide some small fast macros.
- * These are uClibc-specific. */
-#define __isdigit_char(C) (((unsigned char)((C) - '0')) <= 9)
-#define __isdigit_int(C) (((unsigned int)((C) - '0')) <= 9)
-#endif
-
-/* Next, some ctype macros which are valid for all supported locales. */
-/* WARNING: isspace and isblank need to be reverified if more 8-bit codesets
- * are added!!! But isdigit and isxdigit are always valid. */
-
-/* #define __isspace(c) __C_isspace(c) */
-/* #define __isblank(c) __C_isblank(c) */
-
-/* #define __isdigit(c) __C_isdigit(c) */
-/* #define __isxdigit(c) __C_isxdigit(c) */
-
/* Now some non-ansi/iso c99 macros. */
+#ifdef __UCLIBC_SUSV4_LEGACY__
#define __isascii(c) (((c) & ~0x7f) == 0)
#define __toascii(c) ((c) & 0x7f)
+/* Works correctly *only* on lowercase letters! */
#define _toupper(c) ((c) ^ 0x20)
+/* Works correctly *only* on letters (of any case) and numbers */
#define _tolower(c) ((c) | 0x20)
+#endif
__END_DECLS
/**********************************************************************/
#ifdef __GNUC__
-#define __isbody_C_macro(f,args) __C_ ## f args
-
-#define __isbody(f,c) \
- (__extension__ ({ \
- int __res; \
- if (sizeof(c) > sizeof(char)) { \
- int __c = (c); \
- __res = __isbody_C_macro(f,(__c)); \
- } else { \
- unsigned char __c = (c); \
- __res = __isbody_C_macro(f,(__c)); \
- } \
- __res; \
- }))
-
-#define __body_C_macro(f,args) __C_ ## f args
-
-#define __body(f,c) \
- (__extension__ ({ \
- int __res; \
- if (sizeof(c) > sizeof(char)) { \
- int __c = (c); \
- __res = __body_C_macro(f,(__c)); \
- } else { \
- unsigned char __c = (c); \
- __res = __body_C_macro(f,(__c)); \
- } \
- __res; \
- }))
-
-#define __isspace(c) __body(isspace,c)
-#define __isblank(c) __body(isblank,c)
-#define __isdigit(c) __body(isdigit,c)
-#define __isxdigit(c) __body(isxdigit,c)
-#define __iscntrl(c) __body(iscntrl,c)
-#define __isalpha(c) __body(isalpha,c)
-#define __isalnum(c) __body(isalnum,c)
-#define __isprint(c) __body(isprint,c)
-#define __islower(c) __body(islower,c)
-#define __isupper(c) __body(isupper,c)
-#define __ispunct(c) __body(ispunct,c)
-#define __isgraph(c) __body(isgraph,c)
-
-#define __tolower(c) __body(tolower,c)
-#define __toupper(c) __body(toupper,c)
-
-#if !defined __NO_CTYPE && !defined __cplusplus
-
-#define isspace(c) __isspace(c)
-#define isblank(c) __isblank(c)
-#define isdigit(c) __isdigit(c)
-#define isxdigit(c) __isxdigit(c)
-#define iscntrl(c) __iscntrl(c)
-#define isalpha(c) __isalpha(c)
-#define isalnum(c) __isalnum(c)
-#define isprint(c) __isprint(c)
-#define islower(c) __islower(c)
-#define isupper(c) __isupper(c)
-#define ispunct(c) __ispunct(c)
-#define isgraph(c) __isgraph(c)
-
-#define tolower(c) __tolower(c)
-#define toupper(c) __toupper(c)
-
-
-#endif
-
-#else /* _GNUC__ ***************************************************/
-
-#if !defined __NO_CTYPE && !defined __cplusplus
-
-/* These macros should be safe from side effects. */
-
-#define isdigit(c) __C_isdigit(c)
-#define isalpha(c) __C_isalpha(c)
-#define isprint(c) __C_isprint(c)
-#define islower(c) __C_islower(c)
-#define isupper(c) __C_isupper(c)
-#define isgraph(c) __C_isgraph(c)
+# define __body_C_macro(f,args) __C_ ## f args
+
+# define __body(f,c) \
+(__extension__ ({ \
+ int __res; \
+ if (sizeof(c) > sizeof(char)) { \
+ int __c = (c); \
+ __res = __body_C_macro(f,(__c)); \
+ } else { \
+ unsigned char __c = (c); \
+ __res = __body_C_macro(f,(__c)); \
+ } \
+ __res; \
+}))
+
+# define __isspace(c) __body(isspace,c)
+# define __isblank(c) __body(isblank,c)
+# define __isdigit(c) __body(isdigit,c)
+# define __isxdigit(c) __body(isxdigit,c)
+# define __iscntrl(c) __body(iscntrl,c)
+# define __isalpha(c) __body(isalpha,c)
+# define __isalnum(c) __body(isalnum,c)
+# define __isprint(c) __body(isprint,c)
+# define __islower(c) __body(islower,c)
+# define __isupper(c) __body(isupper,c)
+# define __ispunct(c) __body(ispunct,c)
+# define __isgraph(c) __body(isgraph,c)
+
+/*locale-aware ctype.h has no __tolower, why stub locale
+ *tries to have it? remove after 0.9.31
+ *# define __tolower(c) __body(tolower,c)
+ *# define __toupper(c) __body(toupper,c)
+ */
-#endif
+/* Do not combine in one #if - unifdef tool is not that clever */
+# ifndef __NO_CTYPE
+# ifndef __cplusplus
+
+# define isspace(c) __isspace(c)
+# define isblank(c) __isblank(c)
+# define isdigit(c) __isdigit(c)
+# define isxdigit(c) __isxdigit(c)
+# define iscntrl(c) __iscntrl(c)
+# define isalpha(c) __isalpha(c)
+# define isalnum(c) __isalnum(c)
+# define isprint(c) __isprint(c)
+# define islower(c) __islower(c)
+# define isupper(c) __isupper(c)
+# define ispunct(c) __ispunct(c)
+# define isgraph(c) __isgraph(c)
+
+# define tolower(c) __body(tolower,c)
+# define toupper(c) __body(toupper,c)
+
+# endif
+# endif
+
+#else /* !_GNUC__ */
+
+# ifndef __NO_CTYPE
+# ifndef __cplusplus
+
+/* These macros should be safe from side effects!
+ * (not all __C_xxx macros are) */
+# define isdigit(c) __C_isdigit(c)
+# define isalpha(c) __C_isalpha(c)
+# define isprint(c) __C_isprint(c)
+# define islower(c) __C_islower(c)
+# define isupper(c) __C_isupper(c)
+# define isgraph(c) __C_isgraph(c)
+
+# endif
+# endif
#endif /* __GNUC__ */
/**********************************************************************/
#endif /* __UCLIBC_GEN_LOCALE */
-#endif /* _BITS_CTYPE_H */
+#endif /* _BITS_UCLIBC_CTYPE_H */
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 631e10c50..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/bits/uClibc_fpmax.h b/libc/sysdeps/linux/common/bits/uClibc_fpmax.h
index e1721bf40..b7dcee1d3 100644
--- a/libc/sysdeps/linux/common/bits/uClibc_fpmax.h
+++ b/libc/sysdeps/linux/common/bits/uClibc_fpmax.h
@@ -12,10 +12,6 @@
#ifndef _UCLIBC_FPMAX_H
#define _UCLIBC_FPMAX_H
-#ifndef _ISOC99_SOURCE
-#define _ISOC99_SOURCE 1
-#endif
-
#include <features.h>
#include <float.h>
@@ -72,10 +68,6 @@ typedef float __fpmax_t;
#ifndef DECIMAL_DIG
-#ifdef L___strtofpmax
-/* Emit warning only once. */
-#warning DECIMAL_DIG is not defined! If you are using gcc, it may not be defining __STDC_VERSION__ as it should.
-#endif
#if !defined(FLT_RADIX) || (FLT_RADIX != 2)
#error unable to compensate for missing DECIMAL_DIG!
#endif
diff --git a/libc/sysdeps/linux/common/bits/uClibc_local_lim.h b/libc/sysdeps/linux/common/bits/uClibc_local_lim.h
index 6c23f398b..0727ebf55 100644
--- a/libc/sysdeps/linux/common/bits/uClibc_local_lim.h
+++ b/libc/sysdeps/linux/common/bits/uClibc_local_lim.h
@@ -11,14 +11,22 @@
#define _BITS_UCLIBC_LOCAL_LIM_H 1
/* This file works correctly only if local_lim.h is the NPTL version */
-#if !defined PTHREAD_KEYS_MAX || defined TIMER_MAX
+#if !defined PTHREAD_KEYS_MAX || defined TIMER_MAX || !defined SEM_VALUE_MAX
# error local_lim.h was incorrectly updated, use the NPTL version from glibc
#endif
/* This should really be moved to thread specific directories */
-#if defined __UCLIBC_HAS_THREADS__
+#if defined __UCLIBC_HAS_THREADS__ && !defined __UCLIBC_HAS_THREADS_NATIVE__
+/* glibc uses 16384 */
# define PTHREAD_THREADS_MAX 1024
# define TIMER_MAX 256
+# ifdef __LINUXTHREADS_OLD__
+# undef SEM_VALUE_MAX
+# define SEM_VALUE_MAX ((int) ((~0u) >> 1))
+# endif
+# undef PTHREAD_STACK_MIN
+/* glibc uses at least 16364 */
+# define PTHREAD_STACK_MIN 1024
#endif
#ifndef __UCLIBC_HAS_THREADS__
@@ -28,6 +36,7 @@
# undef PTHREAD_DESTRUCTOR_ITERATIONS
# undef PTHREAD_STACK_MIN
# undef DELAYTIMER_MAX
+# undef SEM_VALUE_MAX
#endif
#endif /* bits/uClibc_local_lim.h */
diff --git a/libc/sysdeps/linux/common/bits/uClibc_locale.h b/libc/sysdeps/linux/common/bits/uClibc_locale.h
index a6b381c95..b42236d38 100644
--- a/libc/sysdeps/linux/common/bits/uClibc_locale.h
+++ b/libc/sysdeps/linux/common/bits/uClibc_locale.h
@@ -11,9 +11,8 @@
* 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.
+ * License along with the GNU C Library; see the file COPYING.LIB. If
+ * not, see <http://www.gnu.org/licenses/>.
*/
/* ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION!
@@ -35,49 +34,38 @@
#ifdef __UCLIBC_HAS_LOCALE__
-#undef __LOCALE_C_ONLY
+# undef __LOCALE_C_ONLY
-#else /* __UCLIBC_HAS_LOCALE__ */
+#else
-#define __LOCALE_C_ONLY
+# define __LOCALE_C_ONLY
-#define __XL_NPP(N) N
-#define __LOCALE_PARAM
-#define __LOCALE_ARG
+# ifdef _LIBC
+# define __XL_NPP(N) N
+# define __LOCALE_PARAM
+# define __LOCALE_ARG
+# endif
-#endif /* __UCLIBC_HAS_LOCALE__ */
+#endif
/**********************************************************************/
-#define __NL_ITEM_CATEGORY_SHIFT (8)
-#define __NL_ITEM_INDEX_MASK (0xff)
+#define __NL_ITEM_CATEGORY_SHIFT 8
+#define __NL_ITEM_INDEX_MASK 0xff
/* TODO: Make sure these agree with the locale mmap file gererator! */
-#define __LC_CTYPE 0
-#define __LC_NUMERIC 1
-#define __LC_MONETARY 2
-#define __LC_TIME 3
-#define __LC_COLLATE 4
-#define __LC_MESSAGES 5
-#define __LC_ALL 6
+#define __LC_CTYPE 0
+#define __LC_NUMERIC 1
+#define __LC_MONETARY 2
+#define __LC_TIME 3
+#define __LC_COLLATE 4
+#define __LC_MESSAGES 5
+#define __LC_ALL 6
/**********************************************************************/
#ifndef __LOCALE_C_ONLY
-#if defined _LIBC /* && (defined IS_IN_libc || defined NOT_IN_libc) */
-#include <stddef.h>
-#include <stdint.h>
-#include <bits/uClibc_touplow.h>
-
-#ifndef __UCLIBC_GEN_LOCALE
-#include <bits/uClibc_locale_data.h>
-#endif
-#endif
-
-/* extern void _locale_set(const unsigned char *p); */
-/* extern void _locale_init(void); */
-
enum {
__ctype_encoding_7_bit, /* C/POSIX */
__ctype_encoding_utf8, /* UTF-8 */
@@ -98,7 +86,22 @@ enum {
* In particular, C/POSIX locale is '#' + "\x80\x01"}*LC_ALL + nul.
*/
-#if defined _LIBC && !defined __UCLIBC_GEN_LOCALE /* && (defined IS_IN_libc || defined NOT_IN_libc) */
+struct __uclibc_locale_struct;
+typedef struct __uclibc_locale_struct *__locale_t;
+
+#ifdef _LIBC
+
+/* extern void _locale_set(const unsigned char *p); */
+extern void weak_function _locale_init(void) attribute_hidden;
+
+#include <stddef.h>
+#include <stdint.h>
+#include <bits/uClibc_touplow.h>
+#ifndef __UCLIBC_GEN_LOCALE
+# include <bits/uClibc_locale_data.h>
+#endif
+
+#ifndef __UCLIBC_GEN_LOCALE /* && (defined IS_IN_libc || defined NOT_IN_libc) */
typedef struct {
uint16_t num_weights;
uint16_t num_starters;
@@ -139,10 +142,9 @@ typedef struct {
uint16_t MAX_WEIGHTS;
} __collate_t;
-
/* static unsigned char cur_locale[LOCALE_STRING_SIZE]; */
-typedef struct __uclibc_locale_struct {
+struct __uclibc_locale_struct {
#ifdef __UCLIBC_HAS_XLOCALE__
const __ctype_mask_t *__ctype_b;
const __ctype_touplow_t *__ctype_tolower;
@@ -174,14 +176,14 @@ typedef struct __uclibc_locale_struct {
const unsigned char *idx8ctype;
const unsigned char *tbl8ctype;
const unsigned char *idx8uplow;
- const unsigned char *tbl8uplow;
-#ifdef __UCLIBC_HAS_WCHAR__
+ const unsigned char *tbl8uplow;
+# ifdef __UCLIBC_HAS_WCHAR__
const unsigned char *idx8c2wc;
const uint16_t *tbl8c2wc; /* char > 0x7f to wide char */
const unsigned char *idx8wc2c;
const unsigned char *tbl8wc2c;
/* translit */
-#endif /* __UCLIBC_HAS_WCHAR__ */
+# endif
#endif /* __CTYPE_HAS_8_BIT_LOCALES */
#ifdef __UCLIBC_HAS_WCHAR__
@@ -301,8 +303,6 @@ typedef struct __uclibc_locale_struct {
const char *era_d_t_fmt;
const char *era_t_fmt;
- /* collate is at the end */
-
/* messages */
const char *yesexpr;
const char *noexpr;
@@ -311,70 +311,65 @@ typedef struct __uclibc_locale_struct {
/* collate is at the end */
__collate_t collate;
+};
-} __uclibc_locale_t;
-
-extern __uclibc_locale_t __global_locale_data;
-extern struct __uclibc_locale_struct * __global_locale;
-#endif /* _LIBC */
+extern struct __uclibc_locale_struct __global_locale_data;
+extern struct __uclibc_locale_struct *__global_locale;
+#endif /* !__UCLIBC_GEN_LOCALE */
-typedef struct __uclibc_locale_struct *__locale_t;
-
-/* if we need to leave only _LIBC, then attribute_hidden is not usable */
-#if defined _LIBC && (defined IS_IN_libc || defined NOT_IN_libc)
+#if defined IS_IN_libc || defined NOT_IN_libc
+/* If you plan to remove xxx_IN_libc guards,
+ * remove attribute_hidden, it won't work.
+ */
extern int __locale_mbrtowc_l(wchar_t *__restrict dst,
- const char *__restrict src,
- __locale_t loc ) attribute_hidden;
+ const char *__restrict src,
+ __locale_t loc) attribute_hidden;
#endif
#ifdef L_setlocale
/* so we only get the warning once... */
#warning need thread version of CUR_LOCALE!
#endif
+
/**********************************************************************/
#ifdef __UCLIBC_HAS_XLOCALE__
extern __locale_t __curlocale_var;
-
-#ifdef __UCLIBC_HAS_THREADS__
-
+# ifdef __UCLIBC_HAS_THREADS__
extern __locale_t __curlocale(void) __THROW __attribute__ ((__const__));
+libc_hidden_proto(__curlocale)
extern __locale_t __curlocale_set(__locale_t newloc);
-#define __UCLIBC_CURLOCALE (__curlocale())
-#define __UCLIBC_CURLOCALE_DATA (*__curlocale())
-
-#else /* __UCLIBC_HAS_THREADS__ */
-
-#define __UCLIBC_CURLOCALE (__curlocale_var)
-#define __UCLIBC_CURLOCALE_DATA (*__curlocale_var)
-
-#endif /* __UCLIBC_HAS_THREADS__ */
+libc_hidden_proto(__curlocale_set)
+# define __UCLIBC_CURLOCALE (__curlocale())
+# else
+# define __UCLIBC_CURLOCALE (__curlocale_var)
+# endif
#elif defined(__UCLIBC_HAS_LOCALE__)
-#define __UCLIBC_CURLOCALE (__global_locale)
-#define __UCLIBC_CURLOCALE_DATA (*__global_locale)
+# define __UCLIBC_CURLOCALE (__global_locale)
#endif
/**********************************************************************/
#if defined(__UCLIBC_HAS_XLOCALE__) && defined(__UCLIBC_DO_XLOCALE)
-#define __XL_NPP(N) N ## _l
-#define __LOCALE_PARAM , __locale_t locale_arg
-#define __LOCALE_ARG , locale_arg
-#define __LOCALE_PTR locale_arg
+# define __XL_NPP(N) N ## _l
+# define __LOCALE_PARAM , __locale_t locale_arg
+# define __LOCALE_ARG , locale_arg
+# define __LOCALE_PTR locale_arg
-#else /* defined(__UCLIBC_HAS_XLOCALE__) && defined(__UCLIBC_DO_XLOCALE) */
+#else
-#define __XL_NPP(N) N
-#define __LOCALE_PARAM
-#define __LOCALE_ARG
-#define __LOCALE_PTR __UCLIBC_CURLOCALE
+# define __XL_NPP(N) N
+# define __LOCALE_PARAM
+# define __LOCALE_ARG
+# define __LOCALE_PTR __UCLIBC_CURLOCALE
-#endif /* defined(__UCLIBC_HAS_XLOCALE__) && defined(__UCLIBC_DO_XLOCALE) */
+#endif
/**********************************************************************/
+#endif /* _LIBC */
+
#endif /* !defined(__LOCALE_C_ONLY) */
-/**********************************************************************/
#endif /* _UCLIBC_LOCALE_H */
diff --git a/libc/sysdeps/linux/common/bits/uClibc_mutex.h b/libc/sysdeps/linux/common/bits/uClibc_mutex.h
index 14aeb9c80..94597e840 100644
--- a/libc/sysdeps/linux/common/bits/uClibc_mutex.h
+++ b/libc/sysdeps/linux/common/bits/uClibc_mutex.h
@@ -13,7 +13,9 @@
#ifdef __UCLIBC_HAS_THREADS__
#include <pthread.h>
+#ifdef _LIBC
#include <bits/uClibc_pthread.h>
+#endif
#define __UCLIBC_MUTEX_TYPE pthread_mutex_t
@@ -22,6 +24,9 @@
#define __UCLIBC_MUTEX_STATIC(M,I) static pthread_mutex_t M = I
#define __UCLIBC_MUTEX_EXTERN(M) extern pthread_mutex_t M
+#define __UCLIBC_MUTEX_INIT_VAR(M) \
+ ((M) = (pthread_mutex_t) PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP)
+
#define __UCLIBC_MUTEX_LOCK_CANCEL_UNSAFE(M) \
__pthread_mutex_lock(&(M))
@@ -34,7 +39,8 @@
#define __UCLIBC_MUTEX_CONDITIONAL_LOCK(M,C) \
do { \
struct _pthread_cleanup_buffer __infunc_pthread_cleanup_buffer; \
- if (C) { \
+ int __infunc_need_locking = (C); \
+ if (__infunc_need_locking) { \
_pthread_cleanup_push_defer(&__infunc_pthread_cleanup_buffer, \
(void (*) (void *))__pthread_mutex_unlock, \
&(M)); \
@@ -43,7 +49,7 @@
((void)0)
#define __UCLIBC_MUTEX_CONDITIONAL_UNLOCK(M,C) \
- if (C) { \
+ if (__infunc_need_locking) { \
_pthread_cleanup_pop_restore(&__infunc_pthread_cleanup_buffer,1); \
} \
} while (0)
@@ -62,13 +68,62 @@
#define __UCLIBC_MUTEX_UNLOCK(M) \
__UCLIBC_MUTEX_CONDITIONAL_UNLOCK(M, 1)
-#else
+#ifdef __USE_STDIO_FUTEXES__
+
+#include <bits/stdio-lock.h>
+
+#define __UCLIBC_IO_MUTEX(M) _IO_lock_t M
+#define __UCLIBC_IO_MUTEX_LOCK(M) _IO_lock_lock(M)
+#define __UCLIBC_IO_MUTEX_UNLOCK(M) _IO_lock_unlock(M)
+#define __UCLIBC_IO_MUTEX_TRYLOCK(M) _IO_lock_trylock(M)
+#define __UCLIBC_IO_MUTEX_INIT(M) _IO_lock_t M = _IO_lock_initializer
+#define __UCLIBC_IO_MUTEX_EXTERN(M) extern _IO_lock_t M
+
+#define __UCLIBC_IO_MUTEX_CONDITIONAL_LOCK(M,C) \
+ if (C) { \
+ _IO_lock_lock(M); \
+ }
+
+#define __UCLIBC_IO_MUTEX_CONDITIONAL_UNLOCK(M,C) \
+ if (C) { \
+ _IO_lock_unlock(M); \
+ }
+
+#define __UCLIBC_IO_MUTEX_AUTO_LOCK(M,A,V) \
+ __UCLIBC_IO_MUTEX_CONDITIONAL_LOCK(M,((A=(V))) == 0)
+
+#define __UCLIBC_IO_MUTEX_AUTO_UNLOCK(M,A) \
+ __UCLIBC_IO_MUTEX_CONDITIONAL_UNLOCK(M,((A) == 0))
+
+#define __UCLIBC_IO_MUTEX_LOCK_CANCEL_UNSAFE(M) _IO_lock_lock(M)
+#define __UCLIBC_IO_MUTEX_UNLOCK_CANCEL_UNSAFE(M) _IO_lock_unlock(M)
+
+#else /* of __USE_STDIO_FUTEXES__ */
+
+#define __UCLIBC_IO_MUTEX(M) __UCLIBC_MUTEX(M)
+#define __UCLIBC_IO_MUTEX_LOCK(M) __UCLIBC_MUTEX_CONDITIONAL_LOCK(M, 1)
+#define __UCLIBC_IO_MUTEX_UNLOCK(M) __UCLIBC_MUTEX_CONDITIONAL_UNLOCK(M, 1)
+#define __UCLIBC_IO_MUTEX_TRYLOCK(M) __UCLIBC_MUTEX_TRYLOCK_CANCEL_UNSAFE(M)
+#define __UCLIBC_IO_MUTEX_INIT(M) __UCLIBC_MUTEX_INIT(M, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP)
+#define __UCLIBC_IO_MUTEX_EXTERN(M) __UCLIBC_MUTEX_EXTERN(M)
+#define __UCLIBC_IO_MUTEX_AUTO_LOCK(M,A,V) __UCLIBC_MUTEX_AUTO_LOCK(M,A,V)
+#define __UCLIBC_IO_MUTEX_AUTO_UNLOCK(M,A) __UCLIBC_MUTEX_AUTO_UNLOCK(M,A)
+#define __UCLIBC_IO_MUTEX_LOCK_CANCEL_UNSAFE(M) __UCLIBC_MUTEX_LOCK_CANCEL_UNSAFE(M)
+#define __UCLIBC_IO_MUTEX_UNLOCK_CANCEL_UNSAFE(M) __UCLIBC_MUTEX_UNLOCK_CANCEL_UNSAFE(M)
+#define __UCLIBC_IO_MUTEX_CONDITIONAL_LOCK(M,C) __UCLIBC_MUTEX_CONDITIONAL_LOCK(M,C)
+#define __UCLIBC_IO_MUTEX_CONDITIONAL_UNLOCK(M,C) __UCLIBC_MUTEX_CONDITIONAL_UNLOCK(M,C)
+
+#endif /* of __USE_STDIO_FUTEXES__ */
+
+
+#else /* of __UCLIBC_HAS_THREADS__ */
#define __UCLIBC_MUTEX(M) void *__UCLIBC_MUTEX_DUMMY_ ## M
#define __UCLIBC_MUTEX_INIT(M,I) extern void *__UCLIBC_MUTEX_DUMMY_ ## M
#define __UCLIBC_MUTEX_STATIC(M,I) extern void *__UCLIBC_MUTEX_DUMMY_ ## M
#define __UCLIBC_MUTEX_EXTERN(M) extern void *__UCLIBC_MUTEX_DUMMY_ ## M
+#define __UCLIBC_MUTEX_INIT_VAR(M) ((void)0)
#define __UCLIBC_MUTEX_LOCK_CANCEL_UNSAFE(M) ((void)0)
#define __UCLIBC_MUTEX_UNLOCK_CANCEL_UNSAFE(M) ((void)0)
#define __UCLIBC_MUTEX_TRYLOCK_CANCEL_UNSAFE(M) (0) /* Always succeed? */
@@ -83,6 +138,22 @@
#define __UCLIBC_MUTEX_LOCK(M) ((void)0)
#define __UCLIBC_MUTEX_UNLOCK(M) ((void)0)
-#endif
+#define __UCLIBC_IO_MUTEX(M) __UCLIBC_MUTEX(M)
+#define __UCLIBC_IO_MUTEX_LOCK(M) __UCLIBC_MUTEX_CONDITIONAL_LOCK(M, 1)
+#define __UCLIBC_IO_MUTEX_UNLOCK(M) __UCLIBC_MUTEX_CONDITIONAL_UNLOCK(M, 1)
+#define __UCLIBC_IO_MUTEX_TRYLOCK(M) __UCLIBC_MUTEX_TRYLOCK_CANCEL_UNSAFE(M)
+#define __UCLIBC_IO_MUTEX_INIT(M) __UCLIBC_MUTEX_INIT(M, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP)
+#define __UCLIBC_IO_MUTEX_EXTERN(M) __UCLIBC_MUTEX_EXTERN(M)
+#define __UCLIBC_IO_MUTEX_AUTO_LOCK(M,A,V) __UCLIBC_MUTEX_AUTO_LOCK(M,A,V)
+#define __UCLIBC_IO_MUTEX_AUTO_UNLOCK(M,A) __UCLIBC_MUTEX_AUTO_UNLOCK(M,A)
+#define __UCLIBC_IO_MUTEX_LOCK_CANCEL_UNSAFE(M) __UCLIBC_MUTEX_LOCK_CANCEL_UNSAFE(M)
+#define __UCLIBC_IO_MUTEX_UNLOCK_CANCEL_UNSAFE(M) __UCLIBC_MUTEX_UNLOCK_CANCEL_UNSAFE(M)
+#define __UCLIBC_IO_MUTEX_CONDITIONAL_LOCK(M,C) __UCLIBC_MUTEX_CONDITIONAL_LOCK(M,C)
+#define __UCLIBC_IO_MUTEX_CONDITIONAL_UNLOCK(M,C) __UCLIBC_MUTEX_CONDITIONAL_UNLOCK(M,C)
+
+#endif /* of __UCLIBC_HAS_THREADS__ */
+
+#define __UCLIBC_IO_MUTEX_TRYLOCK_CANCEL_UNSAFE(M) \
+ __UCLIBC_IO_MUTEX_TRYLOCK(M)
#endif /* _UCLIBC_MUTEX_H */
diff --git a/libc/sysdeps/linux/common/bits/uClibc_page.h b/libc/sysdeps/linux/common/bits/uClibc_page.h
index 134094536..d1f9262fd 100644
--- a/libc/sysdeps/linux/common/bits/uClibc_page.h
+++ b/libc/sysdeps/linux/common/bits/uClibc_page.h
@@ -11,9 +11,8 @@
* 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.
+ * License along with the GNU C Library; see the file COPYING.LIB. If
+ * not, see <http://www.gnu.org/licenses/>.
*/
/* Supply an architecture specific value for PAGE_SIZE and friends. */
diff --git a/libc/sysdeps/linux/common/bits/uClibc_posix_opt.h b/libc/sysdeps/linux/common/bits/uClibc_posix_opt.h
new file mode 100644
index 000000000..0ae0da188
--- /dev/null
+++ b/libc/sysdeps/linux/common/bits/uClibc_posix_opt.h
@@ -0,0 +1,136 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+/*
+ * Never include this file directly; use <unistd.h> instead.
+ */
+
+#ifndef _BITS_UCLIBC_POSIX_OPT_H
+#define _BITS_UCLIBC_POSIX_OPT_H 1
+
+/* This file works correctly only if posix_opt.h is the NPTL version */
+#ifndef _POSIX_THREADS
+# error posix_opt.h was incorrectly updated, use the NPTL version from glibc
+#endif
+
+/* change first options based on what glibc does */
+
+#ifndef __UCLIBC_HAS_THREADS_NATIVE__
+# undef _POSIX_THREAD_PROCESS_SHARED
+# define _POSIX_THREAD_PROCESS_SHARED -1
+# undef _POSIX_CLOCK_SELECTION
+# define _POSIX_CLOCK_SELECTION -1
+# undef _POSIX_THREAD_PRIO_INHERIT
+# define _POSIX_THREAD_PRIO_INHERIT -1
+# undef _POSIX_THREAD_PRIO_PROTECT
+# define _POSIX_THREAD_PRIO_PROTECT -1
+# undef _POSIX_THREAD_ROBUST_PRIO_INHERIT
+# undef _POSIX_THREAD_ROBUST_PRIO_PROTECT
+#endif
+
+/* this has to be adapted to uClibc, not all are thread related */
+#ifndef __UCLIBC_HAS_THREADS__
+# undef _XOPEN_REALTIME_THREADS
+# undef _POSIX_THREADS
+# undef _POSIX_REENTRANT_FUNCTIONS
+# undef _POSIX_THREAD_SAFE_FUNCTIONS
+# undef _POSIX_THREAD_PRIORITY_SCHEDULING
+# undef _POSIX_THREAD_ATTR_STACKSIZE
+# undef _POSIX_THREAD_ATTR_STACKADDR
+# undef _POSIX_THREAD_PRIO_INHERIT
+# undef _POSIX_THREAD_PRIO_PROTECT
+# undef _POSIX_SEMAPHORES
+# undef _POSIX_ASYNCHRONOUS_IO
+# undef _POSIX_ASYNC_IO
+# undef _LFS_ASYNCHRONOUS_IO
+# undef _POSIX_PRIORITIZED_IO
+# undef _LFS64_ASYNCHRONOUS_IO
+# undef _POSIX_CPUTIME
+# undef _POSIX_THREAD_CPUTIME
+# undef _POSIX_READER_WRITER_LOCKS
+# undef _POSIX_TIMEOUTS
+# undef _POSIX_SPIN_LOCKS
+# undef _POSIX_BARRIERS
+# undef _POSIX_MESSAGE_PASSING
+# undef _POSIX_THREAD_PROCESS_SHARED
+# undef _POSIX_CLOCK_SELECTION
+# undef _POSIX_ADVISORY_INFO
+/*# undef _POSIX_RAW_SOCKETS*/
+/*# undef _POSIX2_CHAR_TERM*/
+# undef _POSIX_SPORADIC_SERVER
+# undef _POSIX_THREAD_SPORADIC_SERVER
+/*# undef _POSIX_TRACE
+# undef _POSIX_TRACE_EVENT_FILTER
+# undef _POSIX_TRACE_INHERIT
+# undef _POSIX_TRACE_LOG
+# undef _POSIX_TYPED_MEMORY_OBJECTS*/
+#endif
+
+/* were in earlier version, used by sysconf */
+#define _POSIX_POLL 1
+#define _POSIX_SELECT 1
+
+/* disable independently unsupported features */
+#undef _POSIX_TRACE
+#undef _POSIX_TRACE_EVENT_FILTER
+#undef _POSIX_TRACE_INHERIT
+#undef _POSIX_TRACE_LOG
+#undef _POSIX_TYPED_MEMORY_OBJECTS
+#undef _POSIX_SPAWN
+
+#if 0 /* does uClibc support these? */
+# undef _POSIX_ASYNCHRONOUS_IO
+# undef _POSIX_ASYNC_IO
+# undef _LFS_ASYNCHRONOUS_IO
+# undef _POSIX_PRIORITIZED_IO
+# undef _LFS64_ASYNCHRONOUS_IO
+# undef _POSIX_MESSAGE_PASSING
+#endif
+
+/* change options based on uClibc config options */
+
+#if 0 /*ndef __UCLIBC_HAS_POSIX_TIMERS__*/
+# undef _POSIX_TIMERS
+# undef _POSIX_THREAD_CPUTIME
+#endif
+
+#if 0 /*ndef __UCLIBC_HAS_POSIX_BARRIERS__*/
+# undef _POSIX_BARRIERS
+#endif
+
+#if 0 /*ndef __UCLIBC_HAS_POSIX_SPINLOCKS__*/
+# undef _POSIX_SPIN_LOCKS
+#endif
+
+#ifndef __ARCH_USE_MMU__
+# undef _POSIX_MEMLOCK
+# undef _POSIX_MEMLOCK_RANGE
+# undef _POSIX_MEMORY_PROTECTION
+#endif
+
+#ifndef __UCLIBC_HAS_LFS__
+# undef _LFS64_ASYNCHRONOUS_IO
+# undef _LFS_LARGEFILE
+# undef _LFS64_LARGEFILE
+# undef _LFS64_STDIO
+#endif
+
+#ifndef __UCLIBC_HAS_REALTIME__
+# undef _POSIX_SEMAPHORES
+#endif
+
+#ifndef __UCLIBC_HAS_REGEX__
+# undef _POSIX_REGEXP
+#endif
+
+#ifndef __UCLIBC_HAS_IPV6__
+# undef _POSIX_IPV6
+#endif
+
+#ifndef __UCLIBC_HAS_SOCKET__
+# undef _POSIX_RAW_SOCKETS
+#endif
+
+#endif /* bits/uClibc_posix_opt.h */
diff --git a/libc/sysdeps/linux/common/bits/uClibc_pthread.h b/libc/sysdeps/linux/common/bits/uClibc_pthread.h
index 1d6209f5e..708d0fed2 100644
--- a/libc/sysdeps/linux/common/bits/uClibc_pthread.h
+++ b/libc/sysdeps/linux/common/bits/uClibc_pthread.h
@@ -11,9 +11,8 @@
* 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.
+ * License along with the GNU C Library; see the file COPYING.LIB. If
+ * not, see <http://www.gnu.org/licenses/>.
*/
/* Supply prototypes for the internal thread functions used by the
@@ -27,24 +26,20 @@
# error "Always include <pthread.h> rather than <bits/uClibc_pthread.h>"
#endif
-#if defined _LIBC && (defined IS_IN_libc || defined NOT_IN_libc)
+struct _pthread_cleanup_buffer;
+
/* Threading functions internal to uClibc. Make these thread functions
* weak so that we can elide them from single-threaded processes. */
extern int weak_function __pthread_mutex_init (pthread_mutex_t *__mutex,
- __const pthread_mutexattr_t *__mutex_attr);
-extern int weak_function __pthread_mutex_destroy (pthread_mutex_t *__mutex);
+ const pthread_mutexattr_t *__mutex_attr);
extern int weak_function __pthread_mutex_lock (pthread_mutex_t *__mutex);
extern int weak_function __pthread_mutex_unlock (pthread_mutex_t *__mutex);
-extern void __uclibc_mutex_unlock (void *) attribute_hidden;
extern int weak_function __pthread_mutex_trylock (pthread_mutex_t *__mutex);
-# ifndef __UCLIBC_HAS_THREADS_NATIVE__
extern void weak_function _pthread_cleanup_push_defer (
struct _pthread_cleanup_buffer *__buffer,
void (*__routine) (void *), void *__arg);
extern void weak_function _pthread_cleanup_pop_restore (
struct _pthread_cleanup_buffer *__buffer,
int __execute);
-# endif
-#endif
#endif
diff --git a/libc/sysdeps/linux/common/bits/uClibc_stdio.h b/libc/sysdeps/linux/common/bits/uClibc_stdio.h
index 843a2f2c3..efd8a6c89 100644
--- a/libc/sysdeps/linux/common/bits/uClibc_stdio.h
+++ b/libc/sysdeps/linux/common/bits/uClibc_stdio.h
@@ -54,27 +54,6 @@
#endif
/**********************************************************************/
-/* Make sure defines related to large files are consistent. */
-#ifdef _LIBC
-
-#ifdef __UCLIBC_HAS_LFS__
-#undef __USE_LARGEFILE
-#undef __USE_LARGEFILE64
-#undef __USE_FILE_OFFSET64
-/* If we're actually building uClibc with large file support, only define... */
-#define __USE_LARGEFILE64 1
-#endif /* __UCLIBC_HAS_LFS__ */
-
-#else /* not _LIBC */
-
-#ifndef __UCLIBC_HAS_LFS__
-#if defined(__LARGEFILE64_SOURCE) || defined(__USE_LARGEFILE64) || defined(__USE_FILE_OFFSET64)
-#error Sorry... uClibc was built without large file support!
-#endif
-#endif /* __UCLIBC_HAS_LFS__ */
-
-#endif /* _LIBC */
-/**********************************************************************/
#ifdef __UCLIBC_HAS_WCHAR__
#define __need_wchar_t
@@ -99,22 +78,7 @@
#define __STDIO_PUTC_MACRO
#endif
-
-/* These are consistency checks on the different options */
-
-#ifndef __STDIO_BUFFERS
-#undef __STDIO_GETC_MACRO
-#undef __STDIO_PUTC_MACRO
-#endif
-
-#ifdef __BCC__
-#undef __UCLIBC_HAS_LFS__
-#endif
-
-#ifndef __UCLIBC_HAS_LFS__
-#undef __UCLIBC_HAS_FOPEN_LARGEFILE_MODE__
-#endif
-
+#ifdef _LIBC
/**********************************************************************/
#include <bits/uClibc_mutex.h>
@@ -134,26 +98,26 @@
__UCLIBC_MUTEX_AUTO_LOCK_VAR(__infunc_user_locking)
#define __STDIO_AUTO_THREADLOCK(__stream) \
- __UCLIBC_MUTEX_AUTO_LOCK((__stream)->__lock, __infunc_user_locking, \
+ __UCLIBC_IO_MUTEX_AUTO_LOCK((__stream)->__lock, __infunc_user_locking, \
(__stream)->__user_locking)
#define __STDIO_AUTO_THREADUNLOCK(__stream) \
- __UCLIBC_MUTEX_AUTO_UNLOCK((__stream)->__lock, __infunc_user_locking)
+ __UCLIBC_IO_MUTEX_AUTO_UNLOCK((__stream)->__lock, __infunc_user_locking)
#define __STDIO_ALWAYS_THREADLOCK(__stream) \
- __UCLIBC_MUTEX_LOCK((__stream)->__lock)
+ __UCLIBC_IO_MUTEX_LOCK((__stream)->__lock)
#define __STDIO_ALWAYS_THREADUNLOCK(__stream) \
- __UCLIBC_MUTEX_UNLOCK((__stream)->__lock)
+ __UCLIBC_IO_MUTEX_UNLOCK((__stream)->__lock)
#define __STDIO_ALWAYS_THREADLOCK_CANCEL_UNSAFE(__stream) \
- __UCLIBC_MUTEX_LOCK_CANCEL_UNSAFE((__stream)->__lock)
+ __UCLIBC_IO_MUTEX_LOCK_CANCEL_UNSAFE((__stream)->__lock)
#define __STDIO_ALWAYS_THREADTRYLOCK_CANCEL_UNSAFE(__stream) \
- __UCLIBC_MUTEX_TRYLOCK_CANCEL_UNSAFE((__stream)->__lock)
+ __UCLIBC_IO_MUTEX_TRYLOCK_CANCEL_UNSAFE((__stream)->__lock)
#define __STDIO_ALWAYS_THREADUNLOCK_CANCEL_UNSAFE(__stream) \
- __UCLIBC_MUTEX_UNLOCK_CANCEL_UNSAFE((__stream)->__lock)
+ __UCLIBC_IO_MUTEX_UNLOCK_CANCEL_UNSAFE((__stream)->__lock)
#ifdef __UCLIBC_HAS_THREADS__
#define __STDIO_SET_USER_LOCKING(__stream) ((__stream)->__user_locking = 1)
@@ -161,6 +125,16 @@
#define __STDIO_SET_USER_LOCKING(__stream) ((void)0)
#endif
+#ifdef __UCLIBC_HAS_THREADS__
+#ifdef __USE_STDIO_FUTEXES__
+#define STDIO_INIT_MUTEX(M) _IO_lock_init(M)
+#else
+#define STDIO_INIT_MUTEX(M) __stdio_init_mutex(& M)
+#endif
+#endif
+
+#endif /* _LIBC */
+
/**********************************************************************/
#define __STDIO_IOFBF 0 /* Fully buffered. */
@@ -201,7 +175,7 @@ typedef __off_t __offmax_t; /* TODO -- rename this? */
typedef __ssize_t __io_read_fn(void *__cookie, char *__buf, size_t __bufsize);
typedef __ssize_t __io_write_fn(void *__cookie,
- __const char *__buf, size_t __bufsize);
+ const char *__buf, size_t __bufsize);
/* NOTE: GLIBC difference!!! -- fopencookie seek function
* For glibc, the type of pos is always (__off64_t *) but in our case
* it is type (__off_t *) when the lib is built without large file support.
@@ -216,7 +190,7 @@ typedef struct {
__io_close_fn *close;
} _IO_cookie_io_functions_t;
-#if defined(_LIBC) || defined(_GNU_SOURCE)
+#ifdef __USE_GNU
typedef __io_read_fn cookie_read_function_t;
typedef __io_write_fn cookie_write_function_t;
@@ -230,6 +204,17 @@ typedef _IO_cookie_io_functions_t cookie_io_functions_t;
#endif
/**********************************************************************/
+#if defined __UCLIBC_HAS_THREADS__ && !defined __UCLIBC_IO_MUTEX
+/* keep this in sync with uClibc_mutex.h */
+# ifdef __USE_STDIO_FUTEXES__
+# include <bits/stdio-lock.h>
+# define __UCLIBC_IO_MUTEX(M) _IO_lock_t M
+# else
+# include <bits/pthreadtypes.h>
+# define __UCLIBC_IO_MUTEX(M) pthread_mutex_t M
+# endif /* __UCLIBC_HAS_THREADS_NATIVE__ */
+#endif
+
struct __STDIO_FILE_STRUCT {
unsigned short __modeflags;
/* There could be a hole here, but modeflags is used most.*/
@@ -260,10 +245,6 @@ struct __STDIO_FILE_STRUCT {
#ifdef __STDIO_HAS_OPENLIST
struct __STDIO_FILE_STRUCT *__nextopen;
#endif
-#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__
- void *__cookie;
- _IO_cookie_io_functions_t __gcs;
-#endif
#ifdef __UCLIBC_HAS_WCHAR__
wchar_t __ungot[2];
#endif
@@ -275,7 +256,7 @@ struct __STDIO_FILE_STRUCT {
#endif
#ifdef __UCLIBC_HAS_THREADS__
int __user_locking;
- __UCLIBC_MUTEX(__lock);
+ __UCLIBC_IO_MUTEX(__lock);
#endif
/* Everything after this is unimplemented... and may be trashed. */
#if __STDIO_BUILTIN_BUF_SIZE > 0
@@ -343,22 +324,27 @@ struct __STDIO_FILE_STRUCT {
**********************************************************************/
#if defined _LIBC && (defined IS_IN_libc || defined NOT_IN_libc)
-extern void _stdio_init(void) attribute_hidden;
-extern void _stdio_term(void) attribute_hidden;
+extern void weak_function _stdio_init(void) attribute_hidden;
+extern void weak_function _stdio_term(void) attribute_hidden;
#ifdef __STDIO_HAS_OPENLIST
extern struct __STDIO_FILE_STRUCT *_stdio_openlist;
#ifdef __UCLIBC_HAS_THREADS__
-__UCLIBC_MUTEX_EXTERN(_stdio_openlist_add_lock);
+__UCLIBC_IO_MUTEX_EXTERN(_stdio_openlist_add_lock)
+# ifndef __UCLIBC_HAS_THREADS_NATIVE__
+ attribute_hidden
+# endif
+ ;
#ifdef __STDIO_BUFFERS
-__UCLIBC_MUTEX_EXTERN(_stdio_openlist_del_lock);
-extern volatile int _stdio_openlist_use_count; /* _stdio_openlist_del_lock */
-extern int _stdio_openlist_del_count; /* _stdio_openlist_del_lock */
+__UCLIBC_IO_MUTEX_EXTERN(_stdio_openlist_del_lock)
+# ifndef __UCLIBC_HAS_THREADS_NATIVE__
+ attribute_hidden
+# endif
+ ;
#endif
extern int _stdio_user_locking;
-extern void __stdio_init_mutex(__UCLIBC_MUTEX_TYPE *m) attribute_hidden;
#endif
#endif
@@ -382,7 +368,9 @@ extern void __stdio_init_mutex(__UCLIBC_MUTEX_TYPE *m) attribute_hidden;
#endif
extern int __fgetc_unlocked(FILE *__stream);
+libc_hidden_proto(__fgetc_unlocked)
extern int __fputc_unlocked(int __c, FILE *__stream);
+libc_hidden_proto(__fputc_unlocked)
/* First define the default definitions.
They are overridden below as necessary. */
@@ -455,6 +443,8 @@ extern FILE *__stdin; /* For getchar() macro. */
#else
+# define __stdin stdin
+
#endif /* __STDIO_GETC_MACRO */
@@ -514,4 +504,8 @@ extern FILE *__stdout; /* For putchar() macro. */
# endif
# endif
+#else
+
+# define __stdout stdout
+
#endif /* __STDIO_PUTC_MACRO */
diff --git a/libc/sysdeps/linux/common/bits/uClibc_touplow.h b/libc/sysdeps/linux/common/bits/uClibc_touplow.h
index 28d4e2f48..d4c228dcf 100644
--- a/libc/sysdeps/linux/common/bits/uClibc_touplow.h
+++ b/libc/sysdeps/linux/common/bits/uClibc_touplow.h
@@ -11,9 +11,8 @@
* 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.
+ * License along with the GNU C Library; see the file COPYING.LIB. If
+ * not, see <http://www.gnu.org/licenses/>.
*/
/* ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION!
@@ -43,13 +42,13 @@ typedef __int16_t __ctype_touplow_t;
#define __UCLIBC_CTYPE_B_TBL_OFFSET 128
#define __UCLIBC_CTYPE_TO_TBL_OFFSET 128
-#else /* __UCLIBC_HAS_CTYPE_SIGNED__ */
+#else
typedef unsigned char __ctype_touplow_t;
#define __UCLIBC_CTYPE_B_TBL_OFFSET 1
#define __UCLIBC_CTYPE_TO_TBL_OFFSET 0
-#endif /* __UCLIBC_HAS_CTYPE_SIGNED__ */
+#endif
#endif /* _UCLIBC_TOUPLOW_H */
diff --git a/libc/sysdeps/linux/common/bits/uClibc_uintmaxtostr.h b/libc/sysdeps/linux/common/bits/uClibc_uintmaxtostr.h
index 92633ffa6..08d0a86d3 100644
--- a/libc/sysdeps/linux/common/bits/uClibc_uintmaxtostr.h
+++ b/libc/sysdeps/linux/common/bits/uClibc_uintmaxtostr.h
@@ -11,9 +11,8 @@
* 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.
+ * License along with the GNU C Library; see the file COPYING.LIB. If
+ * not, see <http://www.gnu.org/licenses/>.
*/
/* ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION!
@@ -28,16 +27,6 @@
#ifndef _UINTMAXTOSTR_H
#define _UINTMAXTOSTR_H 1
-#ifdef _FEATURES_H
-# ifndef __USE_ISOC99
-# error features was included without defining _ISOC99_SOURCE!
-# endif
-#else
-# ifndef _ISOC99_SOURCE
-# define _ISOC99_SOURCE
-# endif
-#endif
-
#include <features.h>
#include <limits.h>
#include <stdint.h>
diff --git a/libc/sysdeps/linux/common/bits/uClibc_uwchar.h b/libc/sysdeps/linux/common/bits/uClibc_uwchar.h
index ba2c42db7..47ea3cda1 100644
--- a/libc/sysdeps/linux/common/bits/uClibc_uwchar.h
+++ b/libc/sysdeps/linux/common/bits/uClibc_uwchar.h
@@ -11,9 +11,8 @@
* 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.
+ * License along with the GNU C Library; see the file COPYING.LIB. If
+ * not, see <http://www.gnu.org/licenses/>.
*/
/* ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION!
diff --git a/libc/sysdeps/linux/common/bits/uClibc_va_copy.h b/libc/sysdeps/linux/common/bits/uClibc_va_copy.h
index 98663fc0e..39dd378fc 100644
--- a/libc/sysdeps/linux/common/bits/uClibc_va_copy.h
+++ b/libc/sysdeps/linux/common/bits/uClibc_va_copy.h
@@ -13,9 +13,8 @@
* 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.
+ * License along with the GNU C Library; see the file COPYING.LIB. If
+ * not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _UCLIBC_VA_COPY_H
diff --git a/libc/sysdeps/linux/common/bits/uio.h b/libc/sysdeps/linux/common/bits/uio.h
index 6a283ed77..611e42476 100644
--- a/libc/sysdeps/linux/common/bits/uio.h
+++ b/libc/sysdeps/linux/common/bits/uio.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#if !defined _SYS_UIO_H && !defined _FCNTL_H
# error "Never include <bits/uio.h> directly; use <sys/uio.h> instead."
@@ -38,6 +37,7 @@
functionality even if the currently running kernel does not support
this large value the readv/writev call will not fail because of this. */
#define UIO_MAXIOV 1024
+#define UIO_FASTIOV 8
/* Structure for scatter/gather I/O. */
diff --git a/libc/sysdeps/linux/common/bits/ustat.h b/libc/sysdeps/linux/common/bits/ustat.h
index 69c6b7227..ea048d122 100644
--- a/libc/sysdeps/linux/common/bits/ustat.h
+++ b/libc/sysdeps/linux/common/bits/ustat.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_USTAT_H
# error "Never include <bits/ustat.h> directly; use <sys/ustat.h> instead."
diff --git a/libc/sysdeps/linux/common/bits/utmp.h b/libc/sysdeps/linux/common/bits/utmp.h
index e855ad73f..6ece31e34 100644
--- a/libc/sysdeps/linux/common/bits/utmp.h
+++ b/libc/sysdeps/linux/common/bits/utmp.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _UTMP_H
# error "Never include <bits/utmp.h> directly; use <utmp.h> instead."
@@ -37,7 +36,7 @@
previous logins. */
struct lastlog
{
-#if __WORDSIZE == 64 && defined __WORDSIZE_COMPAT32
+#ifdef __WORDSIZE_TIME64_COMPAT32
int32_t ll_time;
#else
__time_t ll_time;
@@ -70,7 +69,7 @@ struct utmp
/* The ut_session and ut_tv fields must be the same size when compiled
32- and 64-bit. This allows data files and shared memory to be
shared between 32- and 64-bit applications. */
-#if __WORDSIZE == 64 && defined __WORDSIZE_COMPAT32
+#ifdef __WORDSIZE_TIME64_COMPAT32
int32_t ut_session; /* Session ID, used for windowing. */
struct
{
diff --git a/libc/sysdeps/linux/common/bits/utmpx.h b/libc/sysdeps/linux/common/bits/utmpx.h
index c84cda6fe..815fc90b8 100644
--- a/libc/sysdeps/linux/common/bits/utmpx.h
+++ b/libc/sysdeps/linux/common/bits/utmpx.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _UTMPX_H
# error "Never include <bits/utmpx.h> directly; use <utmpx.h> instead."
@@ -67,7 +66,7 @@ struct utmpx
/* The fields ut_session and ut_tv must be the same size when compiled
32- and 64-bit. This allows files and shared memory to be shared
between 32- and 64-bit applications. */
-#if __WORDSIZE == 64 && defined __WORDSIZE_COMPAT32
+#ifdef __WORDSIZE_TIME64_COMPAT32
__int32_t ut_session; /* Session ID, used for windowing. */
struct
{
diff --git a/libc/sysdeps/linux/common/bits/utsname.h b/libc/sysdeps/linux/common/bits/utsname.h
index 35e71e3ba..d82dec91e 100644
--- a/libc/sysdeps/linux/common/bits/utsname.h
+++ b/libc/sysdeps/linux/common/bits/utsname.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_UTSNAME_H
# error "Never include <bits/utsname.h> directly; use <sys/utsname.h> instead."
diff --git a/libc/sysdeps/linux/common/bits/waitflags.h b/libc/sysdeps/linux/common/bits/waitflags.h
index 464cedb1f..4ffe40c01 100644
--- a/libc/sysdeps/linux/common/bits/waitflags.h
+++ b/libc/sysdeps/linux/common/bits/waitflags.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#if !defined _SYS_WAIT_H && !defined _STDLIB_H
# error "Never include <bits/waitflags.h> directly; use <sys/wait.h> instead."
diff --git a/libc/sysdeps/linux/common/bits/waitstatus.h b/libc/sysdeps/linux/common/bits/waitstatus.h
index 699c22498..33f39a84a 100644
--- a/libc/sysdeps/linux/common/bits/waitstatus.h
+++ b/libc/sysdeps/linux/common/bits/waitstatus.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#if !defined _SYS_WAIT_H && !defined _STDLIB_H
# error "Never include <bits/waitstatus.h> directly; use <sys/wait.h> instead."
@@ -25,7 +24,7 @@
/* Everything extant so far uses these same bits. */
-/* If WIFEXITED(STATUS), the low-order 8 bits of the status. */
+/* If WIFEXITED(STATUS), the low-order 8 bits of exit(N). */
#define __WEXITSTATUS(status) (((status) & 0xff00) >> 8)
/* If WIFSIGNALED(STATUS), the terminating signal. */
@@ -37,12 +36,20 @@
/* Nonzero if STATUS indicates normal termination. */
#define __WIFEXITED(status) (__WTERMSIG(status) == 0)
-/* Nonzero if STATUS indicates termination by a signal. */
-#define __WIFSIGNALED(status) \
- (((signed char) (((status) & 0x7f) + 1) >> 1) > 0)
+/* Nonzero if STATUS indicates termination by a signal.
+ * Note that status 0x007f is "died from signal 127", not "stopped by signal 0".
+ * This does happen on MIPS.
+ * The comparison is "< 0xff", not "< 0x7f", because WCOREDUMP bit (0x80)
+ * can be set too.
+ */
+#define __WIFSIGNALED(status) (((unsigned)((status) & 0xffff) - 1U) < 0xffU)
/* Nonzero if STATUS indicates the child is stopped. */
+#if !defined(__mips__)
#define __WIFSTOPPED(status) (((status) & 0xff) == 0x7f)
+#else
+#define __WIFSTOPPED(status) (((status) & 0xff) == 0x7f && ((status) & 0xff00))
+#endif
/* Nonzero if STATUS indicates the child continued after a stop. We only
define this if <bits/waitflags.h> provides the WCONTINUED flag bit. */
diff --git a/libc/sysdeps/linux/common/bits/wchar.h b/libc/sysdeps/linux/common/bits/wchar.h
index ef1f56363..a3ff5319e 100644
--- a/libc/sysdeps/linux/common/bits/wchar.h
+++ b/libc/sysdeps/linux/common/bits/wchar.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _BITS_WCHAR_H
#define _BITS_WCHAR_H 1
diff --git a/libc/sysdeps/linux/common/bits/xopen_lim.h b/libc/sysdeps/linux/common/bits/xopen_lim.h
index c2363ab04..90620266b 100644
--- a/libc/sysdeps/linux/common/bits/xopen_lim.h
+++ b/libc/sysdeps/linux/common/bits/xopen_lim.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/*
* Never include this file directly; use <limits.h> instead.
diff --git a/libc/sysdeps/linux/bfin/brk.c b/libc/sysdeps/linux/common/brk.c
index 64480453e..77a26c083 100644
--- a/libc/sysdeps/linux/bfin/brk.c
+++ b/libc/sysdeps/linux/common/brk.c
@@ -8,29 +8,23 @@
#include <unistd.h>
#include <sys/syscall.h>
-libc_hidden_proto(brk)
+#define __NR___syscall_brk __NR_brk
+static __always_inline _syscall1(void *, __syscall_brk, void *, end)
/* This must be initialized data because commons can't have aliases. */
void * __curbrk attribute_hidden = 0;
-int brk (void *addr)
+int brk(void *addr)
{
- void *newbrk;
+ void *newbrk = __syscall_brk(addr);
- __asm__ __volatile__(
- "P0 = %2;\n\t"
- "excpt 0;\n\t"
- : "=q0" (newbrk)
- : "q0" (addr), "i" (__NR_brk): "P0" );
+ __curbrk = newbrk;
- __curbrk = newbrk;
+ if (newbrk < addr) {
+ __set_errno (ENOMEM);
+ return -1;
+ }
- if (newbrk < addr)
- {
- __set_errno (ENOMEM);
- return -1;
- }
-
- return 0;
+ return 0;
}
libc_hidden_def(brk)
diff --git a/libc/sysdeps/linux/common/capget.c b/libc/sysdeps/linux/common/capget.c
index c8c83249c..e420f6a1f 100644
--- a/libc/sysdeps/linux/common/capget.c
+++ b/libc/sysdeps/linux/common/capget.c
@@ -8,13 +8,8 @@
*/
#include <sys/syscall.h>
-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;
-}
+int capget(void *header, void *data);
+_syscall2(int, capget, void *, header, void *, data)
#endif
diff --git a/libc/sysdeps/linux/common/capset.c b/libc/sysdeps/linux/common/capset.c
index 7a28b0e16..493cf1449 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);
-#else
-int capset(void *header, const void *data)
-{
- __set_errno(ENOSYS);
- return -1;
-}
+int capset(void *header, const void *data);
+_syscall2(int, capset, void *, header, const void *, data)
#endif
diff --git a/libc/sysdeps/linux/common/chdir.c b/libc/sysdeps/linux/common/chdir.c
index 95a825eb7..5328fd2f7 100644
--- a/libc/sysdeps/linux/common/chdir.c
+++ b/libc/sysdeps/linux/common/chdir.c
@@ -8,16 +8,7 @@
*/
#include <sys/syscall.h>
-#include <string.h>
#include <unistd.h>
-#include <sys/param.h>
-libc_hidden_proto(chdir)
-
-#define __NR___syscall_chdir __NR_chdir
-static __inline__ _syscall1(int, __syscall_chdir, const char *, path);
-int chdir(const char *path)
-{
- return __syscall_chdir(path);
-}
+_syscall1(int, chdir, const char *, path)
libc_hidden_def(chdir)
diff --git a/libc/sysdeps/linux/common/chmod.c b/libc/sysdeps/linux/common/chmod.c
index 34a30a4b0..494ec666a 100644
--- a/libc/sysdeps/linux/common/chmod.c
+++ b/libc/sysdeps/linux/common/chmod.c
@@ -9,14 +9,22 @@
#include <sys/syscall.h>
#include <sys/stat.h>
+#include <unistd.h>
-libc_hidden_proto(chmod)
+#if defined __NR_fchmodat && !defined __NR_chmod
+# include <fcntl.h>
+int chmod(const char *path, mode_t mode)
+{
+ return fchmodat(AT_FDCWD, path, mode, 0);
+}
-#define __NR___syscall_chmod __NR_chmod
-static __inline__ _syscall2(int, __syscall_chmod, const char *, path, __kernel_mode_t, mode);
+#else
+# define __NR___syscall_chmod __NR_chmod
+static __inline__ _syscall2(int, __syscall_chmod, const char *, path, __kernel_mode_t, mode)
int chmod(const char *path, mode_t mode)
{
return __syscall_chmod(path, mode);
}
+#endif
libc_hidden_def(chmod)
diff --git a/libc/sysdeps/linux/common/chown.c b/libc/sysdeps/linux/common/chown.c
index 27b89a3f4..b10c1c00b 100644
--- a/libc/sysdeps/linux/common/chown.c
+++ b/libc/sysdeps/linux/common/chown.c
@@ -11,21 +11,28 @@
#include <unistd.h>
#include <bits/wordsize.h>
-libc_hidden_proto(chown)
+#if defined __NR_fchownat && !defined __NR_chown
+# include <fcntl.h>
+int chown(const char *path, uid_t owner, gid_t group)
+{
+ return fchownat(AT_FDCWD, path, owner, group, 0);
+}
-#if (__WORDSIZE == 32 && defined(__NR_chown32)) || __WORDSIZE == 64
-# ifdef __NR_chown32
-# undef __NR_chown
-# define __NR_chown __NR_chown32
-# endif
+#else
-_syscall3(int, chown, const char *, path, uid_t, owner, gid_t, group);
+# if (__WORDSIZE == 32 && defined(__NR_chown32)) || __WORDSIZE == 64
+# ifdef __NR_chown32
+# undef __NR_chown
+# define __NR_chown __NR_chown32
+# endif
-#else
+_syscall3(int, chown, const char *, path, uid_t, owner, gid_t, group)
+
+# else
-# define __NR___syscall_chown __NR_chown
+# define __NR___syscall_chown __NR_chown
static __inline__ _syscall3(int, __syscall_chown, const char *, path,
- __kernel_uid_t, owner, __kernel_gid_t, group);
+ __kernel_uid_t, owner, __kernel_gid_t, group)
int chown(const char *path, uid_t owner, gid_t group)
{
@@ -36,6 +43,7 @@ int chown(const char *path, uid_t owner, gid_t group)
}
return (__syscall_chown(path, owner, group));
}
-#endif
+# endif
+#endif
libc_hidden_def(chown)
diff --git a/libc/sysdeps/linux/common/chroot.c b/libc/sysdeps/linux/common/chroot.c
index 12d09bbbe..4c085f215 100644
--- a/libc/sysdeps/linux/common/chroot.c
+++ b/libc/sysdeps/linux/common/chroot.c
@@ -14,7 +14,7 @@
#if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
#define __NR___syscall_chroot __NR_chroot
-static __inline__ _syscall1(int, __syscall_chroot, const char *, path);
+static __inline__ _syscall1(int, __syscall_chroot, const char *, path)
int chroot(const char *path)
{
diff --git a/libc/sysdeps/linux/common/clock_adjtime.c b/libc/sysdeps/linux/common/clock_adjtime.c
new file mode 100644
index 000000000..9f55d4527
--- /dev/null
+++ b/libc/sysdeps/linux/common/clock_adjtime.c
@@ -0,0 +1,15 @@
+/*
+ * clock_adjtime() for uClibc
+ *
+ * Copyright (C) 2005 by Peter Kjellerstedt <pkj@axis.com>
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <sys/timex.h>
+
+#ifdef __NR_clock_adjtime
+_syscall2(int, clock_adjtime, clockid_t, clock_id, struct timex*, ntx)
+#endif
diff --git a/libc/sysdeps/linux/common/clock_getres.c b/libc/sysdeps/linux/common/clock_getres.c
index 3063b18f6..532047ede 100644
--- a/libc/sysdeps/linux/common/clock_getres.c
+++ b/libc/sysdeps/linux/common/clock_getres.c
@@ -9,12 +9,11 @@
#include <sys/syscall.h>
#include <time.h>
-#include <unistd.h>
#ifdef __NR_clock_getres
-_syscall2(int, clock_getres, clockid_t, clock_id, struct timespec*, res);
+_syscall2(int, clock_getres, clockid_t, clock_id, struct timespec*, res)
#else
-libc_hidden_proto(sysconf)
+# include <unistd.h>
int clock_getres(clockid_t clock_id, struct timespec* res)
{
@@ -40,5 +39,5 @@ int clock_getres(clockid_t clock_id, struct timespec* res)
return retval;
}
-libc_hidden_def(clock_getres)
#endif
+libc_hidden_def(clock_getres)
diff --git a/libc/sysdeps/linux/common/clock_gettime.c b/libc/sysdeps/linux/common/clock_gettime.c
index 38f7ab7ba..95d398239 100644
--- a/libc/sysdeps/linux/common/clock_gettime.c
+++ b/libc/sysdeps/linux/common/clock_gettime.c
@@ -10,12 +10,11 @@
#include <sys/syscall.h>
#include <time.h>
-#include <sys/time.h>
#ifdef __NR_clock_gettime
-_syscall2(int, clock_gettime, clockid_t, clock_id, struct timespec*, tp);
+_syscall2(int, clock_gettime, clockid_t, clock_id, struct timespec*, tp)
#else
-libc_hidden_proto(gettimeofday)
+# include <sys/time.h>
int clock_gettime(clockid_t clock_id, struct timespec* tp)
{
@@ -24,10 +23,12 @@ int clock_gettime(clockid_t clock_id, struct timespec* tp)
switch (clock_id) {
case CLOCK_REALTIME:
- retval = gettimeofday(&tv, NULL);
- if (retval == 0) {
- TIMEVAL_TO_TIMESPEC(&tv, tp);
- }
+ /* In Linux, gettimeofday fails only on bad parameter.
+ * We know that here parameter isn't bad.
+ */
+ gettimeofday(&tv, NULL);
+ TIMEVAL_TO_TIMESPEC(&tv, tp);
+ retval = 0;
break;
default:
diff --git a/libc/sysdeps/linux/common/clock_settime.c b/libc/sysdeps/linux/common/clock_settime.c
index 8ebec7381..636f18417 100644
--- a/libc/sysdeps/linux/common/clock_settime.c
+++ b/libc/sysdeps/linux/common/clock_settime.c
@@ -9,12 +9,11 @@
#include <sys/syscall.h>
#include <time.h>
-#include <sys/time.h>
#ifdef __NR_clock_settime
-_syscall2(int, clock_settime, clockid_t, clock_id, const struct timespec*, tp);
+_syscall2(int, clock_settime, clockid_t, clock_id, const struct timespec*, tp)
#else
-libc_hidden_proto(settimeofday)
+# include <sys/time.h>
int clock_settime(clockid_t clock_id, const struct timespec* tp)
{
diff --git a/libc/sysdeps/linux/common/close.c b/libc/sysdeps/linux/common/close.c
index 430fb34b7..c26525cf4 100644
--- a/libc/sysdeps/linux/common/close.c
+++ b/libc/sysdeps/linux/common/close.c
@@ -9,10 +9,13 @@
#include <sys/syscall.h>
#include <unistd.h>
+#include <cancel.h>
-extern __typeof(close) __libc_close;
-#define __NR___libc_close __NR_close
-_syscall1(int, __libc_close, int, fd);
-libc_hidden_proto(close)
-weak_alias(__libc_close,close)
-libc_hidden_weak(close)
+#define __NR___close_nocancel __NR_close
+_syscall1(int, __NC(close), int, fd)
+
+#define __NR___close_nocancel_no_status __NR_close
+_syscall_noerr1(void, __close_nocancel_no_status, int, fd)
+
+CANCELLABLE_SYSCALL(int, close, (int fd), (fd))
+lt_libc_hidden(close)
diff --git a/libc/sysdeps/linux/common/cmsg_nxthdr.c b/libc/sysdeps/linux/common/cmsg_nxthdr.c
index 8350c3a4d..0b198e1bc 100644
--- a/libc/sysdeps/linux/common/cmsg_nxthdr.c
+++ b/libc/sysdeps/linux/common/cmsg_nxthdr.c
@@ -13,15 +13,15 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
-#define __FORCE_GLIBC
#include <features.h>
+#include <stddef.h>
+/* Prevent math.h from defining a colliding inline */
+#undef __USE_EXTERN_INLINES
#include <sys/socket.h>
-libc_hidden_proto(__cmsg_nxthdr)
struct cmsghdr *
__cmsg_nxthdr (struct msghdr *mhdr, struct cmsghdr *cmsg)
diff --git a/libc/sysdeps/linux/common/creat.c b/libc/sysdeps/linux/common/creat.c
new file mode 100644
index 000000000..17929193e
--- /dev/null
+++ b/libc/sysdeps/linux/common/creat.c
@@ -0,0 +1,18 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * creat() 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 <fcntl.h>
+#include <cancel.h>
+
+int creat(const char *file, mode_t mode)
+{
+ return open(file, O_WRONLY | O_CREAT | O_TRUNC, mode);
+}
+/* open handled cancellation, noop on uClibc */
+LIBC_CANCEL_HANDLED();
diff --git a/libc/sysdeps/linux/common/creat64.c b/libc/sysdeps/linux/common/creat64.c
index f5f00182c..1080f11d4 100644
--- a/libc/sysdeps/linux/common/creat64.c
+++ b/libc/sysdeps/linux/common/creat64.c
@@ -12,24 +12,17 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <_lfs_64.h>
-
-#ifdef __UCLIBC_HAS_LFS__
#include <fcntl.h>
-#include <sys/types.h>
-
-extern __typeof(open64) __libc_open64;
-libc_hidden_proto(__libc_open64)
-extern __typeof(creat64) __libc_creat64;
+#include <cancel.h>
/* Create FILE with protections MODE. */
-int __libc_creat64 (const char *file, mode_t mode)
+int creat64(const char *file, mode_t mode)
{
- return __libc_open64 (file, O_WRONLY|O_CREAT|O_TRUNC, mode);
+ return open64(file, O_WRONLY | O_CREAT | O_TRUNC, mode);
}
-weak_alias(__libc_creat64,creat64)
-#endif /* __UCLIBC_HAS_LFS__ */
+/* open handled cancellation, noop on uClibc */
+LIBC_CANCEL_HANDLED();
diff --git a/libc/sysdeps/linux/common/create_module.c b/libc/sysdeps/linux/common/create_module.c
index 95ff900e0..5bded5636 100644
--- a/libc/sysdeps/linux/common/create_module.c
+++ b/libc/sysdeps/linux/common/create_module.c
@@ -7,10 +7,10 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#include <errno.h>
-#include <unistd.h>
#include <features.h>
-#include <sys/types.h>
+#define __need_size_t
+#include <stddef.h>
+#include <errno.h>
#include <sys/syscall.h>
#ifdef __NR_create_module
@@ -19,10 +19,10 @@ unsigned long create_module(const char *name, size_t size);
#if defined(__UCLIBC_BROKEN_CREATE_MODULE__)
# define __NR___create_module __NR_create_module
-static __inline__ _syscall2(long, __create_module, const char *, name, size_t, size);
+static __inline__ _syscall2(long, __create_module, const char *, name, size_t, size)
/* By checking the value of errno, we know if we have been fooled
* by the syscall2 macro making a very high address look like a
- * negative, so we we fix it up here. */
+ * negative, so we fix it up here. */
unsigned long create_module(const char *name, size_t size)
{
long ret = __create_module(name, size);
@@ -39,21 +39,14 @@ unsigned long create_module(const char *name, size_t size)
/* Alpha doesn't have the same problem, exactly, but a bug in older
kernels fails to clear the error flag. Clear it here explicitly. */
static __inline__ _syscall4(unsigned long, __create_module, const char *, name,
- size_t, size, size_t, dummy, size_t, err);
+ size_t, size, size_t, dummy, size_t, err)
unsigned long create_module(const char *name, size_t size)
{
return __create_module(name, size, 0, 0);
}
#else
/* Sparc, MIPS, etc don't mistake return values for errors. */
-_syscall2(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 a93921411..05841d413 100644
--- a/libc/sysdeps/linux/common/delete_module.c
+++ b/libc/sysdeps/linux/common/delete_module.c
@@ -7,13 +7,7 @@
*/
#include <sys/syscall.h>
-int delete_module(const char *name);
#ifdef __NR_delete_module
-_syscall1(int, delete_module, const char *, name);
-#else
-int delete_module(const char *name)
-{
- __set_errno(ENOSYS);
- return -1;
-}
+int delete_module(const char *name, unsigned int flags);
+_syscall2(int, delete_module, const char *, name, unsigned int, flags)
#endif
diff --git a/libc/sysdeps/linux/common/dl-osinfo.h b/libc/sysdeps/linux/common/dl-osinfo.h
index 5155322e0..3110cb05d 100644
--- a/libc/sysdeps/linux/common/dl-osinfo.h
+++ b/libc/sysdeps/linux/common/dl-osinfo.h
@@ -17,14 +17,11 @@
# endif
# include <stdint.h>
-# include <sys/time.h>
# ifdef IS_IN_libc
-#include <fcntl.h>
-libc_hidden_proto(open)
-libc_hidden_proto(read)
-libc_hidden_proto(close)
-libc_hidden_proto(gettimeofday)
+# include <fcntl.h>
+# include <unistd.h>
+# include <sys/time.h>
# define OPEN open
# define READ read
# define CLOSE close
diff --git a/libc/sysdeps/linux/common/dup.c b/libc/sysdeps/linux/common/dup.c
index ea7f7d0b1..d35176673 100644
--- a/libc/sysdeps/linux/common/dup.c
+++ b/libc/sysdeps/linux/common/dup.c
@@ -8,4 +8,4 @@
#include <sys/syscall.h>
#include <unistd.h>
-_syscall1(int, dup, int, oldfd);
+_syscall1(int, dup, int, oldfd)
diff --git a/libc/sysdeps/linux/common/dup2.c b/libc/sysdeps/linux/common/dup2.c
index 16bcc4221..98ac4e305 100644
--- a/libc/sysdeps/linux/common/dup2.c
+++ b/libc/sysdeps/linux/common/dup2.c
@@ -9,8 +9,24 @@
#include <sys/syscall.h>
#include <unistd.h>
+#if defined __NR_dup3 && !defined __NR_dup2
+# include <fcntl.h>
+extern int __libc_fcntl (int fd, int cmd, ...);
+libc_hidden_proto(__libc_fcntl);
-libc_hidden_proto(dup2)
+int dup2(int old, int newfd)
+{
+ /*
+ * Check if old fd is valid before we try
+ * to ducplicate it. Return it if valid
+ * or EBADF otherwise
+ */
+ if (old == newfd)
+ return fcntl(old, F_GETFL, 0) < 0 ? -1 : newfd;
-_syscall2(int, dup2, int, oldfd, int, newfd);
+ return dup3(old, newfd, 0);
+}
+#else
+_syscall2(int, dup2, int, oldfd, int, newfd)
+#endif
libc_hidden_def(dup2)
diff --git a/libc/sysdeps/linux/common/dup3.c b/libc/sysdeps/linux/common/dup3.c
new file mode 100644
index 000000000..5e8acdc8b
--- /dev/null
+++ b/libc/sysdeps/linux/common/dup3.c
@@ -0,0 +1,16 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * dup3() 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 <unistd.h>
+
+#if defined(__NR_dup3)
+_syscall3(int, dup3, int, oldfd, int, newfd, int, flags)
+libc_hidden_def(dup3)
+#endif
diff --git a/libc/sysdeps/linux/common/epoll.c b/libc/sysdeps/linux/common/epoll.c
index 27f5a7d61..d7b7ca7b3 100644
--- a/libc/sysdeps/linux/common/epoll.c
+++ b/libc/sysdeps/linux/common/epoll.c
@@ -1,6 +1,6 @@
/* vi: set sw=4 ts=4: */
/*
- * epoll_create() / epoll_ctl() / epoll_wait() for uClibc
+ * epoll_create() / epoll_ctl() / epoll_wait() / epoll_pwait() for uClibc
*
* Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
*
@@ -9,42 +9,65 @@
#include <sys/syscall.h>
#include <sys/epoll.h>
+#include <cancel.h>
-/*
- * epoll_create()
- */
-#ifdef __NR_epoll_create
-_syscall1(int, epoll_create, int, size);
-#else
+#ifdef L_epoll_create
+# ifdef __NR_epoll_create
+_syscall1(int, epoll_create, int, size)
+# endif
+
+# ifdef __NR_epoll_create1
+_syscall1(int, epoll_create1, int, flags)
+# endif
+
+# if defined __NR_epoll_create1 && !defined __NR_epoll_create
int epoll_create(int size)
{
- __set_errno(ENOSYS);
- return -1;
+ return INLINE_SYSCALL(epoll_create1, 1, 0);
}
+# endif
#endif
-/*
- * epoll_ctl()
- */
-#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)
+#if defined L_epoll_ctl && defined __NR_epoll_ctl
+_syscall4(int, epoll_ctl, int, epfd, int, op, int, fd, struct epoll_event *, event)
+#endif
+
+#if defined L_epoll_pwait && defined __NR_epoll_pwait
+# include <signal.h>
+
+# define __NR___syscall_epoll_pwait __NR_epoll_pwait
+static __always_inline _syscall6(int, __syscall_epoll_pwait, int, epfd, struct epoll_event *, events,
+ int, maxevents, int, timeout, const sigset_t *, sigmask, size_t, sigsetsize)
+
+static int __NC(epoll_pwait)(int epfd, struct epoll_event *events, int maxevents, int timeout,
+ const sigset_t *set)
{
- __set_errno(ENOSYS);
- return -1;
+ return __syscall_epoll_pwait(epfd, events, maxevents, timeout, set, __SYSCALL_SIGSET_T_SIZE);
}
+CANCELLABLE_SYSCALL(int, epoll_pwait, (int epfd, struct epoll_event *events, int maxevents, int timeout,
+ const sigset_t *set),
+ (epfd, events, maxevents, timeout, set))
#endif
+#if defined L_epoll_wait
+# if defined __NR_epoll_wait
+static int __NC(epoll_wait)(int epfd, struct epoll_event *events, int maxevents, int timeout)
+{
+ return INLINE_SYSCALL(epoll_wait, 4, epfd, events, maxevents, timeout);
+}
+CANCELLABLE_SYSCALL(int, epoll_wait, (int epfd, struct epoll_event *events, int maxevents, int timeout),
+ (epfd, events, maxevents, timeout))
+
+
+# elif /* !defined L_epoll_wait && */ defined __NR_epoll_pwait
/*
- * epoll_wait()
+ * If epoll_wait is not defined, then call epoll_pwait instead using NULL
+ * for sigmask argument
*/
-#ifdef __NR_epoll_wait
-_syscall4(int, epoll_wait, int, epfd, struct epoll_event *, events, int, maxevents, int, timeout);
-#else
+# include <stddef.h>
int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout)
{
- __set_errno(ENOSYS);
- return -1;
+ return INLINE_SYSCALL(epoll_pwait, 5, epfd, events, maxevents, timeout, NULL);
}
+# endif
#endif
diff --git a/libc/sysdeps/linux/common/epoll_create.c b/libc/sysdeps/linux/common/epoll_create.c
new file mode 100644
index 000000000..80896f684
--- /dev/null
+++ b/libc/sysdeps/linux/common/epoll_create.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_epoll_create
+#include "epoll.c"
diff --git a/libc/sysdeps/linux/common/epoll_ctl.c b/libc/sysdeps/linux/common/epoll_ctl.c
new file mode 100644
index 000000000..53868cc10
--- /dev/null
+++ b/libc/sysdeps/linux/common/epoll_ctl.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_epoll_ctl
+#include "epoll.c"
diff --git a/libc/sysdeps/linux/common/epoll_pwait.c b/libc/sysdeps/linux/common/epoll_pwait.c
new file mode 100644
index 000000000..07461f974
--- /dev/null
+++ b/libc/sysdeps/linux/common/epoll_pwait.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_epoll_pwait
+#include "epoll.c"
diff --git a/libc/sysdeps/linux/common/epoll_wait.c b/libc/sysdeps/linux/common/epoll_wait.c
new file mode 100644
index 000000000..6963447fb
--- /dev/null
+++ b/libc/sysdeps/linux/common/epoll_wait.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_epoll_wait
+#include "epoll.c"
diff --git a/libc/sysdeps/linux/common/euidaccess.c b/libc/sysdeps/linux/common/euidaccess.c
new file mode 100644
index 000000000..b84295234
--- /dev/null
+++ b/libc/sysdeps/linux/common/euidaccess.c
@@ -0,0 +1,9 @@
+#include <unistd.h>
+#include <fcntl.h>
+
+int euidaccess(const char *filename, int amode)
+{
+ return faccessat(AT_FDCWD, filename, amode, AT_EACCESS);
+}
+
+weak_alias(euidaccess, eaccess);
diff --git a/libc/sysdeps/linux/common/eventfd.c b/libc/sysdeps/linux/common/eventfd.c
new file mode 100644
index 000000000..500b0c002
--- /dev/null
+++ b/libc/sysdeps/linux/common/eventfd.c
@@ -0,0 +1,30 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * eventfd() for uClibc
+ *
+ * Copyright (C) 2011 Jean-Christian de Rivaz <jc@eclis.ch>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <errno.h>
+#include <sys/syscall.h>
+#include <sys/eventfd.h>
+
+/*
+ * eventfd()
+ */
+#if defined __NR_eventfd || defined __NR_eventfd2
+int eventfd (unsigned int count, int flags)
+{
+#if defined __NR_eventfd2
+ return INLINE_SYSCALL (eventfd2, 2, count, flags);
+#elif defined __NR_eventfd
+ if (flags != 0) {
+ __set_errno (EINVAL);
+ return -1;
+ }
+ return INLINE_SYSCALL (eventfd, 1, count);
+#endif
+}
+#endif
diff --git a/libc/sysdeps/linux/e1/bits/wordsize.h b/libc/sysdeps/linux/common/eventfd_read.c
index a56d3ef5c..75f2aaa11 100644
--- a/libc/sysdeps/linux/e1/bits/wordsize.h
+++ b/libc/sysdeps/linux/common/eventfd_read.c
@@ -1,8 +1,5 @@
-/* Copyright (C) 2002-2003, George Thanos <george.thanos@gdt.gr>
- Yannis Mitsos <yannis.mitsos@gdt.gr>
-
- Copyright (C) 1999 Free Software Foundation, Inc.
- This file is part of the GNU C library.
+/* Copyright (C) 2007-2014 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
@@ -15,8 +12,16 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <unistd.h>
+#include <sys/eventfd.h>
+
-#define __WORDSIZE 32
+int
+eventfd_read (int fd, eventfd_t *value)
+{
+ return read (fd, value, sizeof (eventfd_t)) != sizeof (eventfd_t) ? -1 : 0;
+}
diff --git a/libc/sysdeps/linux/common/eventfd_write.c b/libc/sysdeps/linux/common/eventfd_write.c
new file mode 100644
index 000000000..e1509cf5c
--- /dev/null
+++ b/libc/sysdeps/linux/common/eventfd_write.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 2007-2014 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <unistd.h>
+#include <sys/eventfd.h>
+
+
+int
+eventfd_write (int fd, eventfd_t value)
+{
+ return write (fd, &value,
+ sizeof (eventfd_t)) != sizeof (eventfd_t) ? -1 : 0;
+}
diff --git a/libc/sysdeps/linux/common/execve.c b/libc/sysdeps/linux/common/execve.c
index 6bc72dde9..e8568df2b 100644
--- a/libc/sysdeps/linux/common/execve.c
+++ b/libc/sysdeps/linux/common/execve.c
@@ -12,7 +12,6 @@
#include <string.h>
#include <sys/param.h>
-libc_hidden_proto(execve)
_syscall3(int, execve, const char *, filename,
- char *const *, argv, char *const *, envp);
+ char *const *, argv, char *const *, envp)
libc_hidden_def(execve)
diff --git a/libc/sysdeps/linux/common/faccessat.c b/libc/sysdeps/linux/common/faccessat.c
new file mode 100644
index 000000000..156df64a5
--- /dev/null
+++ b/libc/sysdeps/linux/common/faccessat.c
@@ -0,0 +1,17 @@
+/*
+ * faccessat() for uClibc
+ *
+ * Copyright (C) 2009 Analog Devices Inc.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <unistd.h>
+
+#ifdef __NR_faccessat
+_syscall4(int, faccessat, int, fd, const char *, file, int, type, int, flag)
+libc_hidden_def(faccessat)
+#else
+/* should add emulation with faccess() and /proc/self/fd/ ... */
+#endif
diff --git a/libc/sysdeps/linux/common/fallocate.c b/libc/sysdeps/linux/common/fallocate.c
new file mode 100644
index 000000000..0f80fb4c2
--- /dev/null
+++ b/libc/sysdeps/linux/common/fallocate.c
@@ -0,0 +1,43 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * fallocate() for uClibc - Based off of posix_fallocate() by Erik Andersen
+ * http://www.opengroup.org/onlinepubs/9699919799/functions/posix_fallocate.html
+ *
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <fcntl.h>
+#include <bits/kernel-features.h>
+#include <stdint.h>
+#include <errno.h>
+
+#if defined __NR_fallocate
+extern __typeof(fallocate) __libc_fallocate attribute_hidden;
+int attribute_hidden __libc_fallocate(int fd, int mode, __off_t offset, __off_t len)
+{
+# if __WORDSIZE == 32
+ return fallocate64(fd, mode, offset, len);
+# elif __WORDSIZE == 64
+ int ret;
+ INTERNAL_SYSCALL_DECL(err);
+ ret = (int) (INTERNAL_SYSCALL(fallocate, err, 4, fd, mode, offset, len));
+ if (unlikely(INTERNAL_SYSCALL_ERROR_P (ret, err))) {
+ __set_errno(INTERNAL_SYSCALL_ERRNO (ret, err));
+ ret = -1;
+ }
+ return ret;
+# else
+# error your machine is neither 32 bit or 64 bit ... it must be magical
+# endif
+}
+
+# if defined __UCLIBC_LINUX_SPECIFIC__ && defined __USE_GNU
+strong_alias(__libc_fallocate,fallocate)
+# if __WORDSIZE == 64
+strong_alias(__libc_fallocate,fallocate64)
+# endif
+# endif
+#endif
diff --git a/libc/sysdeps/linux/common/fallocate64.c b/libc/sysdeps/linux/common/fallocate64.c
new file mode 100644
index 000000000..1aa351ebe
--- /dev/null
+++ b/libc/sysdeps/linux/common/fallocate64.c
@@ -0,0 +1,45 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * fallocate() for uClibc - based off posix_fallocate() by Erik Andersen
+ * http://www.opengroup.org/onlinepubs/9699919799/functions/posix_fallocate.html
+ *
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+
+#include <fcntl.h>
+#include <bits/kernel-features.h>
+#include <stdint.h>
+#include <errno.h>
+
+#if defined __NR_fallocate
+
+# if __WORDSIZE == 64
+/* Can use normal fallocate() */
+# elif __WORDSIZE == 32
+extern __typeof(fallocate64) __libc_fallocate64 attribute_hidden;
+int attribute_hidden __libc_fallocate64(int fd, int mode, __off64_t offset,
+ __off64_t len)
+{
+ int ret;
+ INTERNAL_SYSCALL_DECL(err);
+ ret = (int) (INTERNAL_SYSCALL(fallocate, err, 6, fd, mode,
+ OFF64_HI_LO (offset), OFF64_HI_LO (len)));
+ if (unlikely(INTERNAL_SYSCALL_ERROR_P (ret, err))) {
+ __set_errno(INTERNAL_SYSCALL_ERRNO (ret, err));
+ ret = -1;
+ }
+ return ret;
+}
+
+# if defined __UCLIBC_LINUX_SPECIFIC__ && defined __USE_GNU
+strong_alias(__libc_fallocate64,fallocate64)
+# endif
+
+# else
+# error your machine is neither 32 bit or 64 bit ... it must be magical
+# endif
+#endif
diff --git a/libc/sysdeps/linux/common/fanotify.c b/libc/sysdeps/linux/common/fanotify.c
new file mode 100644
index 000000000..431e0e591
--- /dev/null
+++ b/libc/sysdeps/linux/common/fanotify.c
@@ -0,0 +1,32 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * fanotify interface for uClibc
+ *
+ * Copyright (C) 2015 by Bartosz Golaszewski <bartekgola@gmail.com>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <sys/fanotify.h>
+
+#ifdef __NR_fanotify_init
+_syscall2(int, fanotify_init, unsigned int, flags, unsigned int, event_f_flags)
+#endif
+
+#ifdef __NR_fanotify_mark
+# include <bits/wordsize.h>
+# include <fcntl.h>
+
+# if __WORDSIZE == 64
+_syscall5(int, fanotify_mark, int, fanotify_fd, unsigned int, flags,
+ uint64_t, mask, int, dirfd, const char *, pathname)
+# else
+int fanotify_mark(int fanotify_fd, unsigned int flags,
+ uint64_t mask, int dirfd, const char *pathname)
+{
+ return INLINE_SYSCALL(fanotify_mark, 6, fanotify_fd, flags,
+ OFF64_HI_LO(mask), dirfd, pathname);
+}
+# endif
+#endif
diff --git a/libc/sysdeps/linux/common/fchdir.c b/libc/sysdeps/linux/common/fchdir.c
index 15c7dbd73..05e9890c8 100644
--- a/libc/sysdeps/linux/common/fchdir.c
+++ b/libc/sysdeps/linux/common/fchdir.c
@@ -10,7 +10,7 @@
#include <sys/syscall.h>
#include <unistd.h>
-libc_hidden_proto(fchdir)
-
-_syscall1(int, fchdir, int, fd);
+#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
+_syscall1(int, fchdir, int, fd)
libc_hidden_def(fchdir)
+#endif
diff --git a/libc/sysdeps/linux/common/fchmod.c b/libc/sysdeps/linux/common/fchmod.c
index cb0058133..791f530b6 100644
--- a/libc/sysdeps/linux/common/fchmod.c
+++ b/libc/sysdeps/linux/common/fchmod.c
@@ -12,7 +12,7 @@
#define __NR___syscall_fchmod __NR_fchmod
static __inline__ _syscall2(int, __syscall_fchmod,
- int, fildes, __kernel_mode_t, mode);
+ int, fildes, __kernel_mode_t, mode)
int fchmod(int fildes, mode_t mode)
{
diff --git a/libc/sysdeps/linux/common/fchmodat.c b/libc/sysdeps/linux/common/fchmodat.c
new file mode 100644
index 000000000..1e936e039
--- /dev/null
+++ b/libc/sysdeps/linux/common/fchmodat.c
@@ -0,0 +1,38 @@
+/*
+ * fchmodat() for uClibc
+ *
+ * Copyright (C) 2009 Analog Devices Inc.
+ * Copyright (C) 2012 Mike Frysinger
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <fcntl.h>
+#include <sys/syscall.h>
+#include <sys/stat.h>
+
+#ifdef __NR_fchmodat
+/*
+ * The kernel takes 3 args, but userland takes 4.
+ * We have to process all the flags ourselves.
+ */
+int fchmodat(int fd, const char *file, mode_t mode, int flag)
+{
+ /* We only support one flag atm ... */
+ if (flag & ~AT_SYMLINK_NOFOLLOW) {
+ __set_errno(EINVAL);
+ return -1;
+ }
+
+ /* ... but Linux doesn't support perms on symlinks. */
+ if (flag & AT_SYMLINK_NOFOLLOW) {
+ __set_errno(ENOTSUP);
+ return -1;
+ }
+
+ return INLINE_SYSCALL(fchmodat, 3, fd, file, mode);
+}
+libc_hidden_def(fchmodat)
+#else
+/* should add emulation with fchmod() and /proc/self/fd/ ... */
+#endif
diff --git a/libc/sysdeps/linux/common/fchown.c b/libc/sysdeps/linux/common/fchown.c
index 31111ca54..61618dcff 100644
--- a/libc/sysdeps/linux/common/fchown.c
+++ b/libc/sysdeps/linux/common/fchown.c
@@ -17,13 +17,13 @@
# define __NR_fchown __NR_fchown32
# endif
-_syscall3(int, fchown, int, fd, uid_t, owner, gid_t, group);
+_syscall3(int, fchown, int, fd, uid_t, owner, gid_t, group)
#else
# define __NR___syscall_fchown __NR_fchown
static __inline__ _syscall3(int, __syscall_fchown, int, fd,
- __kernel_uid_t, owner, __kernel_gid_t, group);
+ __kernel_uid_t, owner, __kernel_gid_t, group)
int fchown(int fd, uid_t owner, gid_t group)
{
diff --git a/libc/sysdeps/linux/common/fchownat.c b/libc/sysdeps/linux/common/fchownat.c
new file mode 100644
index 000000000..4ad818b74
--- /dev/null
+++ b/libc/sysdeps/linux/common/fchownat.c
@@ -0,0 +1,17 @@
+/*
+ * fchownat() for uClibc
+ *
+ * Copyright (C) 2009 Analog Devices Inc.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <unistd.h>
+
+#ifdef __NR_fchownat
+_syscall5(int, fchownat, int, fd, const char *, file, uid_t, owner, gid_t, group, int, flag)
+libc_hidden_def(fchownat)
+#else
+/* should add emulation with fchown() and /proc/self/fd/ ... */
+#endif
diff --git a/libc/sysdeps/linux/common/fdatasync.c b/libc/sysdeps/linux/common/fdatasync.c
index 774433f17..6c2f4f9f3 100644
--- a/libc/sysdeps/linux/common/fdatasync.c
+++ b/libc/sysdeps/linux/common/fdatasync.c
@@ -8,10 +8,17 @@
*/
#include <sys/syscall.h>
-#include <unistd.h>
-#if defined __NR_osf_fdatasync
+#if !defined __NR_fdatasync && defined __NR_osf_fdatasync
# define __NR_fdatasync __NR_osf_fdatasync
#endif
-_syscall1(int, fdatasync, int, fd);
+#ifdef __NR_fdatasync
+# include <unistd.h>
+# include <cancel.h>
+
+# define __NR___fdatasync_nocancel __NR_fdatasync
+static _syscall1(int, __NC(fdatasync), int, fd)
+
+CANCELLABLE_SYSCALL(int, fdatasync, (int fd), (fd))
+#endif
diff --git a/libc/sysdeps/linux/common/flock.c b/libc/sysdeps/linux/common/flock.c
index 9b275d031..3dcd1aee1 100644
--- a/libc/sysdeps/linux/common/flock.c
+++ b/libc/sysdeps/linux/common/flock.c
@@ -11,7 +11,7 @@
#include <sys/file.h>
#define __NR___syscall_flock __NR_flock
-static __inline__ _syscall2(int, __syscall_flock, int, fd, int, operation);
+static __inline__ _syscall2(int, __syscall_flock, int, fd, int, operation)
int flock(int fd, int operation)
{
diff --git a/libc/sysdeps/linux/common/fork.c b/libc/sysdeps/linux/common/fork.c
index b4fa3686d..b5715c7a0 100644
--- a/libc/sysdeps/linux/common/fork.c
+++ b/libc/sysdeps/linux/common/fork.c
@@ -8,29 +8,35 @@
*/
#include <sys/syscall.h>
-#include <unistd.h>
-#ifdef __ARCH_USE_MMU__
-
-#ifdef __NR_fork
+#if defined __ARCH_USE_MMU__
+# include <unistd.h>
extern __typeof(fork) __libc_fork;
-#define __NR___libc_fork __NR_fork
-_syscall0(pid_t, __libc_fork);
-libc_hidden_proto(fork)
-weak_alias(__libc_fork,fork)
-libc_hidden_weak(fork)
-#endif
-
-#elif defined __UCLIBC_HAS_STUBS__
+# if defined __NR_fork
+# include <cancel.h>
+# define __NR___libc_fork __NR_fork
+_syscall0(pid_t, fork)
-pid_t __libc_fork(void)
+# elif defined __NR_clone && !defined __NR_fork
+# include <sys/types.h>
+# include <signal.h>
+# include <stddef.h>
+pid_t fork(void)
{
- __set_errno(ENOSYS);
- return -1;
+ pid_t pid = INLINE_SYSCALL(clone, 4, SIGCHLD, NULL, NULL, NULL);
+
+ if (pid < 0)
+ return -1;
+
+ return pid;
}
-libc_hidden_proto(fork)
-weak_alias(__libc_fork,fork)
+
+# endif
+# ifdef __UCLIBC_HAS_THREADS__
+strong_alias(fork,__libc_fork)
libc_hidden_weak(fork)
-link_warning(fork, "fork: this function is not implemented on no-mmu systems")
+# else
+libc_hidden_def(fork)
+# endif
#endif
diff --git a/libc/sysdeps/linux/common/fpu_control.h b/libc/sysdeps/linux/common/fpu_control.h
index de261c2eb..cbcb2c2d7 100644
--- a/libc/sysdeps/linux/common/fpu_control.h
+++ b/libc/sysdeps/linux/common/fpu_control.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FPU_CONTROL_H
#define _FPU_CONTROL_H
diff --git a/libc/sysdeps/linux/common/fstat.c b/libc/sysdeps/linux/common/fstat.c
index fee750aa4..696f79ea7 100644
--- a/libc/sysdeps/linux/common/fstat.c
+++ b/libc/sysdeps/linux/common/fstat.c
@@ -7,38 +7,58 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-/* need to hide the 64bit prototype or the strong_alias()
- * will fail when __NR_fstat64 doesnt exist */
-#define fstat64 __hidefstat64
-
#include <sys/syscall.h>
#include <unistd.h>
#include <sys/stat.h>
#include "xstatconv.h"
-#undef fstat64
-
-libc_hidden_proto(fstat)
-
-#define __NR___syscall_fstat __NR_fstat
-static __inline__ _syscall2(int, __syscall_fstat, int, fd, struct kernel_stat *, buf);
+#if defined __NR_fstat64 && !defined __NR_fstat
+int fstat(int fd, struct stat *buf)
+{
+ int result = INLINE_SYSCALL(fstat64, 2, fd, buf);
+ if (result == 0) {
+ /* Did we overflow? */
+ if (buf->__pad1 || buf->__pad2 || buf->__pad3
+ || buf->__pad4 || buf->__pad5
+ || buf->__pad6 || buf->__pad7) {
+ __set_errno(EOVERFLOW);
+ return -1;
+ }
+ }
+ return result;
+}
+libc_hidden_def(fstat)
+#elif defined __NR_fstat
int fstat(int fd, struct stat *buf)
{
int result;
+# ifdef __NR_fstat64
+ /* normal stat call has limited values for various stat elements
+ * e.g. uid device major/minor etc.
+ * so we use 64 variant if available
+ * in order to get newer versions of stat elements
+ */
+ struct kernel_stat64 kbuf;
+ result = INLINE_SYSCALL(fstat64, 2, fd, &kbuf);
+ if (result == 0) {
+ __xstat32_conv(&kbuf, buf);
+ }
+# else
struct kernel_stat kbuf;
- result = __syscall_fstat(fd, &kbuf);
+ result = INLINE_SYSCALL(fstat, 2, fd, &kbuf);
if (result == 0) {
__xstat_conv(&kbuf, buf);
}
+# endif
return result;
}
libc_hidden_def(fstat)
-#if ! defined __NR_fstat64 && defined __UCLIBC_HAS_LFS__
-extern __typeof(fstat) fstat64;
-libc_hidden_proto(fstat64)
-strong_alias(fstat,fstat64)
+# if ! defined __NR_fstat64 && defined __UCLIBC_HAS_LFS__
+strong_alias_untyped(fstat,fstat64)
libc_hidden_def(fstat64)
+# endif
+
#endif
diff --git a/libc/sysdeps/linux/common/fstat64.c b/libc/sysdeps/linux/common/fstat64.c
index 67c519a8b..aaaf03e66 100644
--- a/libc/sysdeps/linux/common/fstat64.c
+++ b/libc/sysdeps/linux/common/fstat64.c
@@ -7,21 +7,20 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+#include <_lfs_64.h>
#include <sys/syscall.h>
-#if defined __UCLIBC_HAS_LFS__ && defined __NR_fstat64
-#include <unistd.h>
-#include <sys/stat.h>
-#include "xstatconv.h"
-
-libc_hidden_proto(fstat64)
-
-#define __NR___syscall_fstat64 __NR_fstat64
-static __inline__ _syscall2(int, __syscall_fstat64,
- int, filedes, struct kernel_stat64 *, buf);
+#ifdef __NR_fstat64
+# include <unistd.h>
+# include <sys/stat.h>
+# include "xstatconv.h"
+# define __NR___syscall_fstat64 __NR_fstat64
+static __always_inline _syscall2(int, __syscall_fstat64,
+ int, filedes, struct kernel_stat64 *, buf)
int fstat64(int fd, struct stat64 *buf)
{
+#ifdef __ARCH_HAS_DEPRECATED_SYSCALLS__
int result;
struct kernel_stat64 kbuf;
@@ -30,6 +29,9 @@ int fstat64(int fd, struct stat64 *buf)
__xstat64_conv(&kbuf, buf);
}
return result;
+#else
+ return __syscall_fstat64(fd, buf);
+#endif
}
libc_hidden_def(fstat64)
#endif
diff --git a/libc/sysdeps/linux/common/fstatat.c b/libc/sysdeps/linux/common/fstatat.c
new file mode 100644
index 000000000..4006814f0
--- /dev/null
+++ b/libc/sysdeps/linux/common/fstatat.c
@@ -0,0 +1,44 @@
+/*
+ * fstatat() for uClibc
+ *
+ * Copyright (C) 2009 Analog Devices Inc.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <sys/stat.h>
+#include "xstatconv.h"
+
+/* 64bit ports tend to favor newfstatat() */
+#if __WORDSIZE == 64 && defined __NR_newfstatat
+# define __NR_fstatat64 __NR_newfstatat
+#endif
+
+#ifdef __NR_fstatat64
+int fstatat(int fd, const char *file, struct stat *buf, int flag)
+{
+ int ret;
+# ifdef __ARCH_HAS_DEPRECATED_SYSCALLS__
+ struct kernel_stat64 kbuf;
+ ret = INLINE_SYSCALL(fstatat64, 4, fd, file, &kbuf, flag);
+ if (ret == 0)
+ __xstat32_conv(&kbuf, buf);
+# else
+ ret = INLINE_SYSCALL(fstatat64, 4, fd, file, buf, flag);
+ if (ret == 0) {
+ /* Did we overflow */
+ if (buf->__pad1 || buf->__pad2 || buf->__pad3
+ || buf->__pad4 || buf->__pad5 || buf->__pad6
+ || buf->__pad7) {
+ __set_errno(EOVERFLOW);
+ return -1;
+ }
+ }
+# endif /* __ARCH_HAS_DEPRECATED_SYSCALLS__ */
+ return ret;
+}
+libc_hidden_def(fstatat)
+#else
+/* should add emulation with fstat() and /proc/self/fd/ ... */
+#endif
diff --git a/libc/sysdeps/linux/common/fstatat64.c b/libc/sysdeps/linux/common/fstatat64.c
new file mode 100644
index 000000000..711521a6a
--- /dev/null
+++ b/libc/sysdeps/linux/common/fstatat64.c
@@ -0,0 +1,47 @@
+/*
+ * fstatat64() for uClibc
+ *
+ * Copyright (C) 2009 Analog Devices Inc.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <_lfs_64.h>
+#include <bits/wordsize.h>
+#include <sys/syscall.h>
+
+#if defined __mips__
+# include <sgidefs.h>
+#endif
+
+/* 64bit ports tend to favor newfstatat() */
+#if __WORDSIZE == 64 && defined __NR_newfstatat
+# define __NR_fstatat64 __NR_newfstatat
+#endif
+/* mips N32 ABI use newfstatat(), too */
+#if defined __mips__ && _MIPS_SIM == _ABIN32
+# define __NR_fstatat64 __NR_newfstatat
+#endif
+
+#ifdef __NR_fstatat64
+# include <sys/stat.h>
+# include "xstatconv.h"
+int fstatat64(int fd, const char *file, struct stat64 *buf, int flag)
+{
+# ifdef __ARCH_HAS_DEPRECATED_SYSCALLS__
+ int ret;
+ struct kernel_stat64 kbuf;
+
+ ret = INLINE_SYSCALL(fstatat64, 4, fd, file, &kbuf, flag);
+ if (ret == 0)
+ __xstat64_conv(&kbuf, buf);
+
+ return ret;
+# else
+ return INLINE_SYSCALL(fstatat64, 4, fd, file, buf, flag);
+# endif
+}
+libc_hidden_def(fstatat64)
+#else
+/* should add emulation with fstat64() and /proc/self/fd/ ... */
+#endif
diff --git a/libc/sysdeps/linux/common/fstatfs.c b/libc/sysdeps/linux/common/fstatfs.c
index 8a471d36f..111a399bc 100644
--- a/libc/sysdeps/linux/common/fstatfs.c
+++ b/libc/sysdeps/linux/common/fstatfs.c
@@ -9,8 +9,9 @@
#include <sys/syscall.h>
#include <sys/vfs.h>
+#include <string.h>
-#ifndef __USE_FILE_OFFSET64
+#ifndef __USE_FILE_OFFSET64__
extern int fstatfs (int __fildes, struct statfs *__buf)
__THROW __nonnull ((2));
#else
@@ -22,14 +23,28 @@ extern int __REDIRECT_NTH (fstatfs, (int __fildes, struct statfs *__buf),
# endif
#endif
-extern __typeof(fstatfs) __libc_fstatfs;
-libc_hidden_proto(__libc_fstatfs)
-#define __NR___libc_fstatfs __NR_fstatfs
-_syscall2(int, __libc_fstatfs, int, fd, struct statfs *, buf);
-libc_hidden_def(__libc_fstatfs)
+extern __typeof(fstatfs) __libc_fstatfs attribute_hidden;
+#ifdef __NR_fstatfs
+# define __NR___libc_fstatfs __NR_fstatfs
+_syscall2(int, __libc_fstatfs, int, fd, struct statfs *, buf)
+#else
+int __libc_fstatfs (int __fildes, struct statfs *__buf)
+{
+ int err = INLINE_SYSCALL(fstatfs64, 3, __fildes, sizeof(*__buf), __buf);
+
+ if (err == 0) {
+ /* Did we overflow? */
+ if (__buf->__pad1 || __buf->__pad2 || __buf->__pad3 ||
+ __buf->__pad4 || __buf->__pad5) {
+ __set_errno(EOVERFLOW);
+ return -1;
+ }
+ }
+ return err;
+};
+/* Redefined fstatfs because we need it for backwards compatibility */
+#endif /* __NR_fstatfs */
#if defined __UCLIBC_LINUX_SPECIFIC__
-libc_hidden_proto(fstatfs)
weak_alias(__libc_fstatfs,fstatfs)
-libc_hidden_weak(fstatfs)
#endif
diff --git a/libc/sysdeps/linux/common/fsync.c b/libc/sysdeps/linux/common/fsync.c
index 6a2587e67..f13a1e64f 100644
--- a/libc/sysdeps/linux/common/fsync.c
+++ b/libc/sysdeps/linux/common/fsync.c
@@ -9,8 +9,9 @@
#include <sys/syscall.h>
#include <unistd.h>
+#include <cancel.h>
-extern __typeof(fsync) __libc_fsync;
-#define __NR___libc_fsync __NR_fsync
-_syscall1(int, __libc_fsync, int, fd);
-weak_alias(__libc_fsync, fsync)
+#define __NR___fsync_nocancel __NR_fsync
+static _syscall1(int, __NC(fsync), int, fd)
+
+CANCELLABLE_SYSCALL(int, fsync, (int fd), (fd))
diff --git a/libc/sysdeps/linux/common/ftruncate.c b/libc/sysdeps/linux/common/ftruncate.c
index 951720ba8..96076e449 100644
--- a/libc/sysdeps/linux/common/ftruncate.c
+++ b/libc/sysdeps/linux/common/ftruncate.c
@@ -10,7 +10,20 @@
#include <sys/syscall.h>
#include <unistd.h>
-libc_hidden_proto(ftruncate)
+#if defined __NR_ftruncate64 && !defined __NR_ftruncate
+# include <endian.h>
+# include <stdint.h>
+int ftruncate(int fd, __off_t length)
+{
+# if defined __UCLIBC_HAS_LFS__
+ return ftruncate64(fd, length);
+# elif __WORDSIZE == 32
+ return INLINE_SYSCALL(ftruncate64, 3, fd, OFF_HI_LO(length));
+# endif
+}
+libc_hidden_def(ftruncate);
-_syscall2(int, ftruncate, int, fd, __off_t, length);
+#else
+_syscall2(int, ftruncate, int, fd, __off_t, length)
libc_hidden_def(ftruncate)
+#endif
diff --git a/libc/sysdeps/linux/common/ftruncate64.c b/libc/sysdeps/linux/common/ftruncate64.c
index 04cdc0a99..231d94a33 100644
--- a/libc/sysdeps/linux/common/ftruncate64.c
+++ b/libc/sysdeps/linux/common/ftruncate64.c
@@ -7,64 +7,41 @@
* and on 32 bit machines this sends things into the kernel as
* two 32-bit arguments (high and low 32 bits of length) that
* are ordered based on endianess. It turns out endian.h has
- * just the macro we need to order things, __LONG_LONG_PAIR.
+ * just the macro we need to order things, OFF64_HI_LO.
*/
-#include <features.h>
+#include <_lfs_64.h>
+#include <sys/syscall.h>
+#include <unistd.h>
-#ifdef __UCLIBC_HAS_LFS__
+#ifdef __NR_ftruncate64
+# include <bits/wordsize.h>
-# include <unistd.h>
-# include <errno.h>
-# include <endian.h>
-# include <stdint.h>
-# include <sys/types.h>
-# include <sys/syscall.h>
-
-libc_hidden_proto(ftruncate64)
-
-# ifdef __NR_ftruncate64
-
-# if __WORDSIZE == 64
+# if __WORDSIZE == 64
/* For a 64 bit machine, life is simple... */
-_syscall2(int, ftruncate64, int, fd, __off64_t, length);
+_syscall2(int, ftruncate64, int, fd, __off64_t, length)
-# elif __WORDSIZE == 32
-
-# ifndef INLINE_SYSCALL
-# define INLINE_SYSCALL(name, nr, args...) __syscall_ftruncate64 (args)
-# define __NR___syscall_ftruncate64 __NR_ftruncate64
-# if defined(__UCLIBC_TRUNCATE64_HAS_4_ARGS__)
-static __inline__ _syscall4(int, __syscall_ftruncate64, int, fd, uint32_t, pad,
- unsigned long, high_length, unsigned long, low_length);
-# else
-static __inline__ _syscall3(int, __syscall_ftruncate64, int, fd,
- unsigned long, high_length, unsigned long, low_length);
-# endif
-# endif
+# elif __WORDSIZE == 32
+# include <endian.h>
+# include <stdint.h>
/* The exported ftruncate64 function. */
int ftruncate64 (int fd, __off64_t length)
{
- uint32_t low = length & 0xffffffff;
- uint32_t high = length >> 32;
-# if defined(__UCLIBC_TRUNCATE64_HAS_4_ARGS__)
- return INLINE_SYSCALL(ftruncate64,
- 4, fd, 0, __LONG_LONG_PAIR (high, low));
-# else
- return INLINE_SYSCALL(ftruncate64, 3, fd,
- __LONG_LONG_PAIR (high, low));
-# endif
+# if defined(__UCLIBC_SYSCALL_ALIGN_64BIT__)
+ return INLINE_SYSCALL(ftruncate64, 4, fd, 0, OFF64_HI_LO(length));
+# else
+ return INLINE_SYSCALL(ftruncate64, 3, fd, OFF64_HI_LO(length));
+# endif
}
-# else /* __WORDSIZE */
-# error Your machine is not 64 bit or 32 bit, I am dazed and confused.
-# endif /* __WORDSIZE */
-
-# else /* __NR_ftruncate64 */
+# else /* __WORDSIZE */
+# error Your machine is not 64 bit or 32 bit, I am dazed and confused.
+# endif /* __WORDSIZE */
-libc_hidden_proto(ftruncate)
+#else /* __NR_ftruncate64 */
+# include <errno.h>
int ftruncate64 (int fd, __off64_t length)
{
@@ -79,7 +56,5 @@ int ftruncate64 (int fd, __off64_t length)
return -1;
}
-# endif /* __NR_ftruncate64 */
+#endif /* __NR_ftruncate64 */
libc_hidden_def(ftruncate64)
-
-#endif /* __UCLIBC_HAS_LFS__ */
diff --git a/libc/sysdeps/linux/common/futimens.c b/libc/sysdeps/linux/common/futimens.c
new file mode 100644
index 000000000..b825cf7ac
--- /dev/null
+++ b/libc/sysdeps/linux/common/futimens.c
@@ -0,0 +1,29 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * futimens() implementation for uClibc
+ *
+ * Copyright (C) 2009 Bernhard Reutner-Fischer <uclibc@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <time.h>
+#ifdef __NR_utimensat
+/* To avoid superfluous warnings about passing NULL to the non-null annotated
+ * 2nd param "__path" below, we bypass inclusion of sys/stat.h and use
+ * a non annotated, local decl.
+ * Note that due to not including the header, we have to alias the call
+ * manually.
+ */
+extern int utimensat (int __fd, const char *__path,
+ const struct timespec __times[2],
+ int __flags) __THROW;
+libc_hidden_proto(utimensat)
+
+int futimens (int __fd, const struct timespec __times[2]) __THROW;
+int futimens (int fd, const struct timespec ts[2])
+{
+ return utimensat(fd, 0, ts, 0);
+}
+#endif
diff --git a/libc/sysdeps/linux/common/futimesat.c b/libc/sysdeps/linux/common/futimesat.c
new file mode 100644
index 000000000..bd73eae7e
--- /dev/null
+++ b/libc/sysdeps/linux/common/futimesat.c
@@ -0,0 +1,16 @@
+/*
+ * futimesat() for uClibc
+ *
+ * Copyright (C) 2009 Analog Devices Inc.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <sys/time.h>
+
+#ifdef __NR_futimesat
+_syscall3(int, futimesat, int, fd, const char *, file, const struct timeval *, tvp)
+#else
+/* should add emulation with futimes() and /proc/self/fd/ ... */
+#endif
diff --git a/libc/sysdeps/linux/common/get_kernel_syms.c b/libc/sysdeps/linux/common/get_kernel_syms.c
index 4f4ee5167..740b8d3aa 100644
--- a/libc/sysdeps/linux/common/get_kernel_syms.c
+++ b/libc/sysdeps/linux/common/get_kernel_syms.c
@@ -9,14 +9,8 @@
#include <sys/syscall.h>
-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;
-}
+struct kernel_sym;
+int get_kernel_syms(struct kernel_sym *table);
+_syscall1(int, get_kernel_syms, struct kernel_sym *, table)
#endif
diff --git a/libc/sysdeps/linux/common/getcwd.c b/libc/sysdeps/linux/common/getcwd.c
index 512a9e1ee..87510019e 100644
--- a/libc/sysdeps/linux/common/getcwd.c
+++ b/libc/sysdeps/linux/common/getcwd.c
@@ -15,23 +15,13 @@
#include <sys/param.h>
#include <sys/syscall.h>
-libc_hidden_proto(getcwd)
-libc_hidden_proto(getpagesize)
-
-/* Experimentally off - libc_hidden_proto(strcat) */
-/* Experimentally off - libc_hidden_proto(strcpy) */
-/* Experimentally off - libc_hidden_proto(strncpy) */
-/* Experimentally off - libc_hidden_proto(strlen) */
-libc_hidden_proto(opendir)
-libc_hidden_proto(readdir)
-libc_hidden_proto(closedir)
-libc_hidden_proto(stat)
+
#ifdef __NR_getcwd
# define __NR___syscall_getcwd __NR_getcwd
-static inline
-_syscall2(int, __syscall_getcwd, char *, buf, unsigned long, size);
+static __always_inline
+_syscall2(int, __syscall_getcwd, char *, buf, unsigned long, size)
#else
@@ -79,7 +69,7 @@ static char *search_dir(dev_t this_dev, ino_t this_ino, char *path_buf, int path
slen++;
dp = opendir(path_buf);
- if (dp == 0) {
+ if (!dp) {
goto oops;
}
@@ -88,6 +78,7 @@ static char *search_dir(dev_t this_dev, ino_t this_ino, char *path_buf, int path
if (slow_search || this_ino == d->d_ino) {
# endif
if (slen + strlen(d->d_name) > path_size) {
+ closedir(dp);
goto oops;
}
strcpy(ptr + 1, d->d_name);
@@ -144,7 +135,7 @@ oops:
return 0;
}
-static inline
+static __always_inline
int __syscall_getcwd(char * buf, unsigned long size)
{
int len;
diff --git a/libc/sysdeps/linux/common/getdents.c b/libc/sysdeps/linux/common/getdents.c
index 97c6d8b06..8f371eba4 100644
--- a/libc/sysdeps/linux/common/getdents.c
+++ b/libc/sysdeps/linux/common/getdents.c
@@ -4,18 +4,20 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#include <alloca.h>
-#include <assert.h>
-#include <errno.h>
+#include <sys/syscall.h>
+#include <bits/wordsize.h>
+
+#if !(defined __UCLIBC_HAS_LFS__ && defined __NR_getdents64 && __WORDSIZE == 64)
+
#include <dirent.h>
-#include <stddef.h>
-#include <stdint.h>
#include <string.h>
-#include <unistd.h>
-#include <sys/param.h>
#include <sys/types.h>
-#include <sys/syscall.h>
#include <bits/kernel_types.h>
+#include <bits/kernel-features.h>
+
+/* If the condition above is met, __getdents is defined as an alias
+ * for __getdents64 (see getdents64.c). Otherwise...
+ */
/* With newer versions of linux, the getdents syscall returns d_type
* information after the name field.
@@ -24,10 +26,7 @@
* version / arch details.
*/
-#ifndef offsetof
-# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
-#endif
-
+# ifdef __ARCH_HAS_DEPRECATED_SYSCALLS__
struct kernel_dirent
{
long int d_ino;
@@ -35,13 +34,17 @@ struct kernel_dirent
unsigned short int d_reclen;
char d_name[256];
};
+# else
+# define kernel_dirent dirent
+# endif
-ssize_t __getdents (int fd, char *buf, size_t nbytes) attribute_hidden;
+# if defined __NR_getdents
+# define __NR___syscall_getdents __NR_getdents
+static __always_inline _syscall3(int, __syscall_getdents, int, fd, unsigned char *, kdirp, size_t, count)
+# endif
-#define __NR___syscall_getdents __NR_getdents
-static inline _syscall3(int, __syscall_getdents, int, fd, unsigned char *, kdirp, size_t, count);
+# if defined __ASSUME_GETDENTS32_D_TYPE && defined __NR_getdents
-#ifdef __ASSUME_GETDENTS32_D_TYPE
ssize_t __getdents (int fd, char *buf, size_t nbytes)
{
ssize_t retval;
@@ -69,10 +72,14 @@ ssize_t __getdents (int fd, char *buf, size_t nbytes)
return retval;
}
-#elif ! defined __UCLIBC_HAS_LFS__ || ! defined __NR_getdents64
+# elif ! defined __UCLIBC_HAS_LFS__ || !defined __NR_getdents64
-/* Experimentally off - libc_hidden_proto(memcpy) */
-libc_hidden_proto(lseek)
+# include <assert.h>
+# include <stddef.h>
+# include <errno.h>
+# include <unistd.h>
+# include <sys/param.h>
+# include <bits/uClibc_alloc.h>
ssize_t __getdents (int fd, char *buf, size_t nbytes)
{
@@ -84,16 +91,34 @@ ssize_t __getdents (int fd, char *buf, size_t nbytes)
const size_t size_diff = (offsetof (struct dirent, d_name)
- offsetof (struct kernel_dirent, d_name));
+# ifndef __ARCH_HAS_DEPRECATED_SYSCALLS__
red_nbytes = MIN (nbytes - ((nbytes /
(offsetof (struct dirent, d_name) + 14)) * size_diff),
nbytes - size_diff);
dp = (struct dirent *) buf;
- skdp = kdp = alloca (red_nbytes);
+ skdp = kdp = stack_heap_alloc(red_nbytes);
retval = __syscall_getdents(fd, (unsigned char *)kdp, red_nbytes);
- if (retval == -1)
+# else
+
+ dp = (struct dirent *) buf;
+ skdp = kdp = stack_heap_alloc(nbytes);
+
+ retval = INLINE_SYSCALL(getdents64, 3, fd, (unsigned char *)kdp, nbytes);
+ if (retval > 0) {
+ /* Did we overflow? */
+ if (kdp->__pad1 || kdp->__pad2) {
+ __set_errno(EINVAL);
+ return -1;
+ }
+ }
+# endif
+
+ if (retval == -1) {
+ stack_heap_free(skdp);
return -1;
+ }
while ((char *) kdp < (char *) skdp + retval) {
const size_t alignment = __alignof__ (struct dirent);
@@ -110,6 +135,7 @@ ssize_t __getdents (int fd, char *buf, size_t nbytes)
if ((char *) dp == buf) {
/* The buffer the user passed in is too small to hold even
one entry. */
+ stack_heap_free(skdp);
__set_errno (EINVAL);
return -1;
}
@@ -126,18 +152,14 @@ ssize_t __getdents (int fd, char *buf, size_t nbytes)
dp = (struct dirent *) ((char *) dp + new_reclen);
kdp = (struct kernel_dirent *) (((char *) kdp) + kdp->d_reclen);
}
+ stack_heap_free(skdp);
return (char *) dp - buf;
}
-#if defined __UCLIBC_HAS_LFS__ && ! defined __NR_getdents64
-attribute_hidden strong_alias(__getdents,__getdents64)
-#endif
-
-#elif __WORDSIZE == 32
+# elif __WORDSIZE == 32 && !defined __NR_getdents64
-/* Experimentally off - libc_hidden_proto(memmove) */
+# include <stddef.h>
-extern __typeof(__getdents) __getdents64 attribute_hidden;
ssize_t __getdents (int fd, char *buf, size_t nbytes)
{
struct dirent *dp;
@@ -163,4 +185,10 @@ ssize_t __getdents (int fd, char *buf, size_t nbytes)
return ret;
}
+# endif
+
+# if defined __UCLIBC_HAS_LFS__ && ! defined __NR_getdents64
+strong_alias(__getdents,__getdents64)
+# endif
+
#endif
diff --git a/libc/sysdeps/linux/common/getdents64.c b/libc/sysdeps/linux/common/getdents64.c
index e695b969c..017fa63c1 100644
--- a/libc/sysdeps/linux/common/getdents64.c
+++ b/libc/sysdeps/linux/common/getdents64.c
@@ -4,8 +4,11 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#include <features.h>
-#include <alloca.h>
+#include <_lfs_64.h>
+#include <sys/syscall.h>
+
+#ifdef __NR_getdents64
+
#include <assert.h>
#include <errno.h>
#include <dirent.h>
@@ -14,18 +17,8 @@
#include <string.h>
#include <unistd.h>
#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/syscall.h>
-#include <bits/kernel_types.h>
-
-#if defined __UCLIBC_HAS_LFS__ && defined __NR_getdents64
-
-/* Experimentally off - libc_hidden_proto(memcpy) */
-libc_hidden_proto(lseek64)
-
-# ifndef offsetof
-# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
-# endif
+#include <bits/wordsize.h>
+#include <bits/uClibc_alloc.h>
struct kernel_dirent64
{
@@ -36,11 +29,9 @@ struct kernel_dirent64
char d_name[256];
};
-
# define __NR___syscall_getdents64 __NR_getdents64
-static __inline__ _syscall3(int, __syscall_getdents64, int, fd, unsigned char *, dirp, size_t, count);
+static __inline__ _syscall3(int, __syscall_getdents64, int, fd, unsigned char *, dirp, size_t, count)
-ssize_t __getdents64 (int fd, char *buf, size_t nbytes) attribute_hidden;
ssize_t __getdents64 (int fd, char *buf, size_t nbytes)
{
struct dirent64 *dp;
@@ -56,11 +47,13 @@ ssize_t __getdents64 (int fd, char *buf, size_t nbytes)
nbytes - size_diff);
dp = (struct dirent64 *) buf;
- skdp = kdp = alloca (red_nbytes);
+ skdp = kdp = stack_heap_alloc(red_nbytes);
retval = __syscall_getdents64(fd, (unsigned char *)kdp, red_nbytes);
- if (retval == -1)
+ if (retval == -1) {
+ stack_heap_free(skdp);
return -1;
+ }
while ((char *) kdp < (char *) skdp + retval) {
const size_t alignment = __alignof__ (struct dirent64);
@@ -77,6 +70,7 @@ ssize_t __getdents64 (int fd, char *buf, size_t nbytes)
if ((char *) dp == buf) {
/* The buffer the user passed in is too small to hold even
one entry. */
+ stack_heap_free(skdp);
__set_errno (EINVAL);
return -1;
}
@@ -93,13 +87,14 @@ ssize_t __getdents64 (int fd, char *buf, size_t nbytes)
dp = (struct dirent64 *) ((char *) dp + new_reclen);
kdp = (struct kernel_dirent64 *) (((char *) kdp) + kdp->d_reclen);
}
+ stack_heap_free(skdp);
return (char *) dp - buf;
}
-#if __WORDSIZE == 64
+#if __WORDSIZE == 64 || (defined __UCLIBC_HAS_LFS__ && !defined __NR_getdents)
/* since getdents doesnt give us d_type but getdents64 does, try and
* use getdents64 as much as possible */
-attribute_hidden strong_alias(__getdents64,__getdents)
+strong_alias(__getdents64,__getdents)
#endif
-#endif /* __UCLIBC_HAS_LFS__ */
+#endif
diff --git a/libc/sysdeps/linux/common/getdirname.c b/libc/sysdeps/linux/common/getdirname.c
index 5938d7257..862559a2e 100644
--- a/libc/sysdeps/linux/common/getdirname.c
+++ b/libc/sysdeps/linux/common/getdirname.c
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <features.h>
@@ -25,15 +24,6 @@
#include <stdlib.h>
#include <string.h>
-/* Experimentally off - libc_hidden_proto(strdup) */
-libc_hidden_proto(getcwd)
-libc_hidden_proto(getenv)
-#ifdef __UCLIBC_HAS_LFS__
-libc_hidden_proto(stat64)
-#else
-libc_hidden_proto(stat)
-#endif
-
/* Return a malloc'd string containing the current directory name.
If the environment variable `PWD' is set, and its value is correct,
that value is used. */
diff --git a/libc/sysdeps/linux/common/getdomainname.c b/libc/sysdeps/linux/common/getdomainname.c
index 86f6dfd32..8590283f5 100644
--- a/libc/sysdeps/linux/common/getdomainname.c
+++ b/libc/sysdeps/linux/common/getdomainname.c
@@ -12,17 +12,12 @@
#include <sys/utsname.h>
#if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_UNIX98)
-/* Experimentally off - libc_hidden_proto(strlen) */
-/* Experimentally off - libc_hidden_proto(strcpy) */
-libc_hidden_proto(uname)
-#if !defined __UCLIBC_BSD_SPECIFIC__
-extern int getdomainname (char *__name, size_t __len)
- __THROW __nonnull ((1)) __wur;
+int
+#ifndef __UCLIBC_BSD_SPECIFIC__
+attribute_hidden
#endif
-extern __typeof(getdomainname) __libc_getdomainname;
-libc_hidden_proto(__libc_getdomainname)
-int __libc_getdomainname(char *name, size_t len)
+getdomainname(char *name, size_t len)
{
struct utsname uts;
@@ -48,10 +43,7 @@ int __libc_getdomainname(char *name, size_t len)
#endif
return 0;
}
-libc_hidden_def(__libc_getdomainname)
-#if defined __UCLIBC_BSD_SPECIFIC__
-libc_hidden_proto(getdomainname)
-weak_alias(__libc_getdomainname,getdomainname)
-libc_hidden_weak(getdomainname)
-#endif /* __UCLIBC_BSD_SPECIFIC__ */
+# ifdef __UCLIBC_BSD_SPECIFIC__
+libc_hidden_def(getdomainname)
+# endif
#endif
diff --git a/libc/sysdeps/linux/common/getdtablesize.c b/libc/sysdeps/linux/common/getdtablesize.c
index 44d21862f..7dd3a54d9 100644
--- a/libc/sysdeps/linux/common/getdtablesize.c
+++ b/libc/sysdeps/linux/common/getdtablesize.c
@@ -11,9 +11,7 @@
/* XXX: _BSD || _XOPEN_SOURCE >= 500 */
#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
-libc_hidden_proto(getdtablesize)
-libc_hidden_proto(getrlimit)
#define __LOCAL_OPEN_MAX 256
diff --git a/libc/sysdeps/linux/common/getegid.c b/libc/sysdeps/linux/common/getegid.c
index eaa708f15..80a8ac9bb 100644
--- a/libc/sysdeps/linux/common/getegid.c
+++ b/libc/sysdeps/linux/common/getegid.c
@@ -10,26 +10,12 @@
#include <sys/syscall.h>
#include <unistd.h>
-libc_hidden_proto(getegid)
-
-#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
-libc_hidden_proto(getgid)
-
-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 60151214d..610fbc170 100644
--- a/libc/sysdeps/linux/common/geteuid.c
+++ b/libc/sysdeps/linux/common/geteuid.c
@@ -10,27 +10,12 @@
#include <sys/syscall.h>
#include <unistd.h>
-libc_hidden_proto(geteuid)
-
-#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
-libc_hidden_proto(getuid)
-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 820ebf0e2..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,6 +19,9 @@
# define __NR_getgid __NR_getgid32
#endif
-libc_hidden_proto(getgid)
-_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/getgroups.c b/libc/sysdeps/linux/common/getgroups.c
index 7e1604294..87fecce24 100644
--- a/libc/sysdeps/linux/common/getgroups.c
+++ b/libc/sysdeps/linux/common/getgroups.c
@@ -8,28 +8,25 @@
*/
#include <sys/syscall.h>
-#include <stdlib.h>
#include <unistd.h>
-#include <grp.h>
-
-libc_hidden_proto(getgroups)
#if defined(__NR_getgroups32)
# undef __NR_getgroups
# define __NR_getgroups __NR_getgroups32
-_syscall2(int, getgroups, int, size, gid_t *, list);
+_syscall2(int, getgroups, int, size, gid_t *, list)
#elif __WORDSIZE == 64
-_syscall2(int, getgroups, int, size, gid_t *, list);
+_syscall2(int, getgroups, int, size, gid_t *, list)
#else
+# include <errno.h>
+# include <stdlib.h>
+# include <sys/types.h>
+# include <sys/param.h>
-libc_hidden_proto(sysconf)
-#define MIN(a,b) (((a)<(b))?(a):(b))
-
-#define __NR___syscall_getgroups __NR_getgroups
-static __inline__ _syscall2(int, __syscall_getgroups,
- int, size, __kernel_gid_t *, list);
+# define __NR___syscall_getgroups __NR_getgroups
+static __always_inline
+_syscall2(int, __syscall_getgroups, int, size, __kernel_gid_t *, list)
int getgroups(int size, gid_t groups[])
{
@@ -58,5 +55,4 @@ ret_error:
}
}
#endif
-
libc_hidden_def(getgroups)
diff --git a/libc/sysdeps/linux/common/gethostname.c b/libc/sysdeps/linux/common/gethostname.c
index 8fc14ff32..3b59e5671 100644
--- a/libc/sysdeps/linux/common/gethostname.c
+++ b/libc/sysdeps/linux/common/gethostname.c
@@ -9,11 +9,7 @@
#include <sys/utsname.h>
#include <errno.h>
-libc_hidden_proto(gethostname)
-/* Experimentally off - libc_hidden_proto(strlen) */
-/* Experimentally off - libc_hidden_proto(strcpy) */
-libc_hidden_proto(uname)
int
gethostname(char *name, size_t len)
diff --git a/libc/sysdeps/linux/common/getitimer.c b/libc/sysdeps/linux/common/getitimer.c
index b240f1c6e..b324233a4 100644
--- a/libc/sysdeps/linux/common/getitimer.c
+++ b/libc/sysdeps/linux/common/getitimer.c
@@ -9,4 +9,4 @@
#include <sys/syscall.h>
#include <sys/time.h>
-_syscall2(int, getitimer, __itimer_which_t, which, struct itimerval *, value);
+_syscall2(int, getitimer, __itimer_which_t, which, struct itimerval *, value)
diff --git a/libc/sysdeps/linux/common/getpagesize.c b/libc/sysdeps/linux/common/getpagesize.c
index efb5fcb7f..f2745d44b 100644
--- a/libc/sysdeps/linux/common/getpagesize.c
+++ b/libc/sysdeps/linux/common/getpagesize.c
@@ -12,16 +12,13 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <unistd.h>
#include <features.h>
#include <sys/param.h>
-extern size_t __pagesize;
-
/* Return the system page size. */
/* couldn't make __getpagesize hidden, because shm.h uses it in a macro */
extern __typeof(getpagesize) __getpagesize;
@@ -43,6 +40,5 @@ int __getpagesize(void)
#endif /* NBPG. */
#endif /* EXEC_PAGESIZE. */
}
-libc_hidden_proto(getpagesize)
strong_alias(__getpagesize,getpagesize)
libc_hidden_def(getpagesize)
diff --git a/libc/sysdeps/linux/common/getpgid.c b/libc/sysdeps/linux/common/getpgid.c
index 25ff12907..8e7516f12 100644
--- a/libc/sysdeps/linux/common/getpgid.c
+++ b/libc/sysdeps/linux/common/getpgid.c
@@ -13,10 +13,13 @@
#include <unistd.h>
#define __NR___syscall_getpgid __NR_getpgid
-static __inline__ _syscall1(__kernel_pid_t, __syscall_getpgid, __kernel_pid_t, pid);
+static __inline__ _syscall1(__kernel_pid_t, __syscall_getpgid, __kernel_pid_t, pid)
-pid_t getpgid(pid_t pid)
+pid_t __getpgid(pid_t pid)
{
return (__syscall_getpgid(pid));
}
+#ifdef __USE_XOPEN_EXTENDED
+weak_alias(__getpgid,getpgid)
+#endif
#endif
diff --git a/libc/sysdeps/linux/common/getpgrp.c b/libc/sysdeps/linux/common/getpgrp.c
index a2fe44560..14912c376 100644
--- a/libc/sysdeps/linux/common/getpgrp.c
+++ b/libc/sysdeps/linux/common/getpgrp.c
@@ -2,7 +2,7 @@
/*
* getpgrp() for uClibc
*
- * Copyright (C) 2000-2006 by Erik Andersen <andersen@codepoet.org>
+ * Copyright (C) 2000-2008 by Erik Andersen <andersen@codepoet.org>
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
@@ -12,5 +12,10 @@
#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
+pid_t getpgrp(void)
+{
+ return getpgid(0);
+}
#endif
diff --git a/libc/sysdeps/linux/common/getpid.c b/libc/sysdeps/linux/common/getpid.c
index 56f1ddd66..d9a69084f 100644
--- a/libc/sysdeps/linux/common/getpid.c
+++ b/libc/sysdeps/linux/common/getpid.c
@@ -10,12 +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);
-libc_hidden_proto(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 1630234cc..9d85661d9 100644
--- a/libc/sysdeps/linux/common/getppid.c
+++ b/libc/sysdeps/linux/common/getppid.c
@@ -9,12 +9,7 @@
#include <sys/syscall.h>
#include <unistd.h>
+
#ifdef __NR_getppid
-_syscall0(pid_t, getppid);
-#else
-libc_hidden_proto(getpid)
-pid_t getppid(void)
-{
- return getpid();
-}
+_syscall_noerr0(pid_t, getppid)
#endif
diff --git a/libc/sysdeps/linux/common/getpriority.c b/libc/sysdeps/linux/common/getpriority.c
index bdfc723e6..eba54a5fd 100644
--- a/libc/sysdeps/linux/common/getpriority.c
+++ b/libc/sysdeps/linux/common/getpriority.c
@@ -10,11 +10,10 @@
#include <sys/syscall.h>
#include <sys/resource.h>
-libc_hidden_proto(getpriority)
#define __NR___syscall_getpriority __NR_getpriority
static __inline__ _syscall2(int, __syscall_getpriority,
- __priority_which_t, which, id_t, who);
+ __priority_which_t, which, id_t, who)
/* The return value of __syscall_getpriority is biased by this value
* to avoid returning negative values. */
diff --git a/libc/sysdeps/linux/common/getrandom.c b/libc/sysdeps/linux/common/getrandom.c
new file mode 100644
index 000000000..d33d5224a
--- /dev/null
+++ b/libc/sysdeps/linux/common/getrandom.c
@@ -0,0 +1,14 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * getrandom() for uClibc
+ *
+ * Copyright (C) 2015 Bernhard Reutner-Fischer
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <sys/random.h>
+#ifdef __NR_getrandom
+_syscall3(int, getrandom, void *, buf, size_t, buflen, unsigned int, flags)
+#endif
diff --git a/libc/sysdeps/linux/common/getresgid.c b/libc/sysdeps/linux/common/getresgid.c
index 922874a3d..425263e7e 100644
--- a/libc/sysdeps/linux/common/getresgid.c
+++ b/libc/sysdeps/linux/common/getresgid.c
@@ -19,7 +19,7 @@ _syscall3(int, getresgid, gid_t *, rgid, gid_t *, egid, gid_t *, sgid)
#elif defined(__NR_getresgid)
# define __NR___syscall_getresgid __NR_getresgid
static __inline__ _syscall3(int, __syscall_getresgid, __kernel_gid_t *, rgid,
- __kernel_gid_t *, egid, __kernel_gid_t *, sgid);
+ __kernel_gid_t *, egid, __kernel_gid_t *, sgid)
int getresgid(gid_t * rgid, gid_t * egid, gid_t * sgid)
{
diff --git a/libc/sysdeps/linux/common/getresuid.c b/libc/sysdeps/linux/common/getresuid.c
index 5a070cc42..87cf6d6d8 100644
--- a/libc/sysdeps/linux/common/getresuid.c
+++ b/libc/sysdeps/linux/common/getresuid.c
@@ -19,7 +19,7 @@ _syscall3(int, getresuid, uid_t *, ruid, uid_t *, euid, uid_t *, suid)
#elif defined(__NR_getresuid)
# define __NR___syscall_getresuid __NR_getresuid
static __inline__ _syscall3(int, __syscall_getresuid, __kernel_uid_t *, ruid,
- __kernel_uid_t *, euid, __kernel_uid_t *, suid);
+ __kernel_uid_t *, euid, __kernel_uid_t *, suid)
int getresuid(uid_t * ruid, uid_t * euid, uid_t * suid)
{
diff --git a/libc/sysdeps/linux/common/getrlimit.c b/libc/sysdeps/linux/common/getrlimit.c
index ecb09d1e2..3b2ce3b37 100644
--- a/libc/sysdeps/linux/common/getrlimit.c
+++ b/libc/sysdeps/linux/common/getrlimit.c
@@ -7,13 +7,9 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define getrlimit64 __hide_getrlimit64
#include <sys/syscall.h>
-#include <unistd.h>
#include <sys/resource.h>
-#undef getrlimit64
-
-libc_hidden_proto(getrlimit)
+#include <bits/wordsize.h>
/* Only wrap getrlimit if the new ugetrlimit is not present and getrlimit sucks */
@@ -21,26 +17,26 @@ libc_hidden_proto(getrlimit)
/* just call ugetrlimit() */
# define __NR___syscall_ugetrlimit __NR_ugetrlimit
-static inline
+static __always_inline
_syscall2(int, __syscall_ugetrlimit, enum __rlimit_resource, resource,
- struct rlimit *, rlim);
+ struct rlimit *, rlim)
int getrlimit(__rlimit_resource_t resource, struct rlimit *rlimits)
{
- return (__syscall_ugetrlimit(resource, rlimits));
+ return __syscall_ugetrlimit(resource, rlimits);
}
#elif !defined(__UCLIBC_HANDLE_OLDER_RLIMIT__)
/* We don't need to wrap getrlimit() */
_syscall2(int, getrlimit, __rlimit_resource_t, resource,
- struct rlimit *, rlim);
+ struct rlimit *, rlim)
#else
/* we have to handle old style getrlimit() */
# define __NR___syscall_getrlimit __NR_getrlimit
-static inline
-_syscall2(int, __syscall_getrlimit, int, resource, struct rlimit *, rlim);
+static __always_inline
+_syscall2(int, __syscall_getrlimit, int, resource, struct rlimit *, rlim)
int getrlimit(__rlimit_resource_t resource, struct rlimit *rlimits)
{
@@ -60,9 +56,8 @@ int getrlimit(__rlimit_resource_t resource, struct rlimit *rlimits)
return result;
}
#endif
-
libc_hidden_def(getrlimit)
#if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64
-strong_alias(getrlimit, getrlimit64)
+strong_alias_untyped(getrlimit, getrlimit64)
#endif
diff --git a/libc/sysdeps/linux/common/getrlimit64.c b/libc/sysdeps/linux/common/getrlimit64.c
index ca7aa7310..be98098a1 100644
--- a/libc/sysdeps/linux/common/getrlimit64.c
+++ b/libc/sysdeps/linux/common/getrlimit64.c
@@ -12,21 +12,16 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <_lfs_64.h>
-
-#include <sys/types.h>
-#include <sys/resource.h>
#include <bits/wordsize.h>
/* the regular getrlimit will work just fine for 64bit users */
+#if __WORDSIZE == 32
-#if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 32
-
-libc_hidden_proto(getrlimit)
+# include <sys/resource.h>
/* Put the soft and hard limits for RESOURCE in *RLIMITS.
Returns 0 if successful, -1 if not (and sets errno). */
diff --git a/libc/sysdeps/linux/common/getrusage.c b/libc/sysdeps/linux/common/getrusage.c
index 03f524dff..fb7614be8 100644
--- a/libc/sysdeps/linux/common/getrusage.c
+++ b/libc/sysdeps/linux/common/getrusage.c
@@ -10,4 +10,5 @@
#include <sys/syscall.h>
#include <unistd.h>
#include <wait.h>
-_syscall2(int, getrusage, __rusage_who_t, who, struct rusage *, usage);
+#include <sys/resource.h>
+_syscall2(int, getrusage, __rusage_who_t, who, struct rusage *, usage)
diff --git a/libc/sysdeps/linux/common/getsid.c b/libc/sysdeps/linux/common/getsid.c
index 9743a976f..5a178bba1 100644
--- a/libc/sysdeps/linux/common/getsid.c
+++ b/libc/sysdeps/linux/common/getsid.c
@@ -11,10 +11,9 @@
#include <unistd.h>
#ifdef __USE_XOPEN_EXTENDED
-libc_hidden_proto(getsid)
#define __NR___syscall_getsid __NR_getsid
-static __inline__ _syscall1(__kernel_pid_t, __syscall_getsid, __kernel_pid_t, pid);
+static __inline__ _syscall1(__kernel_pid_t, __syscall_getsid, __kernel_pid_t, pid)
pid_t getsid(pid_t pid)
{
diff --git a/libc/sysdeps/linux/common/gettimeofday.c b/libc/sysdeps/linux/common/gettimeofday.c
index 697b2dd6c..d9b2a2252 100644
--- a/libc/sysdeps/linux/common/gettimeofday.c
+++ b/libc/sysdeps/linux/common/gettimeofday.c
@@ -10,10 +10,5 @@
#include <sys/syscall.h>
#include <sys/time.h>
-libc_hidden_proto(gettimeofday)
-#ifdef __USE_BSD
-_syscall2(int, gettimeofday, struct timeval *, tv, struct timezone *, tz);
-#else
-_syscall2(int, gettimeofday, struct timeval *, tv, void *, tz);
-#endif
+_syscall2(int, gettimeofday, struct timeval *, tv, __timezone_ptr_t, tz)
libc_hidden_def(gettimeofday)
diff --git a/libc/sysdeps/linux/common/getuid.c b/libc/sysdeps/linux/common/getuid.c
index 7d5a02bc6..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,6 +19,9 @@
# define __NR_getuid __NR_getuid32
#endif
-libc_hidden_proto(getuid)
-_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/hp-timing.h b/libc/sysdeps/linux/common/hp-timing.h
index 099342db8..bc36f022c 100644
--- a/libc/sysdeps/linux/common/hp-timing.h
+++ b/libc/sysdeps/linux/common/hp-timing.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _HP_TIMING_H
#define _HP_TIMING_H 1
diff --git a/libc/sysdeps/linux/common/init_module.c b/libc/sysdeps/linux/common/init_module.c
index 45f1fff23..a2a3e02f5 100644
--- a/libc/sysdeps/linux/common/init_module.c
+++ b/libc/sysdeps/linux/common/init_module.c
@@ -8,18 +8,13 @@
*/
#include <sys/syscall.h>
-int init_module(void *first, void *second, void *third, void *fourth, void *fifth);
+
#ifdef __NR_init_module
+int init_module(void *first, void *second, void *third, void *fourth, void *fifth);
/* This may have 5 arguments (for old 2.0 kernels) or 2 arguments
* (for 2.2 and 2.4 kernels). Use the greatest common denominator,
* 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;
-}
+ void *, fourth, void *, fifth)
#endif
diff --git a/libc/sysdeps/linux/common/inotify.c b/libc/sysdeps/linux/common/inotify.c
index 31bfb0c3b..314388efb 100644
--- a/libc/sysdeps/linux/common/inotify.c
+++ b/libc/sysdeps/linux/common/inotify.c
@@ -12,13 +12,24 @@
#include <sys/inotify.h>
#ifdef __NR_inotify_init
-_syscall0(int, inotify_init);
+_syscall0(int, inotify_init)
+#endif
+
+#ifdef __NR_inotify_init1
+_syscall1(int, inotify_init1, int, flags)
+#endif
+
+#if defined __NR_inotify_init1 && !defined __NR_inotify_init
+int inotify_init(void)
+{
+ return INLINE_SYSCALL(inotify_init1, 1, 0);
+}
#endif
#ifdef __NR_inotify_add_watch
-_syscall3(int, inotify_add_watch, int, fd, const char *, path, uint32_t, mask);
+_syscall3(int, inotify_add_watch, int, fd, const char *, path, uint32_t, mask)
#endif
#ifdef __NR_inotify_rm_watch
-_syscall2(int, inotify_rm_watch, int, fd, uint32_t, wd);
+_syscall2(int, inotify_rm_watch, int, fd, int, wd)
#endif
diff --git a/libc/sysdeps/linux/common/ioctl.c b/libc/sysdeps/linux/common/ioctl.c
index 56173d826..9a00e614a 100644
--- a/libc/sysdeps/linux/common/ioctl.c
+++ b/libc/sysdeps/linux/common/ioctl.c
@@ -10,22 +10,29 @@
#include <sys/syscall.h>
#include <stdarg.h>
#include <sys/ioctl.h>
-
-libc_hidden_proto(ioctl)
+#include <cancel.h>
#define __NR___syscall_ioctl __NR_ioctl
-static inline
-_syscall3(int, __syscall_ioctl, int, fd, int, request, void *, arg);
+static __always_inline
+_syscall3(int, __syscall_ioctl, int, fd, unsigned long int, request, void *, arg)
int ioctl(int fd, unsigned long int request, ...)
{
- void *arg;
- va_list list;
+ void *arg;
+ va_list list;
- va_start(list, request);
- arg = va_arg(list, void *);
- va_end(list);
+ va_start(list, request);
+ arg = va_arg(list, void *);
+ va_end(list);
- return __syscall_ioctl(fd, request, arg);
+ if (SINGLE_THREAD_P)
+ return __syscall_ioctl(fd, request, arg);
+#ifdef __NEW_THREADS
+ int oldtype = LIBC_CANCEL_ASYNC ();
+ int result = __syscall_ioctl(fd, request, arg);
+ LIBC_CANCEL_RESET (oldtype);
+ return result;
+#endif
}
-libc_hidden_def(ioctl)
+lt_strong_alias(ioctl)
+lt_libc_hidden(ioctl)
diff --git a/libc/sysdeps/linux/common/ioperm.c b/libc/sysdeps/linux/common/ioperm.c
index 880842d97..b64a82213 100644
--- a/libc/sysdeps/linux/common/ioperm.c
+++ b/libc/sysdeps/linux/common/ioperm.c
@@ -8,8 +8,11 @@
*/
#include <sys/syscall.h>
+
#if defined __ARCH_USE_MMU__ && defined __NR_ioperm
+
/* psm: can't #include <sys/io.h>, some archs miss it */
extern int ioperm(unsigned long __from, unsigned long __num, int __turn_on) __THROW;
-_syscall3(int, ioperm, unsigned long, from, unsigned long, num, int, turn_on);
+_syscall3(int, ioperm, unsigned long, from, unsigned long, num, int, turn_on)
+
#endif
diff --git a/libc/sysdeps/linux/common/iopl.c b/libc/sysdeps/linux/common/iopl.c
index 510e1a4f6..4d9c4587f 100644
--- a/libc/sysdeps/linux/common/iopl.c
+++ b/libc/sysdeps/linux/common/iopl.c
@@ -11,5 +11,5 @@
#if defined __ARCH_USE_MMU__ && defined __NR_iopl
/* psm: can't #include <sys/io.h>, some archs miss it */
extern int iopl(int __level) __THROW;
-_syscall1(int, iopl, int, level);
+_syscall1(int, iopl, int, level)
#endif
diff --git a/libc/sysdeps/linux/common/jmpbuf-offsets.h b/libc/sysdeps/linux/common/jmpbuf-offsets.h
new file mode 100644
index 000000000..9456178fb
--- /dev/null
+++ b/libc/sysdeps/linux/common/jmpbuf-offsets.h
@@ -0,0 +1,6 @@
+/* Private macros for accessing __jmp_buf contents. dummy version. */
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
diff --git a/libc/sysdeps/linux/common/kill.c b/libc/sysdeps/linux/common/kill.c
index c7729113b..c11a0ed08 100644
--- a/libc/sysdeps/linux/common/kill.c
+++ b/libc/sysdeps/linux/common/kill.c
@@ -10,10 +10,9 @@
#include <sys/syscall.h>
#include <signal.h>
-libc_hidden_proto(kill)
#define __NR___syscall_kill __NR_kill
-static __inline__ _syscall2(int, __syscall_kill, __kernel_pid_t, pid, int, sig);
+static __inline__ _syscall2(int, __syscall_kill, __kernel_pid_t, pid, int, sig)
int kill(pid_t pid, int sig)
{
diff --git a/libc/sysdeps/linux/common/klogctl.c b/libc/sysdeps/linux/common/klogctl.c
index e378e3e67..58467dfa3 100644
--- a/libc/sysdeps/linux/common/klogctl.c
+++ b/libc/sysdeps/linux/common/klogctl.c
@@ -11,7 +11,7 @@
#include <unistd.h>
#include <sys/klog.h>
#define __NR__syslog __NR_syslog
-static __inline__ _syscall3(int, _syslog, int, type, char *, buf, int, len);
+static __inline__ _syscall3(int, _syslog, int, type, char *, buf, int, len)
int klogctl(int type, char *buf, int len)
{
return (_syslog(type, buf, len));
diff --git a/libc/sysdeps/linux/common/lchown.c b/libc/sysdeps/linux/common/lchown.c
index 08c686fd6..4d310fdcb 100644
--- a/libc/sysdeps/linux/common/lchown.c
+++ b/libc/sysdeps/linux/common/lchown.c
@@ -11,19 +11,28 @@
#include <unistd.h>
#include <bits/wordsize.h>
-#if (__WORDSIZE == 32 && defined(__NR_lchown32)) || __WORDSIZE == 64
-# ifdef __NR_lchown32
-# undef __NR_lchown
-# define __NR_lchown __NR_lchown32
-# endif
-
-_syscall3(int, lchown, const char *, path, uid_t, owner, gid_t, group);
+#if defined __NR_fchownat && !defined __NR_lchown
+# include <fcntl.h>
+int lchown(const char *path, uid_t owner, gid_t group)
+{
+ return fchownat(AT_FDCWD, path, owner, group, AT_SYMLINK_NOFOLLOW);
+}
#else
-# define __NR___syscall_lchown __NR_lchown
+# if (__WORDSIZE == 32 && defined(__NR_lchown32)) || __WORDSIZE == 64
+# ifdef __NR_lchown32
+# undef __NR_lchown
+# define __NR_lchown __NR_lchown32
+# endif
+
+_syscall3(int, lchown, const char *, path, uid_t, owner, gid_t, group)
+
+# else
+
+# define __NR___syscall_lchown __NR_lchown
static __inline__ _syscall3(int, __syscall_lchown, const char *, path,
- __kernel_uid_t, owner, __kernel_gid_t, group);
+ __kernel_uid_t, owner, __kernel_gid_t, group)
int lchown(const char *path, uid_t owner, gid_t group)
{
@@ -35,4 +44,6 @@ int lchown(const char *path, uid_t owner, gid_t group)
return __syscall_lchown(path, owner, group);
}
+# endif
+
#endif
diff --git a/libc/sysdeps/linux/common/libgcc_s.h b/libc/sysdeps/linux/common/libgcc_s.h
new file mode 100644
index 000000000..e74a1034c
--- /dev/null
+++ b/libc/sysdeps/linux/common/libgcc_s.h
@@ -0,0 +1,2 @@
+/* Name of libgcc_s library provided by gcc. */
+#define LIBGCC_S_SO "libgcc_s.so.1"
diff --git a/libc/sysdeps/linux/common/link.c b/libc/sysdeps/linux/common/link.c
index a012cc2c3..86d4cfabc 100644
--- a/libc/sysdeps/linux/common/link.c
+++ b/libc/sysdeps/linux/common/link.c
@@ -9,4 +9,13 @@
#include <sys/syscall.h>
#include <unistd.h>
-_syscall2(int, link, const char *, oldpath, const char *, newpath);
+
+#if defined __NR_linkat && !defined __NR_link
+# include <fcntl.h>
+int link(const char *oldpath, const char *newpath)
+{
+ return linkat(AT_FDCWD, oldpath, AT_FDCWD, newpath, 0);
+}
+#else
+_syscall2(int, link, const char *, oldpath, const char *, newpath)
+#endif
diff --git a/libc/sysdeps/linux/common/linkat.c b/libc/sysdeps/linux/common/linkat.c
new file mode 100644
index 000000000..26a3d08e0
--- /dev/null
+++ b/libc/sysdeps/linux/common/linkat.c
@@ -0,0 +1,17 @@
+/*
+ * linkat() for uClibc
+ *
+ * Copyright (C) 2009 Analog Devices Inc.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <unistd.h>
+
+#ifdef __NR_linkat
+_syscall5(int, linkat, int, fromfd, const char *, from, int, tofd, const char *, to, int, flags)
+libc_hidden_def(linkat)
+#else
+/* should add emulation with link() and /proc/self/fd/ ... */
+#endif
diff --git a/libc/sysdeps/linux/common/llseek.c b/libc/sysdeps/linux/common/llseek.c
index 35365d8ae..09f5435a4 100644
--- a/libc/sysdeps/linux/common/llseek.c
+++ b/libc/sysdeps/linux/common/llseek.c
@@ -7,37 +7,26 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#include <unistd.h>
-#include <sys/types.h>
+#include <_lfs_64.h>
#include <sys/syscall.h>
+#include <bits/wordsize.h>
-extern __typeof(lseek64) __libc_lseek64;
-
-#if defined __NR__llseek && defined __UCLIBC_HAS_LFS__
-
-# ifndef INLINE_SYSCALL
-# define INLINE_SYSCALL(name, nr, args...) __syscall_llseek (args)
-# define __NR___syscall_llseek __NR__llseek
-static __inline__ _syscall5(int, __syscall_llseek, int, fd, off_t, offset_hi,
- off_t, offset_lo, loff_t *, result, int, whence);
-# endif
-
-loff_t __libc_lseek64(int fd, loff_t offset, int whence)
-{
- loff_t result;
- return(loff_t)(INLINE_SYSCALL (_llseek, 5, fd, (off_t) (offset >> 32),
- (off_t) (offset & 0xffffffff), &result, whence) ?: result);
-}
-#else
-extern __typeof(lseek) __libc_lseek;
-libc_hidden_proto(__libc_lseek)
+/* Newer kernel ports have llseek() instead of _llseek() */
+#if !defined __NR__llseek && defined __NR_llseek
+# define __NR__llseek __NR_llseek
+#endif
-loff_t __libc_lseek64(int fd, loff_t offset, int whence)
+#if defined __NR__llseek && __WORDSIZE == 32
+# include <unistd.h>
+# include <endian.h>
+# include <cancel.h>
+off64_t __NC(lseek64)(int fd, off64_t offset, int whence)
{
- return(loff_t)(__libc_lseek(fd, (off_t) (offset), whence));
+ off64_t result;
+ /* do we not need to handle the offset with __LONG_LONG_PAIR depending on endianness? */
+ return (off64_t)INLINE_SYSCALL(_llseek, 5, fd, (off_t) OFF64_HI(offset),
+ (off_t) OFF64_LO(offset), &result, whence) ?: result;
}
+CANCELLABLE_SYSCALL(off64_t, lseek64, (int fd, off64_t offset, int whence), (fd, offset, whence))
+lt_libc_hidden(lseek64)
#endif
-libc_hidden_proto(lseek64)
-weak_alias(__libc_lseek64,lseek64)
-libc_hidden_weak(lseek64)
-//strong_alias(__libc_lseek64,_llseek)
diff --git a/libc/sysdeps/linux/common/longjmp.c b/libc/sysdeps/linux/common/longjmp.c
index a54f01f48..e39fb381a 100644
--- a/libc/sysdeps/linux/common/longjmp.c
+++ b/libc/sysdeps/linux/common/longjmp.c
@@ -12,34 +12,26 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <stddef.h>
#include <setjmp.h>
#include <signal.h>
-libc_hidden_proto(sigprocmask)
-
-extern void __longjmp (__jmp_buf __env, int __val) attribute_noreturn;
-libc_hidden_proto(__longjmp)
-
-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
call there to return VAL, or 1 if VAL is 0. */
void __libc_longjmp (sigjmp_buf env, int val)
{
-#if 0
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
/* Perform any cleanups needed by the frames being unwound. */
_longjmp_unwind (env, val);
#endif
if (env[0].__mask_was_saved)
/* Restore the saved signal mask. */
- (void) sigprocmask (SIG_SETMASK, &env[0].__saved_mask,
- (sigset_t *) NULL);
+ (void) sigprocmask (SIG_SETMASK, &env[0].__saved_mask, NULL);
/* Call the machine-dependent function to restore machine state. */
__longjmp (env[0].__jmpbuf, val ?: 1);
diff --git a/libc/sysdeps/linux/common/lseek.c b/libc/sysdeps/linux/common/lseek.c
index 5ba5ad9c8..11a1fbb3e 100644
--- a/libc/sysdeps/linux/common/lseek.c
+++ b/libc/sysdeps/linux/common/lseek.c
@@ -9,23 +9,53 @@
#include <sys/syscall.h>
#include <unistd.h>
-
-extern __typeof(lseek) __libc_lseek;
-libc_hidden_proto(__libc_lseek)
+#include <cancel.h>
#ifdef __NR_lseek
-#define __NR___libc_lseek __NR_lseek
-_syscall3(__off_t, __libc_lseek, int, fildes, __off_t, offset, int, whence);
+# define __NR___lseek_nocancel __NR_lseek
+_syscall3(off_t, __NC(lseek), int, fd, off_t, offset, int, whence)
+/* Use lseek64 if __NR_lseek is not defined but UCLIBC_HAS_LFS is enabled */
+#elif !defined __NR_lseek && defined __NR_llseek
+#include <endian.h>
+off_t __NC(lseek)(int fd, off_t offset, int whence)
+{
+#if defined __UCLIBC_HAS_LFS__
+ return lseek64(fd, offset, whence);
+#elif __WORDSIZE == 32
+ __off64_t result;
+ __off_t high = 0;
+ return INLINE_SYSCALL(llseek, 5, fd, high, offset, &result, whence) ?: result;
+#endif
+/* No need to handle __WORDSIZE == 64 as such a kernel won't define __NR_llseek */
+}
#else
-extern __typeof(lseek64) __libc_lseek64;
-libc_hidden_proto(__libc_lseek64)
-__off_t __libc_lseek(int fildes, __off_t offset, int whence)
+# include <errno.h>
+off_t __NC(lseek)(int fd, off_t offset attribute_unused, int whence)
{
- return __libc_lseek64(fildes, offset, whence);
+ if (fd < 0) {
+ __set_errno(EBADF);
+ return -1;
+ }
+
+ switch(whence) {
+ case SEEK_SET:
+ case SEEK_CUR:
+ case SEEK_END:
+ break;
+ default:
+ __set_errno(EINVAL);
+ return -1;
+ }
+
+ __set_errno(ENOSYS);
+ return -1;
}
#endif
-libc_hidden_def(__libc_lseek)
-
-libc_hidden_proto(lseek)
-weak_alias(__libc_lseek,lseek)
-libc_hidden_weak(lseek)
+CANCELLABLE_SYSCALL(off_t, lseek, (int fd, off_t offset, int whence), (fd, offset, whence))
+lt_libc_hidden(lseek)
+#if defined __UCLIBC_HAS_LFS__ && (__WORDSIZE == 64 || (!defined __NR__llseek && !defined __NR_llseek))
+strong_alias_untyped(__NC(lseek),__NC(lseek64))
+strong_alias_untyped(lseek,lseek64)
+lt_strong_alias(lseek64)
+lt_libc_hidden(lseek64)
+#endif
diff --git a/libc/sysdeps/linux/common/lstat.c b/libc/sysdeps/linux/common/lstat.c
index 4707dfc7c..2fa3de1c2 100644
--- a/libc/sysdeps/linux/common/lstat.c
+++ b/libc/sysdeps/linux/common/lstat.c
@@ -7,39 +7,52 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-/* need to hide the 64bit prototype or the strong_alias()
- * will fail when __NR_lstat64 doesnt exist */
-#define lstat64 __hidelstat64
-
#include <sys/syscall.h>
#include <unistd.h>
#include <sys/stat.h>
-#include "xstatconv.h"
-
-#undef lstat64
-libc_hidden_proto(lstat)
+#if defined __NR_fstatat64 && !defined __NR_lstat
+# include <fcntl.h>
-#define __NR___syscall_lstat __NR_lstat
-static __inline__ _syscall2(int, __syscall_lstat,
- const char *, file_name, struct kernel_stat *, buf);
+int lstat(const char *file_name, struct stat *buf)
+{
+ return fstatat(AT_FDCWD, file_name, buf, AT_SYMLINK_NOFOLLOW);
+}
+libc_hidden_def(lstat)
+/* For systems which have both, prefer the old one */
+#else
+# include "xstatconv.h"
int lstat(const char *file_name, struct stat *buf)
{
int result;
+# ifdef __NR_lstat64
+ /* normal stat call has limited values for various stat elements
+ * e.g. uid device major/minor etc.
+ * so we use 64 variant if available
+ * in order to get newer versions of stat elements
+ */
+ struct kernel_stat64 kbuf;
+ result = INLINE_SYSCALL(lstat64, 2, file_name, &kbuf);
+ if (result == 0) {
+ __xstat32_conv(&kbuf, buf);
+ }
+# else
struct kernel_stat kbuf;
- result = __syscall_lstat(file_name, &kbuf);
+ result = INLINE_SYSCALL(lstat, 2, file_name, &kbuf);
if (result == 0) {
__xstat_conv(&kbuf, buf);
}
+# endif /* __NR_lstat64 */
return result;
}
libc_hidden_def(lstat)
-#if ! defined __NR_lstat64 && defined __UCLIBC_HAS_LFS__
-extern __typeof(lstat) lstat64;
-libc_hidden_proto(lstat64)
-strong_alias(lstat,lstat64)
+# if ! defined __NR_fstatat64 && ! defined __NR_lstat64 \
+ && defined __UCLIBC_HAS_LFS__
+strong_alias_untyped(lstat,lstat64)
libc_hidden_def(lstat64)
-#endif
+# endif
+
+#endif /* __NR_fstatat64 */
diff --git a/libc/sysdeps/linux/common/lstat64.c b/libc/sysdeps/linux/common/lstat64.c
index 6777dff6a..c43e53e1d 100644
--- a/libc/sysdeps/linux/common/lstat64.c
+++ b/libc/sysdeps/linux/common/lstat64.c
@@ -7,18 +7,27 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+#include <_lfs_64.h>
#include <sys/syscall.h>
-#if defined __UCLIBC_HAS_LFS__ && defined __NR_lstat64
# include <unistd.h>
# include <sys/stat.h>
-# include "xstatconv.h"
-libc_hidden_proto(lstat64)
+#if defined __NR_fstatat64 && !defined __NR_lstat64
+# include <fcntl.h>
+
+int lstat64(const char *file_name, struct stat64 *buf)
+{
+ return fstatat64(AT_FDCWD, file_name, buf, AT_SYMLINK_NOFOLLOW);
+}
+libc_hidden_def(lstat64)
+/* For systems which have both, prefer the old one */
+#elif defined __NR_lstat64
+# include "xstatconv.h"
# define __NR___syscall_lstat64 __NR_lstat64
-static __inline__ _syscall2(int, __syscall_lstat64, const char *, file_name,
- struct kernel_stat64 *, buf);
+static __always_inline _syscall2(int, __syscall_lstat64, const char *, file_name,
+ struct kernel_stat64 *, buf)
int lstat64(const char *file_name, struct stat64 *buf)
{
@@ -32,5 +41,4 @@ int lstat64(const char *file_name, struct stat64 *buf)
return result;
}
libc_hidden_def(lstat64)
-
#endif
diff --git a/libc/sysdeps/linux/common/lutimes.c b/libc/sysdeps/linux/common/lutimes.c
new file mode 100644
index 000000000..e01d40efd
--- /dev/null
+++ b/libc/sysdeps/linux/common/lutimes.c
@@ -0,0 +1,38 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * lutimes() implementation for uClibc
+ *
+ * Copyright (C) 2010 Vladimir Zapolskiy <vzapolskiy@gmail.com>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <time.h>
+
+#ifdef __NR_lutimes
+_syscall2(int, lutimes, const char *, file, const struct timeval *, tvp)
+#elif defined __NR_utimensat
+#include <sys/time.h>
+#include <fcntl.h>
+
+int lutimes(const char *file, const struct timeval tvp[2])
+{
+ struct timespec ts[2];
+
+ if (tvp != NULL)
+ {
+ if (tvp[0].tv_usec < 0 || tvp[0].tv_usec >= 1000000
+ || tvp[1].tv_usec < 0 || tvp[1].tv_usec >= 1000000)
+ {
+ __set_errno(EINVAL);
+ return -1;
+ }
+
+ TIMEVAL_TO_TIMESPEC(&tvp[0], &ts[0]);
+ TIMEVAL_TO_TIMESPEC(&tvp[1], &ts[1]);
+ }
+
+ return utimensat(AT_FDCWD, file, tvp ? ts : NULL, AT_SYMLINK_NOFOLLOW);
+}
+#endif
diff --git a/libc/sysdeps/linux/common/madvise.c b/libc/sysdeps/linux/common/madvise.c
index 627bcdc59..e953d7b92 100644
--- a/libc/sysdeps/linux/common/madvise.c
+++ b/libc/sysdeps/linux/common/madvise.c
@@ -10,5 +10,5 @@
#include <sys/syscall.h>
#include <sys/mman.h>
#if defined __NR_madvise && defined __USE_BSD
-_syscall3(int, madvise, void *, __addr, size_t, __len, int, __advice);
+_syscall3(int, madvise, void *, __addr, size_t, __len, int, __advice)
#endif
diff --git a/libc/sysdeps/linux/common/makedev.c b/libc/sysdeps/linux/common/makedev.c
new file mode 100644
index 000000000..d7761671b
--- /dev/null
+++ b/libc/sysdeps/linux/common/makedev.c
@@ -0,0 +1,42 @@
+/* Definitions of functions to access `dev_t' values.
+ Copyright (C) 2003-2015 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <endian.h>
+#include <sys/sysmacros.h>
+
+unsigned int
+gnu_dev_major (unsigned long long int dev)
+{
+ return ((dev >> 8) & 0xfff) | ((unsigned int) (dev >> 32) & ~0xfff);
+}
+libc_hidden_def(gnu_dev_major)
+
+unsigned int
+gnu_dev_minor (unsigned long long int dev)
+{
+ return (dev & 0xff) | ((unsigned int) (dev >> 12) & ~0xff);
+}
+libc_hidden_def(gnu_dev_minor)
+
+unsigned long long int
+gnu_dev_makedev (unsigned int major, unsigned int minor)
+{
+ return ((minor & 0xff) | ((major & 0xfff) << 8)
+ | (((unsigned long long int) (minor & ~0xff)) << 12)
+ | (((unsigned long long int) (major & ~0xfff)) << 32));
+}
diff --git a/libc/sysdeps/linux/common/mincore.c b/libc/sysdeps/linux/common/mincore.c
index 1dc9a9a1a..f1f3557c6 100644
--- a/libc/sysdeps/linux/common/mincore.c
+++ b/libc/sysdeps/linux/common/mincore.c
@@ -11,5 +11,5 @@
#if defined __NR_mincore && (defined __USE_BSD || defined __USE_SVID)
#include <unistd.h>
#include <sys/mman.h>
-_syscall3(int, mincore, void *, start, size_t, length, unsigned char *, vec);
+_syscall3(int, mincore, void *, start, size_t, length, unsigned char *, vec)
#endif
diff --git a/libc/sysdeps/linux/common/mkdir.c b/libc/sysdeps/linux/common/mkdir.c
index ab3cbfee5..bee3e3e7c 100644
--- a/libc/sysdeps/linux/common/mkdir.c
+++ b/libc/sysdeps/linux/common/mkdir.c
@@ -10,14 +10,21 @@
#include <sys/syscall.h>
#include <sys/stat.h>
-libc_hidden_proto(mkdir)
+#if defined __NR_mkdirat && !defined __NR_mkdir
+# include <fcntl.h>
+int mkdir(const char *pathname, mode_t mode)
+{
+ return mkdirat(AT_FDCWD, pathname, mode);
+}
-#define __NR___syscall_mkdir __NR_mkdir
+#else
+# define __NR___syscall_mkdir __NR_mkdir
static __inline__ _syscall2(int, __syscall_mkdir, const char *, pathname,
- __kernel_mode_t, mode);
+ __kernel_mode_t, mode)
int mkdir(const char *pathname, mode_t mode)
{
return (__syscall_mkdir(pathname, mode));
}
+#endif
libc_hidden_def(mkdir)
diff --git a/libc/sysdeps/linux/common/mkdirat.c b/libc/sysdeps/linux/common/mkdirat.c
new file mode 100644
index 000000000..871104bda
--- /dev/null
+++ b/libc/sysdeps/linux/common/mkdirat.c
@@ -0,0 +1,17 @@
+/*
+ * mkdirat() for uClibc
+ *
+ * Copyright (C) 2009 Analog Devices Inc.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <sys/stat.h>
+
+#ifdef __NR_mkdirat
+_syscall3(int, mkdirat, int, fd, const char *, path, mode_t, mode)
+libc_hidden_def(mkdirat)
+#else
+/* should add emulation with mkdir() and /proc/self/fd/ ... */
+#endif
diff --git a/libc/sysdeps/linux/common/mkfifo.c b/libc/sysdeps/linux/common/mkfifo.c
index cbde71e04..d725e4fe5 100644
--- a/libc/sysdeps/linux/common/mkfifo.c
+++ b/libc/sysdeps/linux/common/mkfifo.c
@@ -12,16 +12,14 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <errno.h>
#include <stddef.h>
#include <sys/stat.h>
#include <sys/types.h>
-libc_hidden_proto(mknod)
/* Create a named pipe (FIFO) named PATH with protections MODE. */
int
diff --git a/libc/sysdeps/linux/common/mkfifoat.c b/libc/sysdeps/linux/common/mkfifoat.c
new file mode 100644
index 000000000..e442fe22f
--- /dev/null
+++ b/libc/sysdeps/linux/common/mkfifoat.c
@@ -0,0 +1,19 @@
+/*
+ * mkfifoat() for uClibc
+ *
+ * Copyright (C) 2009 Analog Devices Inc.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <sys/stat.h>
+
+#ifdef __NR_mknodat
+int mkfifoat(int fd, const char *path, mode_t mode)
+{
+ return mknodat(fd, path, mode | S_IFIFO, 0);
+}
+#else
+/* should add emulation with mkfifo() and /proc/self/fd/ ... */
+#endif
diff --git a/libc/sysdeps/linux/common/mknod.c b/libc/sysdeps/linux/common/mknod.c
index 75aff70c8..e0c54e6e3 100644
--- a/libc/sysdeps/linux/common/mknod.c
+++ b/libc/sysdeps/linux/common/mknod.c
@@ -9,20 +9,26 @@
#include <sys/syscall.h>
#include <sys/stat.h>
-#include <sys/sysmacros.h>
-
-libc_hidden_proto(mknod)
-
-#define __NR___syscall_mknod __NR_mknod
-static __inline__ _syscall3(int, __syscall_mknod, const char *, path,
- __kernel_mode_t, mode, __kernel_dev_t, dev);
+#if defined __NR_mknodat && !defined __NR_mknod
+# include <fcntl.h>
+int mknod(const char *path, mode_t mode, dev_t dev)
+{
+ return mknodat(AT_FDCWD, path, mode, dev);
+}
+#else
int mknod(const char *path, mode_t mode, dev_t dev)
{
- /* We must convert the dev_t value to a __kernel_dev_t */
- __kernel_dev_t k_dev;
+ unsigned long long int k_dev;
+
+ /* We must convert the value to dev_t type used by the kernel. */
+ k_dev = (dev) & ((1ULL << 32) - 1);
- k_dev = ((major(dev) & 0xff) << 8) | (minor(dev) & 0xff);
- return __syscall_mknod(path, mode, k_dev);
+ if (k_dev != dev) {
+ __set_errno(EINVAL);
+ return -1;
+ }
+ return INLINE_SYSCALL(mknod, 3, path, mode, (unsigned int)k_dev);
}
+#endif
libc_hidden_def(mknod)
diff --git a/libc/sysdeps/linux/common/mknodat.c b/libc/sysdeps/linux/common/mknodat.c
new file mode 100644
index 000000000..93b9e6e75
--- /dev/null
+++ b/libc/sysdeps/linux/common/mknodat.c
@@ -0,0 +1,25 @@
+/*
+ * mknodat() for uClibc
+ *
+ * Copyright (C) 2009 Analog Devices Inc.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <sys/stat.h>
+
+#ifdef __NR_mknodat
+int mknodat(int fd, const char *path, mode_t mode, dev_t dev)
+{
+ unsigned long long int k_dev;
+
+ /* We must convert the value to dev_t type used by the kernel. */
+ k_dev = (dev) & ((1ULL << 32) - 1);
+
+ return INLINE_SYSCALL(mknodat, 4, fd, path, mode, (unsigned int)k_dev);
+}
+libc_hidden_def(mknodat)
+#else
+/* should add emulation with mknod() and /proc/self/fd/ ... */
+#endif
diff --git a/libc/sysdeps/linux/common/mlock.c b/libc/sysdeps/linux/common/mlock.c
index 55b77a5d5..12120d8e5 100644
--- a/libc/sysdeps/linux/common/mlock.c
+++ b/libc/sysdeps/linux/common/mlock.c
@@ -10,5 +10,5 @@
#include <sys/syscall.h>
#include <sys/mman.h>
#if defined __ARCH_USE_MMU__ && defined __NR_mlock
-_syscall2(int, mlock, const void *, addr, size_t, len);
+_syscall2(int, mlock, const void *, addr, size_t, len)
#endif
diff --git a/libc/sysdeps/linux/common/mlockall.c b/libc/sysdeps/linux/common/mlockall.c
index d75e30fe7..99f72018a 100644
--- a/libc/sysdeps/linux/common/mlockall.c
+++ b/libc/sysdeps/linux/common/mlockall.c
@@ -10,5 +10,5 @@
#include <sys/syscall.h>
#include <sys/mman.h>
#if defined __ARCH_USE_MMU__ && defined __NR_mlockall
-_syscall1(int, mlockall, int, flags);
+_syscall1(int, mlockall, int, flags)
#endif
diff --git a/libc/sysdeps/linux/common/mmap.c b/libc/sysdeps/linux/common/mmap.c
index 7645565a2..dbc66c208 100644
--- a/libc/sysdeps/linux/common/mmap.c
+++ b/libc/sysdeps/linux/common/mmap.c
@@ -7,26 +7,57 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#include <sys/syscall.h>
-#include <unistd.h>
#include <sys/mman.h>
-#include <bits/uClibc_page.h>
+#include <sys/syscall.h>
-#ifdef __NR_mmap
+#if defined __UCLIBC_MMAP_HAS_6_ARGS__ && defined __NR_mmap
-libc_hidden_proto(mmap)
+# ifndef _syscall6
+# error disable __UCLIBC_MMAP_HAS_6_ARGS__ for this arch
+# endif
-#ifdef __UCLIBC_MMAP_HAS_6_ARGS__
+# define __NR__mmap __NR_mmap
+static _syscall6(void *, _mmap, void *, addr, size_t, len,
+ int, prot, int, flags, int, fd, __off_t, offset)
-_syscall6(void *, mmap, void *, start, size_t, length,
- int, prot, int, flags, int, fd, off_t, offset);
+#elif defined __NR_mmap2 && defined _syscall6
-#else
+# include <errno.h>
+# include <bits/uClibc_page.h>
+# ifndef MMAP2_PAGE_SHIFT
+# define MMAP2_PAGE_SHIFT 12
+# endif
-# define __NR__mmap __NR_mmap
-static __inline__ _syscall1(__ptr_t, _mmap, unsigned long *, buffer);
-__ptr_t mmap(__ptr_t addr, size_t len, int prot,
- int flags, int fd, __off_t offset)
+# define __NR___syscall_mmap2 __NR_mmap2
+static __inline__ _syscall6(void *, __syscall_mmap2, void *, addr, size_t, len,
+ int, prot, int, flags, int, fd, __off_t, offset)
+
+static void *_mmap(void *addr, size_t len, int prot, int flags,
+ int fd, __off_t offset)
+{
+ const int mmap2_shift = MMAP2_PAGE_SHIFT;
+ const __off_t mmap2_mask = ((__off_t) 1 << MMAP2_PAGE_SHIFT) - 1;
+ /* check if offset is page aligned */
+ if (offset & mmap2_mask) {
+ __set_errno(EINVAL);
+ return MAP_FAILED;
+ }
+# ifdef __USE_FILE_OFFSET64
+ return __syscall_mmap2(addr, len, prot, flags, fd,
+ ((__u_quad_t) offset >> mmap2_shift));
+# else
+ return __syscall_mmap2(addr, len, prot, flags, fd,
+ ((__u_long) offset >> mmap2_shift));
+# endif
+}
+
+#elif defined __NR_mmap
+
+# define __NR___syscall_mmap __NR_mmap
+static __inline__ _syscall1(void *, __syscall_mmap, unsigned long *, buffer)
+
+static void *_mmap(void *addr, size_t len, int prot, int flags,
+ int fd, __off_t offset)
{
unsigned long buffer[6];
@@ -36,38 +67,14 @@ __ptr_t mmap(__ptr_t addr, size_t len, int prot,
buffer[3] = (unsigned long) flags;
buffer[4] = (unsigned long) fd;
buffer[5] = (unsigned long) offset;
- return (__ptr_t) _mmap(buffer);
+ return __syscall_mmap(buffer);
}
-#endif
-
-libc_hidden_def(mmap)
-
-#elif defined(__NR_mmap2)
-
-libc_hidden_proto(mmap)
+#else
-#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);
+# error "Your architecture doesn't seem to provide mmap() !?"
-/* Some architectures always use 12 as page shift for mmap2() eventhough the
- * real PAGE_SHIFT != 12. Other architectures use the same value as
- * PAGE_SHIFT...
- */
-# ifndef MMAP2_PAGE_SHIFT
-# define MMAP2_PAGE_SHIFT 12
-# endif
-
-__ptr_t mmap(__ptr_t addr, size_t len, int prot, int flags, int fd, __off_t offset)
-{
- if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1)) {
- __set_errno(EINVAL);
- return MAP_FAILED;
- }
- return __syscall_mmap2(addr, len, prot, flags, fd, offset >> MMAP2_PAGE_SHIFT);
-}
+#endif
+strong_alias(_mmap,mmap)
libc_hidden_def(mmap)
-
-#endif
diff --git a/libc/sysdeps/linux/common/mmap64.c b/libc/sysdeps/linux/common/mmap64.c
index a1aa19fb8..c501434a0 100644
--- a/libc/sysdeps/linux/common/mmap64.c
+++ b/libc/sysdeps/linux/common/mmap64.c
@@ -6,18 +6,12 @@
/* Massivly hacked up for uClibc by Erik Andersen */
#include <_lfs_64.h>
-
-#ifdef __UCLIBC_HAS_LFS__
-
+#include <stdint.h>
+#include <sys/syscall.h>
#include <errno.h>
-#include <unistd.h>
#include <sys/mman.h>
-#include <sys/syscall.h>
-#include <bits/uClibc_page.h>
-libc_hidden_proto(mmap)
-
-# if !defined __NR_mmap2 || !defined _syscall6
+#ifndef __NR_mmap2
/*
* This version is a stub that just chops off everything at the mmap 32 bit
@@ -27,7 +21,7 @@ libc_hidden_proto(mmap)
*
*/
-__ptr_t mmap64(__ptr_t addr, size_t len, int prot, int flags, int fd, __off64_t offset)
+void *mmap64(void *addr, size_t len, int prot, int flags, int fd, __off64_t offset)
{
if (offset != (off_t) offset ||
(offset + len) != (off_t) (offset + len)) {
@@ -38,35 +32,43 @@ __ptr_t mmap64(__ptr_t addr, size_t len, int prot, int flags, int fd, __off64_t
return mmap(addr, len, prot, flags, fd, (off_t) offset);
}
-# else
-
-# 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);
+#else
+# include <bits/uClibc_page.h>
-/* Some architectures always use 12 as page shift for mmap2() eventhough the
+/* Some architectures always use 12 as page shift for mmap2() even though the
* real PAGE_SHIFT != 12. Other architectures use the same value as
* PAGE_SHIFT...
*/
-# ifndef MMAP2_PAGE_SHIFT
-# define MMAP2_PAGE_SHIFT 12
-# endif
+# ifndef MMAP2_PAGE_SHIFT
+# define MMAP2_PAGE_SHIFT 12
+# endif
-__ptr_t mmap64(__ptr_t addr, size_t len, int prot, int flags, int fd, __off64_t offset)
+void *mmap64(void *addr, size_t len, int prot, int flags, int fd, __off64_t offset)
{
+ /*
+ * Some arches check the size in INLINE_SYSCALL() and barf if it's
+ * too big (i.e. a 64bit value getting truncated to 32bit).
+ */
+# if __WORDSIZE == 32
+ uint32_t sysoff;
+# else
+ uint64_t sysoff;
+# endif
+
if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1)) {
__set_errno(EINVAL);
return MAP_FAILED;
}
-# ifdef __USE_FILE_OFFSET64
- return __syscall_mmap2(addr, len, prot, flags,
- fd, ((__u_quad_t) offset >> MMAP2_PAGE_SHIFT));
-# else
- return __syscall_mmap2(addr, len, prot, flags,
- fd, ((__u_long) offset >> MMAP2_PAGE_SHIFT));
-# endif
+ /*
+ * We know __off64_t is always a signed 64-bit type, but need things
+ * to be unsigned before doing the shift. If it isn't, we might
+ * sign extend things and pass in the wrong value. So cast it to
+ * an unsigned 64-bit value before doing the shift.
+ */
+ sysoff = (uint64_t)offset >> MMAP2_PAGE_SHIFT;
+
+ return (void*) INLINE_SYSCALL(mmap2, 6, addr, len, prot, flags, fd, sysoff);
}
-# endif
-#endif /* __UCLIBC_HAS_LFS__ */
+#endif
diff --git a/libc/sysdeps/linux/common/modify_ldt.c b/libc/sysdeps/linux/common/modify_ldt.c
index d5f0105dd..d70bd40b0 100644
--- a/libc/sysdeps/linux/common/modify_ldt.c
+++ b/libc/sysdeps/linux/common/modify_ldt.c
@@ -11,5 +11,5 @@
int modify_ldt (int func, void *ptr, unsigned long bytecount);
#ifdef __NR_modify_ldt
-_syscall3(int, modify_ldt, int, func, void *, ptr, unsigned long, bytecount);
+_syscall3(int, modify_ldt, int, func, void *, ptr, unsigned long, bytecount)
#endif
diff --git a/libc/sysdeps/linux/common/mount.c b/libc/sysdeps/linux/common/mount.c
index a5a2c7fec..e2c344c1f 100644
--- a/libc/sysdeps/linux/common/mount.c
+++ b/libc/sysdeps/linux/common/mount.c
@@ -10,5 +10,5 @@
#include <sys/syscall.h>
#include <sys/mount.h>
_syscall5(int, mount, const char *, specialfile, const char *, dir,
- const char *, filesystemtype, unsigned long, rwflag,
- const void *, data);
+ const char *, filesystemtype, unsigned long, rwflag,
+ const void *, data)
diff --git a/libc/sysdeps/linux/common/mprotect.c b/libc/sysdeps/linux/common/mprotect.c
index 7122f0f2f..d60fc04d6 100644
--- a/libc/sysdeps/linux/common/mprotect.c
+++ b/libc/sysdeps/linux/common/mprotect.c
@@ -10,6 +10,6 @@
#include <sys/syscall.h>
#include <sys/mman.h>
-#if defined __ARCH_USE_MMU__ && defined __NR_mprotect
-_syscall3(int, mprotect, void *, addr, size_t, len, int, prot);
+#if defined __NR_mprotect
+_syscall3(int, mprotect, void *, addr, size_t, len, int, prot)
#endif
diff --git a/libc/sysdeps/linux/common/mremap.c b/libc/sysdeps/linux/common/mremap.c
index 04548d5ec..0295a25da 100644
--- a/libc/sysdeps/linux/common/mremap.c
+++ b/libc/sysdeps/linux/common/mremap.c
@@ -12,15 +12,17 @@
#ifdef __NR_mremap
+/* Why do we do this?! */
+
#define mremap _hidemremap
#include <sys/mman.h>
#undef mremap
void *mremap(void *, size_t, size_t, int, void *);
-
libc_hidden_proto(mremap)
+
_syscall5(void *, mremap, void *, old_address, size_t, old_size, size_t,
- new_size, int, may_move, void *, new_address);
+ new_size, int, may_move, void *, new_address)
libc_hidden_def(mremap)
#endif
diff --git a/libc/sysdeps/linux/common/msync.c b/libc/sysdeps/linux/common/msync.c
index 88f021f43..e183fbff2 100644
--- a/libc/sysdeps/linux/common/msync.c
+++ b/libc/sysdeps/linux/common/msync.c
@@ -8,15 +8,14 @@
*/
#include <sys/syscall.h>
-#include <unistd.h>
#if defined __NR_msync && defined __ARCH_USE_MMU__
+# include <sys/mman.h>
+# include <cancel.h>
-#include <sys/mman.h>
-
-extern __typeof(msync) __libc_msync;
-#define __NR___libc_msync __NR_msync
-_syscall3(int, __libc_msync, void *, addr, size_t, length, int, flags);
-weak_alias(__libc_msync,msync)
+# define __NR___msync_nocancel __NR_msync
+static _syscall3(int, __NC(msync), void *, addr, size_t, length, int, flags)
+CANCELLABLE_SYSCALL(int, msync, (void *addr, size_t length, int flags),
+ (addr, length, flags))
#endif
diff --git a/libc/sysdeps/linux/common/munlock.c b/libc/sysdeps/linux/common/munlock.c
index e901cc00a..07f93760f 100644
--- a/libc/sysdeps/linux/common/munlock.c
+++ b/libc/sysdeps/linux/common/munlock.c
@@ -10,5 +10,5 @@
#include <sys/syscall.h>
#include <sys/mman.h>
#if defined __ARCH_USE_MMU__ && defined __NR_munlock
-_syscall2(int, munlock, const void *, addr, size_t, len);
+_syscall2(int, munlock, const void *, addr, size_t, len)
#endif
diff --git a/libc/sysdeps/linux/common/munlockall.c b/libc/sysdeps/linux/common/munlockall.c
index 39507715a..cc1526451 100644
--- a/libc/sysdeps/linux/common/munlockall.c
+++ b/libc/sysdeps/linux/common/munlockall.c
@@ -12,5 +12,5 @@
#if defined __NR_munlockall && defined __ARCH_USE_MMU__
#include <sys/mman.h>
-_syscall0(int, munlockall);
+_syscall0(int, munlockall)
#endif
diff --git a/libc/sysdeps/linux/common/munmap.c b/libc/sysdeps/linux/common/munmap.c
index 5c948abfd..22c393ffc 100644
--- a/libc/sysdeps/linux/common/munmap.c
+++ b/libc/sysdeps/linux/common/munmap.c
@@ -8,10 +8,7 @@
*/
#include <sys/syscall.h>
-#include <unistd.h>
#include <sys/mman.h>
-libc_hidden_proto(munmap)
-
-_syscall2(int, munmap, void *, start, size_t, length);
+_syscall2(int, munmap, void *, start, size_t, length)
libc_hidden_def(munmap)
diff --git a/libc/sysdeps/linux/common/nanosleep.c b/libc/sysdeps/linux/common/nanosleep.c
index c464403c5..dd3f4dd14 100644
--- a/libc/sysdeps/linux/common/nanosleep.c
+++ b/libc/sysdeps/linux/common/nanosleep.c
@@ -9,14 +9,13 @@
#include <sys/syscall.h>
#include <time.h>
+#include <cancel.h>
-#if defined __USE_POSIX199309 && defined __NR_nanosleep
+#define __NR___nanosleep_nocancel __NR_nanosleep
+static _syscall2(int, __NC(nanosleep), const struct timespec *, req,
+ struct timespec *, rem);
-extern __typeof(nanosleep) __libc_nanosleep;
-#define __NR___libc_nanosleep __NR_nanosleep
-_syscall2(int, __libc_nanosleep, const struct timespec *, req,
- struct timespec *, rem);
-libc_hidden_proto(nanosleep)
-weak_alias(__libc_nanosleep,nanosleep)
-libc_hidden_weak(nanosleep)
-#endif
+CANCELLABLE_SYSCALL(int, nanosleep,
+ (const struct timespec *req, struct timespec *rem),
+ (req, rem))
+lt_libc_hidden(nanosleep)
diff --git a/libc/sysdeps/linux/common/nice.c b/libc/sysdeps/linux/common/nice.c
index 8ced60915..ed399460f 100644
--- a/libc/sysdeps/linux/common/nice.c
+++ b/libc/sysdeps/linux/common/nice.c
@@ -12,30 +12,28 @@
#include <unistd.h>
#include <sys/resource.h>
-libc_hidden_proto(getpriority)
#ifdef __NR_nice
# define __NR___syscall_nice __NR_nice
-static __inline__ _syscall1(int, __syscall_nice, int, incr);
+static __inline__ _syscall1(int, __syscall_nice, int, incr)
#else
# include <limits.h>
-libc_hidden_proto(setpriority)
static __inline__ int int_add_no_wrap(int a, int b)
{
- int s = a + b;
-
if (b < 0) {
- if (s > a) s = INT_MIN;
+ if (a < INT_MIN - b)
+ return INT_MIN;
} else {
- if (s < a) s = INT_MAX;
+ if (a > INT_MAX - b)
+ return INT_MAX;
}
- return s;
+ return a + b;
}
static __inline__ int __syscall_nice(int incr)
diff --git a/libc/sysdeps/linux/common/noophooks.c b/libc/sysdeps/linux/common/noophooks.c
index a6c9d7673..dfd068ddd 100644
--- a/libc/sysdeps/linux/common/noophooks.c
+++ b/libc/sysdeps/linux/common/noophooks.c
@@ -14,11 +14,8 @@
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 <libc-internal.h>
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
void
__cyg_profile_func_enter (attribute_unused void *this_fn, attribute_unused void *call_site);
diff --git a/libc/sysdeps/linux/common/not-cancel.h b/libc/sysdeps/linux/common/not-cancel.h
new file mode 100644
index 000000000..acf8e39e8
--- /dev/null
+++ b/libc/sysdeps/linux/common/not-cancel.h
@@ -0,0 +1,152 @@
+/* Uncancelable versions of cancelable interfaces. Linux version.
+ Copyright (C) 2003, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sys/types.h>
+#include <sysdep.h>
+
+#ifdef NOT_IN_libc
+
+/* Uncancelable open. */
+#if defined __NR_openat && !defined __NR_open
+#define open_not_cancel(name, flags, mode) \
+ INLINE_SYSCALL (openat, 4, AT_FDCWD, (const char *) (name), (flags), (mode))
+#define open_not_cancel_2(name, flags) \
+ INLINE_SYSCALL (openat, 3, AT_FDCWD, (const char *) (name), (flags))
+#else
+#define open_not_cancel(name, flags, mode) \
+ INLINE_SYSCALL (open, 3, (const char *) (name), (flags), (mode))
+#define open_not_cancel_2(name, flags) \
+ INLINE_SYSCALL (open, 2, (const char *) (name), (flags))
+#endif
+
+#if 0
+/* Uncancelable openat. */
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+extern int __openat_nocancel (int fd, const char *fname, int oflag,
+ mode_t mode) attribute_hidden;
+extern int __openat64_nocancel (int fd, const char *fname, int oflag,
+ mode_t mode) attribute_hidden;
+#else
+# define __openat_nocancel(fd, fname, oflag, mode) \
+ openat (fd, fname, oflag, mode)
+# define __openat64_nocancel(fd, fname, oflag, mode) \
+ openat64 (fd, fname, oflag, mode)
+#endif
+
+#define openat_not_cancel(fd, fname, oflag, mode) \
+ __openat_nocancel (fd, fname, oflag, mode)
+#define openat_not_cancel_3(fd, fname, oflag) \
+ __openat_nocancel (fd, fname, oflag, 0)
+#define openat64_not_cancel(fd, fname, oflag, mode) \
+ __openat64_nocancel (fd, fname, oflag, mode)
+#define openat64_not_cancel_3(fd, fname, oflag) \
+ __openat64_nocancel (fd, fname, oflag, 0)
+#endif
+
+/* Uncancelable close. */
+#define close_not_cancel(fd) \
+ INLINE_SYSCALL (close, 1, fd)
+#define close_not_cancel_no_status(fd) \
+ (void) ({ INTERNAL_SYSCALL_DECL (err); \
+ INTERNAL_SYSCALL (close, err, 1, (fd)); })
+
+/* Uncancelable read. */
+#define read_not_cancel(fd, buf, n) \
+ INLINE_SYSCALL (read, 3, (fd), (buf), (n))
+
+#ifdef __LINUXTHREADS_NEW__
+/* Uncancelable write. */
+#define write_not_cancel(fd, buf, n) \
+ INLINE_SYSCALL (write, 3, (fd), (buf), (n))
+#endif
+
+#if 0
+/* Uncancelable writev. */
+#define writev_not_cancel_no_status(fd, iov, n) \
+ (void) ({ INTERNAL_SYSCALL_DECL (err); \
+ INTERNAL_SYSCALL (writev, err, 3, (fd), (iov), (n)); })
+
+/* Uncancelable fcntl. */
+#define fcntl_not_cancel(fd, cmd, val) \
+ __fcntl_nocancel (fd, cmd, val)
+#endif
+
+#ifdef __LINUXTHREADS_NEW__
+/* Uncancelable waitpid. */
+#if 0 /*def __NR_waitpid*/
+# define waitpid_not_cancel(pid, stat_loc, options) \
+ INLINE_SYSCALL (waitpid, 3, pid, stat_loc, options)
+#else
+# define waitpid_not_cancel(pid, stat_loc, options) \
+ INLINE_SYSCALL (wait4, 4, pid, stat_loc, options, NULL)
+#endif
+#endif
+
+/* Uncancelable pause. */
+#ifdef __NR_pause
+# define pause_not_cancel() \
+ INLINE_SYSCALL (pause, 0)
+#else
+# include <unistd.h>
+extern __typeof(pause) __pause_nocancel;
+# define pause_not_cancel() \
+ __pause_nocancel ()
+#endif
+
+/* Uncancelable nanosleep. */
+#ifdef __NR_nanosleep
+# define nanosleep_not_cancel(requested_time, remaining) \
+ INLINE_SYSCALL (nanosleep, 2, requested_time, remaining)
+/*#else
+# define nanosleep_not_cancel(requested_time, remaining) \
+ __nanosleep_nocancel (requested_time, remaining)*/
+#endif
+
+#if 0
+/* Uncancelable sigsuspend. */
+#define sigsuspend_not_cancel(set) \
+ __sigsuspend_nocancel (set)
+#endif
+
+#elif !defined NOT_IN_libc
+
+#include <cancel.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#define open_not_cancel(name, flags, mode) \
+ __NC(open)(name, flags, mode)
+#define open_not_cancel_2(name, flags) \
+ __NC(open2)(name, flags)
+
+#define close_not_cancel(fd) \
+ __NC(close)(fd)
+#define close_not_cancel_no_status(fd) \
+ __close_nocancel_no_status(fd)
+
+#define read_not_cancel(fd, buf, n) \
+ __NC(read)(fd, buf, n)
+
+#define write_not_cancel(fd, buf, n) \
+ __NC(write)(fd, buf, n)
+
+#define fcntl_not_cancel(fd, cmd, val) \
+ __NC(fcntl)(fd, cmd, val)
+
+#endif
diff --git a/libc/sysdeps/linux/common/ntp_gettime.c b/libc/sysdeps/linux/common/ntp_gettime.c
index f32e05444..a41bfe7c8 100644
--- a/libc/sysdeps/linux/common/ntp_gettime.c
+++ b/libc/sysdeps/linux/common/ntp_gettime.c
@@ -12,13 +12,11 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <sys/timex.h>
-libc_hidden_proto(adjtimex)
int ntp_gettime(struct ntptimeval *ntv)
{
diff --git a/libc/sysdeps/linux/common/open.c b/libc/sysdeps/linux/common/open.c
index 7c0566b46..fd37ea0f0 100644
--- a/libc/sysdeps/linux/common/open.c
+++ b/libc/sysdeps/linux/common/open.c
@@ -8,41 +8,61 @@
*/
#include <sys/syscall.h>
-#include <stdlib.h>
-#include <stdarg.h>
#include <fcntl.h>
-#include <string.h>
-#include <sys/param.h>
+#include <stdarg.h>
+#include <cancel.h>
-extern __typeof(open) __libc_open;
-extern __typeof(creat) __libc_creat;
+#if defined __NR_open
+# define __NR___syscall_open __NR_open
+static __always_inline _syscall3(int, __syscall_open, const char *, file,
+ int, flags, __kernel_mode_t, mode)
+strong_alias_untyped(__syscall_open,__NC(open))
-#define __NR___syscall_open __NR_open
-static __inline__ _syscall3(int, __syscall_open, const char *, file,
- int, flags, __kernel_mode_t, mode);
+# define __NR___open2_nocancel __NR_open
+_syscall2(int, __NC(open2), const char *, file, int, flags)
+#else
+int __open2_nocancel(const char *, int) __nonnull ((1)) attribute_hidden;
+int __open_nocancel(const char *, int, mode_t) __nonnull ((1)) attribute_hidden;
+#endif
-libc_hidden_proto(__libc_open)
-int __libc_open(const char *file, int oflag, ...)
+int open(const char *file, int oflag, ...)
{
mode_t mode = 0;
if (oflag & O_CREAT) {
va_list arg;
- va_start (arg, oflag);
- mode = va_arg (arg, mode_t);
- va_end (arg);
+ va_start(arg, oflag);
+ mode = va_arg(arg, mode_t);
+ va_end(arg);
}
- return __syscall_open(file, oflag, mode);
-}
-libc_hidden_def(__libc_open)
-
-libc_hidden_proto(open)
-weak_alias(__libc_open,open)
-libc_hidden_weak(open)
+ if (SINGLE_THREAD_P)
+#if defined(__NR_open)
+ return __NC(open)(file, oflag, mode);
+#elif defined(__NR_openat)
+ return openat(AT_FDCWD, file, oflag, mode);
+#endif
-int __libc_creat(const char *file, mode_t mode)
+#ifdef __NEW_THREADS
+ int oldtype = LIBC_CANCEL_ASYNC ();
+# if defined(__NR_open)
+ int result = __NC(open)(file, oflag, mode);
+# else
+ int result = openat(AT_FDCWD, file, oflag, mode);
+# endif
+ LIBC_CANCEL_RESET (oldtype);
+ return result;
+#endif
+}
+lt_strong_alias(open)
+lt_libc_hidden(open)
+#if !defined(__NR_open)
+int __open2_nocancel(const char *file, int oflag)
+{
+ return open(file, oflag);
+}
+int __open_nocancel(const char *file, int oflag, mode_t mode)
{
- return __libc_open(file, O_WRONLY | O_CREAT | O_TRUNC, mode);
+ return open(file, oflag, mode);
}
-weak_alias(__libc_creat,creat)
+#endif
diff --git a/libc/sysdeps/linux/common/open64.c b/libc/sysdeps/linux/common/open64.c
index 1c40b3e9b..6e65a988e 100644
--- a/libc/sysdeps/linux/common/open64.c
+++ b/libc/sysdeps/linux/common/open64.c
@@ -4,40 +4,31 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#include <features.h>
+#include <_lfs_64.h>
+#include <sys/syscall.h>
#include <fcntl.h>
#include <stdarg.h>
-
-#ifdef __UCLIBC_HAS_LFS__
-
-#ifndef O_LARGEFILE
-# define O_LARGEFILE 0100000
-#endif
-
-extern __typeof(open64) __libc_open64;
-extern __typeof(open) __libc_open;
-libc_hidden_proto(__libc_open)
+#include <cancel.h>
/* Open FILE with access OFLAG. If OFLAG includes O_CREAT,
a third argument is the file protection. */
-libc_hidden_proto(__libc_open64)
-int __libc_open64 (const char *file, int oflag, ...)
+int open64(const char *file, int oflag, ...)
{
- mode_t mode = 0;
-
- if (oflag & O_CREAT)
- {
- va_list arg;
- va_start (arg, oflag);
- mode = va_arg (arg, mode_t);
- va_end (arg);
- }
-
- return __libc_open(file, oflag | O_LARGEFILE, mode);
+ mode_t mode = 0;
+
+ if (oflag & O_CREAT) {
+ va_list arg;
+ va_start (arg, oflag);
+ mode = va_arg (arg, mode_t);
+ va_end (arg);
+ }
+#if defined __NR_openat && !defined __NR_open
+ return openat(AT_FDCWD, file, oflag | O_LARGEFILE, mode);
+#else
+ return open(file, oflag | O_LARGEFILE, mode);
+#endif
}
-libc_hidden_def(__libc_open64)
-
-libc_hidden_proto(open64)
-weak_alias(__libc_open64,open64)
-libc_hidden_weak(open64)
-#endif /* __UCLIBC_HAS_LFS__ */
+lt_strong_alias(open64)
+lt_libc_hidden(open64)
+/* open handled cancellation, noop on uClibc */
+LIBC_CANCEL_HANDLED();
diff --git a/libc/sysdeps/linux/common/openat.c b/libc/sysdeps/linux/common/openat.c
new file mode 100644
index 000000000..f71567cdc
--- /dev/null
+++ b/libc/sysdeps/linux/common/openat.c
@@ -0,0 +1,32 @@
+/*
+ * openat() for uClibc
+ *
+ * Copyright (C) 2009 Analog Devices Inc.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <fcntl.h>
+#include <stdarg.h>
+
+#ifdef __NR_openat
+# define __NR___syscall_openat __NR_openat
+static __inline__ _syscall4(int, __syscall_openat, int, fd, const char *, file, int, oflag, mode_t, mode)
+
+int __openat(int fd, const char *file, int o_flag, ...)
+{
+ va_list ap;
+ mode_t mode;
+
+ va_start(ap, o_flag);
+ mode = va_arg(ap, int);
+ va_end(ap);
+ return __syscall_openat(fd, file, o_flag, mode);
+}
+
+strong_alias_untyped(__openat,openat)
+libc_hidden_def(openat)
+#else
+/* should add emulation with open() and /proc/self/fd/ ... */
+#endif
diff --git a/libc/sysdeps/linux/common/openat64.c b/libc/sysdeps/linux/common/openat64.c
new file mode 100644
index 000000000..eda3e7db1
--- /dev/null
+++ b/libc/sysdeps/linux/common/openat64.c
@@ -0,0 +1,21 @@
+/*
+ * openat() for uClibc
+ *
+ * Copyright (C) 2009 Analog Devices Inc.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <_lfs_64.h>
+#include <sys/syscall.h>
+#include <fcntl.h>
+
+#ifdef __NR_openat
+static int __openat64(int fd, const char *file, int oflag, mode_t mode)
+{
+ return openat(fd, file, oflag | O_LARGEFILE, mode);
+}
+strong_alias_untyped(__openat64,openat64)
+#else
+/* should add emulation with open() and /proc/self/fd/ ... */
+#endif
diff --git a/libc/sysdeps/linux/common/pause.c b/libc/sysdeps/linux/common/pause.c
index 22a039b4f..c35ecd5d5 100644
--- a/libc/sysdeps/linux/common/pause.c
+++ b/libc/sysdeps/linux/common/pause.c
@@ -7,22 +7,35 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define __UCLIBC_HIDE_DEPRECATED__
#include <sys/syscall.h>
#include <unistd.h>
+#include <cancel.h>
-extern __typeof(pause) __libc_pause;
#ifdef __NR_pause
-#define __NR___libc_pause __NR_pause
-_syscall0(int, __libc_pause);
+/* even if it is not obvious, glibc uses the pause syscall, see syscalls.list */
+# define __NR___pause_nocancel __NR_pause
+static _syscall0(int, __NC(pause))
+CANCELLABLE_SYSCALL(int, pause, (void), ())
#else
-#include <signal.h>
-libc_hidden_proto(__sigpause)
-libc_hidden_proto(sigblock)
+# define __need_NULL
+# include <stddef.h>
+# include <signal.h>
-int __libc_pause(void)
+int
+# ifdef __LINUXTHREADS_OLD__
+weak_function
+# endif
+__NC(pause)(void)
{
- return (__sigpause(sigblock(0), 0));
+ sigset_t set;
+
+ /*__sigemptyset (&set); - why? */
+ sigprocmask (SIG_BLOCK, NULL, &set);
+
+ /* pause is a cancellation point, but so is sigsuspend.
+ So no need for anything special here. */
+ return sigsuspend(&set);
}
+CANCELLABLE_SYSCALL(int, pause, (void), ())
+LIBC_CANCEL_HANDLED (); /* sigsuspend handles our cancellation. */
#endif
-weak_alias(__libc_pause,pause)
diff --git a/libc/sysdeps/linux/common/personality.c b/libc/sysdeps/linux/common/personality.c
index 149fb5f08..fa304de09 100644
--- a/libc/sysdeps/linux/common/personality.c
+++ b/libc/sysdeps/linux/common/personality.c
@@ -9,4 +9,4 @@
#include <sys/syscall.h>
#include <sys/personality.h>
-_syscall1(int, personality, unsigned long int, __persona);
+_syscall1(int, personality, unsigned long int, __persona)
diff --git a/libc/sysdeps/linux/common/pipe.c b/libc/sysdeps/linux/common/pipe.c
index 789b23c40..bd3929781 100644
--- a/libc/sysdeps/linux/common/pipe.c
+++ b/libc/sysdeps/linux/common/pipe.c
@@ -10,7 +10,14 @@
#include <sys/syscall.h>
#include <unistd.h>
-libc_hidden_proto(pipe)
-_syscall1(int, pipe, int *, filedes);
+#if defined __NR_pipe2 && !defined __NR_pipe
+int pipe(int filedes[2])
+{
+ return pipe2(filedes, 0);
+}
+/* If both are defined then use the pipe syscall */
+#else
+_syscall1(int, pipe, int *, filedes)
+#endif
libc_hidden_def(pipe)
diff --git a/libc/sysdeps/linux/common/pipe2.c b/libc/sysdeps/linux/common/pipe2.c
new file mode 100644
index 000000000..0a3686d81
--- /dev/null
+++ b/libc/sysdeps/linux/common/pipe2.c
@@ -0,0 +1,16 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * pipe2() for uClibc
+ *
+ * Copyright (C) 2011 Bernhard Reutner-Fischer <uclibc@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <unistd.h>
+
+#ifdef __NR_pipe2
+_syscall2(int, pipe2, int *, filedes, int, flags)
+libc_hidden_def(pipe2)
+#endif
diff --git a/libc/sysdeps/linux/common/pivot_root.c b/libc/sysdeps/linux/common/pivot_root.c
index 154a37e2d..78f71efa4 100644
--- a/libc/sysdeps/linux/common/pivot_root.c
+++ b/libc/sysdeps/linux/common/pivot_root.c
@@ -9,13 +9,7 @@
#include <sys/syscall.h>
-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;
-}
+int pivot_root(const char *new_root, const char *put_old);
+_syscall2(int, pivot_root, const char *, new_root, const char *, put_old)
#endif
diff --git a/libc/sysdeps/linux/common/poll.c b/libc/sysdeps/linux/common/poll.c
index 164e08120..d1f1f1723 100644
--- a/libc/sysdeps/linux/common/poll.c
+++ b/libc/sysdeps/linux/common/poll.c
@@ -13,41 +13,21 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <sys/syscall.h>
#include <sys/poll.h>
+#include <bits/kernel-features.h>
+#include <cancel.h>
-extern __typeof(poll) __libc_poll;
+#if defined __ASSUME_POLL_SYSCALL && defined __NR_poll
-#ifdef __NR_poll
+#define __NR___poll_nocancel __NR_poll
+static _syscall3(int, __NC(poll), struct pollfd *, fds,
+ unsigned long int, nfds, int, timeout)
-# define __NR___libc_poll __NR_poll
-_syscall3(int, __libc_poll, struct pollfd *, fds,
- unsigned long int, nfds, int, timeout);
-
-#elif defined(__NR_ppoll) && defined __UCLIBC_LINUX_SPECIFIC__
-
-libc_hidden_proto(ppoll)
-int __libc_poll(struct pollfd *fds, nfds_t nfds, int timeout)
-{
- struct timespec *ts = NULL, tval;
- if (timeout > 0) {
- tval.tv_sec = timeout / 1000;
- tval.tv_nsec = (timeout % 1000) * 1000000;
- ts = &tval;
- } else if (timeout == 0) {
- tval.tv_sec = 0;
- tval.tv_nsec = 0;
- ts = &tval;
- }
- return ppoll(fds, nfds, ts, NULL);
-}
-
-#else
-/* ugh, this arch lacks poll, so we need to emulate this crap ... */
+#else /* !__NR_poll */
#include <alloca.h>
#include <sys/types.h>
@@ -56,11 +36,7 @@ int __libc_poll(struct pollfd *fds, nfds_t nfds, int timeout)
#include <sys/time.h>
#include <sys/param.h>
#include <unistd.h>
-
-/* Experimentally off - libc_hidden_proto(memcpy) */
-/* Experimentally off - libc_hidden_proto(memset) */
-libc_hidden_proto(getdtablesize)
-libc_hidden_proto(select)
+#include <sys/select.h>
/* uClinux 2.0 doesn't have poll, emulate it using select */
@@ -70,7 +46,7 @@ libc_hidden_proto(select)
Returns the number of file descriptors with events, zero if timed out,
or -1 for errors. */
-int __libc_poll(struct pollfd *fds, nfds_t nfds, int timeout)
+int __NC(poll)(struct pollfd *fds, nfds_t nfds, int timeout)
{
static int max_fd_size;
struct timeval tv;
@@ -141,7 +117,7 @@ int __libc_poll(struct pollfd *fds, nfds_t nfds, int timeout)
while (1)
{
- ready = select (maxfd + 1, rset, wset, xset,
+ ready = __NC(select) (maxfd + 1, rset, wset, xset,
timeout == -1 ? NULL : &tv);
/* It might be that one or more of the file descriptors is invalid.
@@ -184,7 +160,7 @@ int __libc_poll(struct pollfd *fds, nfds_t nfds, int timeout)
if (f->events & POLLPRI)
FD_SET (f->fd, sngl_xset);
- n = select (f->fd + 1, sngl_rset, sngl_wset, sngl_xset,
+ n = __NC(select) (f->fd + 1, sngl_rset, sngl_wset, sngl_xset,
&sngl_tv);
if (n != -1)
{
@@ -229,6 +205,6 @@ int __libc_poll(struct pollfd *fds, nfds_t nfds, int timeout)
}
#endif
-libc_hidden_proto(poll)
-weak_alias(__libc_poll,poll)
-libc_hidden_weak(poll)
+CANCELLABLE_SYSCALL(int, poll, (struct pollfd *fds, nfds_t nfds, int timeout),
+ (fds, nfds, timeout))
+lt_libc_hidden(poll)
diff --git a/libc/sysdeps/linux/common/posix_fadvise.c b/libc/sysdeps/linux/common/posix_fadvise.c
index 95aa4d27b..74d8409c0 100644
--- a/libc/sysdeps/linux/common/posix_fadvise.c
+++ b/libc/sysdeps/linux/common/posix_fadvise.c
@@ -8,55 +8,73 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-/* need to hide the 64bit prototype or the strong_alias()
- * will fail when __NR_fadvise64_64 doesnt exist */
-#define posix_fadvise64 __hideposix_fadvise64
-
#include <sys/syscall.h>
-#include <fcntl.h>
-#undef posix_fadvise64
+#ifdef __NR_arm_fadvise64_64
+/* We handle the 64bit alignment issue which is why the arm guys renamed their
+ * syscall in the first place. So rename it back.
+ */
+# define __NR_fadvise64_64 __NR_arm_fadvise64_64
+#endif
+
+#if defined(__NR_fadvise64) || defined(__NR_fadvise64_64)
+# include <fcntl.h>
+# include <endian.h>
+# include <bits/wordsize.h>
-#ifdef __NR_fadvise64
-#define __NR_posix_fadvise __NR_fadvise64
-/* get rid of following conditional when
- all supported arches are having INTERNAL_SYSCALL defined
-*/
-#ifdef INTERNAL_SYSCALL
+# if defined(__NR_fadvise64_64) && defined(__UCLIBC_HAS_LFS__)
+#include <_lfs_64.h>
+
+int posix_fadvise64(int fd, off64_t offset, off64_t len, int advice);
int posix_fadvise(int fd, off_t offset, off_t len, int advice)
{
- INTERNAL_SYSCALL_DECL(err);
- int ret = (int) (INTERNAL_SYSCALL(posix_fadvise, err, 5, fd,
- __LONG_LONG_PAIR (offset >> 31, offset), len, advice));
- if (INTERNAL_SYSCALL_ERROR_P (ret, err))
- return INTERNAL_SYSCALL_ERRNO (ret, err);
- return 0;
+ return posix_fadvise64(fd, offset, len, advice);
}
#else
-static __inline__ int syscall_posix_fadvise(int fd, off_t offset1, off_t offset2, off_t len, int advice);
-#define __NR_syscall_posix_fadvise __NR_fadvise64
-_syscall5(int, syscall_posix_fadvise, int, fd, off_t, offset1,
- off_t, offset2, off_t, len, int, advice);
int posix_fadvise(int fd, off_t offset, off_t len, int advice)
{
- int ret = syscall_posix_fadvise(fd, __LONG_LONG_PAIR (offset >> 31, offset), len, advice);
- if (ret == -1)
- return errno;
- return ret;
-}
-
-#endif
+ int ret;
+ INTERNAL_SYSCALL_DECL(err);
-#if defined __UCLIBC_HAS_LFS__ && (!defined __NR_fadvise64_64 || !defined _syscall6)
-extern __typeof(posix_fadvise) posix_fadvise64;
+# ifdef __NR_fadvise64_64
+# if __WORDSIZE == 64
+ ret = INTERNAL_SYSCALL(fadvise64_64, err, 4, fd, offset, len, advice);
+# else
+# if defined (__arm__) || \
+ (defined(__UCLIBC_SYSCALL_ALIGN_64BIT__) && (defined(__powerpc__) || defined(__xtensa__)))
+ /* arch with 64-bit data in even reg alignment #1: [powerpc/xtensa]
+ * custom syscall handler (rearranges @advice to avoid register hole punch) */
+ ret = INTERNAL_SYSCALL(fadvise64_64, err, 6, fd, advice,
+ OFF_HI_LO (offset), OFF_HI_LO (len));
+# elif defined(__UCLIBC_SYSCALL_ALIGN_64BIT__)
+ /* arch with 64-bit data in even reg alignment #2: [arcv2/others-in-future]
+ * stock syscall handler in kernel (reg hole punched) */
+ ret = INTERNAL_SYSCALL(fadvise64_64, err, 7, fd, 0,
+ OFF_HI_LO (offset), OFF_HI_LO (len), advice);
+# else
+ ret = INTERNAL_SYSCALL(fadvise64_64, err, 6, fd,
+ OFF_HI_LO (offset), OFF_HI_LO (len), advice);
+# endif
+# endif
+# else /* __NR_fadvise64 */
+# if __WORDSIZE == 64
+ ret = INTERNAL_SYSCALL(fadvise64, err, 4, fd, offset, len, advice);
+# else
+# if defined(__UCLIBC_SYSCALL_ALIGN_64BIT__)
+ ret = INTERNAL_SYSCALL(fadvise64, err, 6, fd, /*unused*/0,
+# else
+ ret = INTERNAL_SYSCALL(fadvise64, err, 5, fd,
+# endif
+ OFF_HI_LO (offset), len, advice);
+# endif
+# endif
+ if (INTERNAL_SYSCALL_ERROR_P (ret, err))
+ return INTERNAL_SYSCALL_ERRNO (ret, err);
+ return 0;
+}
+# if defined __UCLIBC_HAS_LFS__ && (!defined __NR_fadvise64_64 || __WORDSIZE == 64)
strong_alias(posix_fadvise,posix_fadvise64)
+# endif
#endif
-
-#else
-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 061718e9a..37fb269ca 100644
--- a/libc/sysdeps/linux/common/posix_fadvise64.c
+++ b/libc/sysdeps/linux/common/posix_fadvise64.c
@@ -8,98 +8,41 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#include <features.h>
-#include <unistd.h>
-#include <errno.h>
-#include <endian.h>
-#include <stdint.h>
-#include <sys/types.h>
+#include <_lfs_64.h>
#include <sys/syscall.h>
-#include <fcntl.h>
+#include <bits/wordsize.h>
-#ifdef __UCLIBC_HAS_LFS__
-#ifdef __NR_fadvise64_64
-
-/* 64 bit implementation is cake ... or more like pie ... */
-#if __WORDSIZE == 64
-
-#define __NR_posix_fadvise64 __NR_fadvise64_64
-
-#if defined INTERNAL_SYSCALL && ! defined __TARGET_powerpc__
-int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advice)
-{
- if (len != (off_t) len)
- return EOVERFLOW;
- INTERNAL_SYSCALL_DECL (err);
- int ret = INTERNAL_SYSCALL (posix_fadvise64, err, 5, fd,
- __LONG_LONG_PAIR ((long) (offset >> 32),
- (long) offset),
- (off_t) len, advice);
- if (!INTERNAL_SYSCALL_ERROR_P (ret, err))
- return 0;
- return INTERNAL_SYSCALL_ERRNO (ret, err);
-}
-#else
-static __inline__ int syscall_posix_fadvise(int fd, off_t offset1, off_t offset2, off_t len, int advice);
-#define __NR_syscall_posix_fadvise64 __NR_posix_fadvise64
-_syscall4(int, syscall_posix_fadvise64, int, fd, __off64_t, offset,
- __off64_t, len, int, advice);
-int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advice)
-{
- int ret = syscall_posix_fadvise64(fd, offset, len, advice);
- if (ret == -1)
- return errno;
- return ret;
-}
+#ifdef __NR_arm_fadvise64_64
+# define __NR_fadvise64_64 __NR_arm_fadvise64_64
#endif
-/* 32 bit implementation is kind of a pita */
-#elif __WORDSIZE == 32
+#if defined __NR_fadvise64_64 && __WORDSIZE == 32
+# include <fcntl.h>
+# include <endian.h>
-#if defined INTERNAL_SYSCALL && ! defined __TARGET_powerpc__
-int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advice)
+int posix_fadvise64(int fd, off64_t offset, off64_t len, int advice)
{
INTERNAL_SYSCALL_DECL (err);
+ /* ARM has always been funky. */
+#if defined (__arm__) || \
+ (defined(__UCLIBC_SYSCALL_ALIGN_64BIT__) && (defined(__powerpc__) || defined(__xtensa__)))
+ /* arch with 64-bit data in even reg alignment #1: [powerpc/xtensa]
+ * custom syscall handler (rearranges @advice to avoid register hole punch) */
+ int ret = INTERNAL_SYSCALL (fadvise64_64, err, 6, fd, advice,
+ OFF64_HI_LO (offset), OFF64_HI_LO (len));
+#elif defined(__UCLIBC_SYSCALL_ALIGN_64BIT__)
+ /* arch with 64-bit data in even reg alignment #2: [arcv2/others-in-future]
+ * stock syscall handler in kernel (reg hole punched) */
+ int ret = INTERNAL_SYSCALL (fadvise64_64, err, 7, fd, 0,
+ OFF64_HI_LO (offset), OFF64_HI_LO (len),
+ advice);
+# else
int ret = INTERNAL_SYSCALL (fadvise64_64, err, 6, fd,
- __LONG_LONG_PAIR(offset >> 32, offset & 0xffffffff),
- __LONG_LONG_PAIR(len >> 32, len & 0xffffffff),
- advice);
- if (!INTERNAL_SYSCALL_ERROR_P (ret, err))
- return 0;
- return INTERNAL_SYSCALL_ERRNO (ret, err);
+ OFF64_HI_LO (offset), OFF64_HI_LO (len),
+ advice);
+# endif
+ if (INTERNAL_SYSCALL_ERROR_P (ret, err))
+ return INTERNAL_SYSCALL_ERRNO (ret, err);
+ return 0;
}
-#elif defined _syscall6 /* workaround until everyone has _syscall6() */
-#define __NR___syscall_fadvise64_64 __NR_fadvise64_64
-static __inline__ _syscall6(int, __syscall_fadvise64_64, int, fd,
- unsigned long, high_offset, unsigned long, low_offset,
- unsigned long, high_len, unsigned long, low_len,
- int, advice);
-int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advice)
-{
- int ret = __syscall_fadvise64_64(fd,
- __LONG_LONG_PAIR(offset >> 32, offset & 0xffffffff),
- __LONG_LONG_PAIR(len >> 32, len & 0xffffffff),
- advice);
- if (ret == -1)
- return errno;
- return ret;
-}
-#else
-#warning neither INTERNAL_SYSCALL nor _syscall6 has been defined for your machine :(
-#endif /* INTERNAL_SYSCALL */
-
-#else
-#error your machine is neither 32 bit or 64 bit ... it must be magical
#endif
-
-#elif !defined __NR_fadvise64
-/* 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 */
-#endif /* __UCLIBC_HAS_LFS__ */
diff --git a/libc/sysdeps/linux/common/posix_fallocate.c b/libc/sysdeps/linux/common/posix_fallocate.c
new file mode 100644
index 000000000..2316cfdcd
--- /dev/null
+++ b/libc/sysdeps/linux/common/posix_fallocate.c
@@ -0,0 +1,28 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * posix_fallocate() for uClibc
+ * http://www.opengroup.org/onlinepubs/9699919799/functions/posix_fallocate.html
+ *
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <fcntl.h>
+#include <bits/kernel-features.h>
+#include <stdint.h>
+#include <errno.h>
+
+#if defined __NR_fallocate
+extern __typeof(fallocate) __libc_fallocate attribute_hidden;
+int posix_fallocate(int fd, __off_t offset, __off_t len)
+{
+ if (__libc_fallocate(fd, 0, offset, len))
+ return errno;
+ return 0;
+}
+# if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64
+strong_alias(posix_fallocate,posix_fallocate64)
+# endif
+#endif
diff --git a/libc/sysdeps/linux/common/posix_fallocate64.c b/libc/sysdeps/linux/common/posix_fallocate64.c
new file mode 100644
index 000000000..85614f6f5
--- /dev/null
+++ b/libc/sysdeps/linux/common/posix_fallocate64.c
@@ -0,0 +1,31 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * posix_fallocate() for uClibc
+ * http://www.opengroup.org/onlinepubs/9699919799/functions/posix_fallocate.html
+ *
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <fcntl.h>
+#include <bits/kernel-features.h>
+#include <stdint.h>
+#include <errno.h>
+
+#if defined __NR_fallocate
+# if __WORDSIZE == 64
+/* Can use normal posix_fallocate() */
+# elif __WORDSIZE == 32
+extern __typeof(fallocate64) __libc_fallocate64 attribute_hidden;
+int posix_fallocate64(int fd, __off64_t offset, __off64_t len)
+{
+ if (__libc_fallocate64(fd, 0, offset, len))
+ return errno;
+ return 0;
+}
+# else
+# error your machine is neither 32 bit or 64 bit ... it must be magical
+# endif
+#endif
diff --git a/libc/sysdeps/linux/common/posix_madvise.c b/libc/sysdeps/linux/common/posix_madvise.c
new file mode 100644
index 000000000..2f95bcba7
--- /dev/null
+++ b/libc/sysdeps/linux/common/posix_madvise.c
@@ -0,0 +1,25 @@
+/* vi: set sw=4 ts=4: */
+/* Licensed under the LGPL v2.1, see the file LICENSE in this tarball. */
+
+#include <sys/mman.h>
+#include <sys/syscall.h>
+
+#if defined __NR_madvise && defined __USE_XOPEN2K && defined __UCLIBC_HAS_ADVANCED_REALTIME__
+int posix_madvise(void *addr, size_t len, int advice)
+{
+ int result;
+ /* We have one problem: the kernel's MADV_DONTNEED does not
+ * correspond to POSIX's POSIX_MADV_DONTNEED. The former simply
+ * discards changes made to the memory without writing it back to
+ * disk, if this would be necessary. The POSIX behaviour does not
+ * allow this. There is no functionality mapping for the POSIX
+ * behaviour so far so we ignore that advice for now. */
+ if (advice == POSIX_MADV_DONTNEED)
+ return 0;
+
+ /* this part might use madvise function */
+ INTERNAL_SYSCALL_DECL (err);
+ result = INTERNAL_SYSCALL (madvise, err, 3, addr, len, advice);
+ return INTERNAL_SYSCALL_ERRNO (result, err);
+}
+#endif
diff --git a/libc/sysdeps/linux/common/ppoll.c b/libc/sysdeps/linux/common/ppoll.c
index 90b3517b2..781f1ff1c 100644
--- a/libc/sysdeps/linux/common/ppoll.c
+++ b/libc/sysdeps/linux/common/ppoll.c
@@ -13,38 +13,35 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <sys/syscall.h>
-#include <sys/poll.h>
-
-#if defined __NR_ppoll && defined __UCLIBC_LINUX_SPECIFIC__
-libc_hidden_proto(ppoll)
+#if defined __NR_ppoll && defined __UCLIBC_LINUX_SPECIFIC__ && defined __USE_GNU
-# define __NR___libc_ppoll __NR_ppoll
-static inline
-_syscall4(int, __libc_ppoll, struct pollfd *, fds,
- nfds_t, nfds, const struct timespec *, timeout,
- const __sigset_t *, sigmask);
+#define __need_NULL
+#include <stddef.h>
+#include <signal.h>
+#include <sys/poll.h>
+#include <cancel.h>
-int
-ppoll (struct pollfd *fds, nfds_t nfds, const struct timespec *timeout,
- const __sigset_t *sigmask)
+static int
+__NC(ppoll)(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout,
+ const sigset_t *sigmask)
{
- /* The Linux kernel can in some situations update the timeout value.
- We do not want that so use a local variable. */
- struct timespec tval;
- if (timeout != NULL)
- {
- tval = *timeout;
- timeout = &tval;
- }
-
- return __libc_ppoll(fds, nfds, timeout, sigmask);
+ /* The Linux kernel can in some situations update the timeout value.
+ We do not want that so use a local variable. */
+ struct timespec tval;
+ if (timeout != NULL) {
+ tval = *timeout;
+ timeout = &tval;
+ }
+ return INLINE_SYSCALL(ppoll, 5, fds, nfds, timeout, sigmask, __SYSCALL_SIGSET_T_SIZE);
}
-libc_hidden_def(ppoll)
+
+CANCELLABLE_SYSCALL(int, ppoll, (struct pollfd *fds, nfds_t nfds, const struct timespec *timeout,
+ const sigset_t *sigmask),
+ (fds, nfds, timeout, sigmask))
#endif
diff --git a/libc/sysdeps/linux/common/prctl.c b/libc/sysdeps/linux/common/prctl.c
index 485386727..5f29cdb54 100644
--- a/libc/sysdeps/linux/common/prctl.c
+++ b/libc/sysdeps/linux/common/prctl.c
@@ -8,10 +8,10 @@
*/
#include <sys/syscall.h>
-#include <stdarg.h>
/* psm: including sys/prctl.h would depend on kernel headers */
#ifdef __NR_prctl
-extern int prctl (int, long, long, long, long);
-_syscall5(int, prctl, int, option, long, arg2, long, arg3, long, arg4, long, arg5);
+int prctl (int, long, long, long, long);
+_syscall5(int, prctl, int, option, long, _prctl_a2, long, _prctl_a3,
+ long, _prctl_a4, long, _prctl_a5)
#endif
diff --git a/libc/sysdeps/linux/common/pread_write.c b/libc/sysdeps/linux/common/pread_write.c
index b2aaa2a1d..4f96f681d 100644
--- a/libc/sysdeps/linux/common/pread_write.c
+++ b/libc/sysdeps/linux/common/pread_write.c
@@ -15,177 +15,101 @@
#include <sys/syscall.h>
#include <unistd.h>
-#include <stdint.h>
#include <endian.h>
+#include <bits/wordsize.h>
+#include <cancel.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;
+#ifdef __NR_pread64
+# undef __NR_pread
+# define __NR_pread __NR_pread64
+#endif
+#ifdef __NR_pwrite64
+# undef __NR_pwrite
+# define __NR_pwrite __NR_pwrite64
#endif
-#include <bits/kernel_types.h>
-
-#ifdef __NR_pread
-
-# 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, __LONG_LONG_PAIR(offset >> 31, offset));
-}
-weak_alias(__libc_pread,pread)
-
-# ifdef __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, __LONG_LONG_PAIR(high, low));
-}
-weak_alias(__libc_pread64,pread64)
-# endif /* __UCLIBC_HAS_LFS__ */
-
-#endif /* __NR_pread */
-
-#ifdef __NR_pwrite
-
-# 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, __LONG_LONG_PAIR(offset >> 31, offset));
-}
-weak_alias(__libc_pwrite,pwrite)
-
-# ifdef __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, __LONG_LONG_PAIR(high, low));
-}
-weak_alias(__libc_pwrite64,pwrite64)
-# endif /* __UCLIBC_HAS_LFS__ */
-#endif /* __NR_pwrite */
-
-#if ! defined __NR_pread || ! defined __NR_pwrite
-libc_hidden_proto(read)
-libc_hidden_proto(write)
-libc_hidden_proto(lseek)
-
-static ssize_t __fake_pread_write(int fd, void *buf,
- size_t count, off_t offset, int do_pwrite)
-{
- int save_errno;
- ssize_t result;
- off_t old_offset;
-
- /* Since we must not change the file pointer preserve the
- * value so that we can restore it later. */
- if ((old_offset=lseek(fd, 0, SEEK_CUR)) == (off_t) -1)
- return -1;
-
- /* Set to wanted position. */
- if (lseek(fd, offset, SEEK_SET) == (off_t) -1)
- return -1;
-
- if (do_pwrite == 1) {
- /* Write the data. */
- result = write(fd, buf, count);
- } else {
- /* Read the data. */
- result = read(fd, buf, count);
- }
-
- /* Now we have to restore the position. If this fails we
- * have to return this as an error. */
- save_errno = errno;
- if (lseek(fd, old_offset, SEEK_SET) == (off_t) -1)
- {
- if (result == -1)
- __set_errno(save_errno);
- return -1;
- }
- __set_errno(save_errno);
- return(result);
-}
-
-# ifdef __UCLIBC_HAS_LFS__
-libc_hidden_proto(lseek64)
-
-static ssize_t __fake_pread_write64(int fd, void *buf,
- size_t count, off64_t offset, int do_pwrite)
-{
- int save_errno;
- ssize_t result;
- off64_t old_offset;
-
- /* Since we must not change the file pointer preserve the
- * value so that we can restore it later. */
- if ((old_offset=lseek64(fd, 0, SEEK_CUR)) == (off64_t) -1)
- return -1;
-
- /* Set to wanted position. */
- if (lseek64(fd, offset, SEEK_SET) == (off64_t) -1)
- return -1;
-
- if (do_pwrite == 1) {
- /* Write the data. */
- result = write(fd, buf, count);
- } else {
- /* Read the data. */
- result = read(fd, buf, count);
- }
+#ifndef MY_PREAD
+# ifdef __NR_pread
+# define __NR___syscall_pread __NR_pread
+# if defined(__UCLIBC_SYSCALL_ALIGN_64BIT__)
+static _syscall6(ssize_t, __syscall_pread, int, fd, void *, buf,
+ size_t, count, int, dummy, off_t, offset_hi, off_t, offset_lo)
+# define MY_PREAD(fd, buf, count, offset) __syscall_pread(fd, buf, count, 0, OFF_HI_LO(offset))
+# define MY_PREAD64(fd, buf, count, offset) __syscall_pread(fd, buf, count, 0, OFF64_HI_LO(offset))
+# elif __WORDSIZE == 32
+static _syscall5(ssize_t, __syscall_pread, int, fd, void *, buf,
+ size_t, count, off_t, offset_hi, off_t, offset_lo)
+# define MY_PREAD(fd, buf, count, offset) __syscall_pread(fd, buf, count, OFF_HI_LO(offset))
+# define MY_PREAD64(fd, buf, count, offset) __syscall_pread(fd, buf, count, OFF64_HI_LO(offset))
+# else
+static _syscall4(ssize_t, __syscall_pread, int, fd, void *, buf,
+ size_t, count, off_t, offset)
+# define MY_PREAD(fd, buf, count, offset) __syscall_pread(fd, buf, count, offset)
+# define MY_PREAD64(fd, buf, count, offset) __syscall_pread(fd, buf, count, offset)
+# endif
+# endif
+#endif
- /* Now we have to restore the position. */
- save_errno = errno;
- if (lseek64(fd, old_offset, SEEK_SET) == (off64_t) -1) {
- if (result == -1)
- __set_errno (save_errno);
- return -1;
- }
- __set_errno (save_errno);
- return result;
-}
-# endif /* __UCLIBC_HAS_LFS__ */
-#endif /* ! defined __NR_pread || ! defined __NR_pwrite */
+#ifndef MY_PWRITE
+# ifdef __NR_pwrite
+# define __NR___syscall_pwrite __NR_pwrite
+# if defined(__UCLIBC_SYSCALL_ALIGN_64BIT__)
+static _syscall6(ssize_t, __syscall_pwrite, int, fd, const void *, buf,
+ size_t, count, int, dummy, off_t, offset_hi, off_t, offset_lo)
+# define MY_PWRITE(fd, buf, count, offset) __syscall_pwrite(fd, buf, count, 0, OFF_HI_LO(offset))
+# define MY_PWRITE64(fd, buf, count, offset) __syscall_pwrite(fd, buf, count, 0, OFF64_HI_LO(offset))
+# elif __WORDSIZE == 32
+static _syscall5(ssize_t, __syscall_pwrite, int, fd, const void *, buf,
+ size_t, count, off_t, offset_hi, off_t, offset_lo)
+# define MY_PWRITE(fd, buf, count, offset) __syscall_pwrite(fd, buf, count, OFF_HI_LO(offset))
+# define MY_PWRITE64(fd, buf, count, offset) __syscall_pwrite(fd, buf, count, OFF64_HI_LO(offset))
+# else
+static _syscall4(ssize_t, __syscall_pwrite, int, fd, const void *, buf,
+ size_t, count, off_t, offset)
+# define MY_PWRITE(fd, buf, count, offset) __syscall_pwrite(fd, buf, count, offset)
+# define MY_PWRITE64(fd, buf, count, offset) __syscall_pwrite(fd, buf, count, offset)
+# endif
+# endif
+#endif
-#ifndef __NR_pread
-ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset)
+static ssize_t __NC(pread)(int fd, void *buf, size_t count, off_t offset)
{
- return __fake_pread_write(fd, buf, count, offset, 0);
+ return MY_PREAD(fd, buf, count, offset);
}
-weak_alias(__libc_pread,pread)
+CANCELLABLE_SYSCALL(ssize_t, pread, (int fd, void *buf, size_t count, off_t offset),
+ (fd, buf, count, offset))
-# ifdef __UCLIBC_HAS_LFS__
-ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset)
+static ssize_t __NC(pwrite)(int fd, const void *buf, size_t count, off_t offset)
{
- return __fake_pread_write64(fd, buf, count, offset, 0);
+ return MY_PWRITE(fd, buf, count, offset);
}
-weak_alias(__libc_pread64,pread64)
-# endif /* __UCLIBC_HAS_LFS__ */
-#endif /* ! __NR_pread */
+CANCELLABLE_SYSCALL(ssize_t, pwrite, (int fd, const void *buf, size_t count, off_t offset),
+ (fd, buf, count, offset))
-#ifndef __NR_pwrite
-ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset)
+#ifdef __UCLIBC_HAS_LFS__
+# if __WORDSIZE == 32
+static ssize_t __NC(pread64)(int fd, void *buf, size_t count, off64_t offset)
{
- /* we won't actually be modifying the buffer,
- *just cast it to get rid of warnings */
- return __fake_pread_write(fd, (void*)buf, count, offset, 1);
+ return MY_PREAD64(fd, buf, count, offset);
}
-weak_alias(__libc_pwrite,pwrite)
+CANCELLABLE_SYSCALL(ssize_t, pread64, (int fd, void *buf, size_t count, off64_t offset),
+ (fd, buf, count, offset))
-# ifdef __UCLIBC_HAS_LFS__
-ssize_t __libc_pwrite64(int fd, const void *buf, size_t count, off64_t offset)
+static ssize_t __NC(pwrite64)(int fd, const void *buf, size_t count, off64_t offset)
{
- return __fake_pread_write64(fd, (void*)buf, count, offset, 1);
+ return MY_PWRITE64(fd, buf, count, offset);
}
-weak_alias(__libc_pwrite64,pwrite64)
-# endif /* __UCLIBC_HAS_LFS__ */
-#endif /* ! __NR_pwrite */
+CANCELLABLE_SYSCALL(ssize_t, pwrite64, (int fd, const void *buf, size_t count, off64_t offset),
+ (fd, buf, count, offset))
+# else
+# ifdef __LINUXTHREADS_OLD__
+weak_alias(pread,pread64)
+weak_alias(pwrite,pwrite64)
+lt_strong_alias(pread64)
+lt_strong_alias(pwrite64)
+# else
+strong_alias_untyped(pread,pread64)
+strong_alias_untyped(pwrite,pwrite64)
+# endif
+# endif
+#endif
diff --git a/libc/sysdeps/linux/common/pselect.c b/libc/sysdeps/linux/common/pselect.c
index 3a958fcfc..fbe85b780 100644
--- a/libc/sysdeps/linux/common/pselect.c
+++ b/libc/sysdeps/linux/common/pselect.c
@@ -13,57 +13,82 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
-#include <errno.h>
-#include <signal.h>
-#include <stddef.h> /* For NULL. */
-#include <sys/time.h>
+#include <features.h>
+
+#ifdef __USE_XOPEN2K
+
+#include <sys/syscall.h>
#include <sys/select.h>
+#include <sys/time.h>
+#include <signal.h>
+#include <cancel.h>
-extern __typeof(pselect) __libc_pselect;
+static int __NC(pselect)(int nfds, fd_set *readfds, fd_set *writefds,
+ fd_set *exceptfds, const struct timespec *timeout,
+ const sigset_t *sigmask)
+{
+#ifdef __NR_pselect6
+ /* The Linux kernel can in some situations update the timeout value.
+ * We do not want that so use a local variable.
+ */
+ struct timespec _ts;
-libc_hidden_proto(sigprocmask)
-libc_hidden_proto(select)
+ if (timeout != NULL) {
+ _ts = *timeout;
+ timeout = &_ts;
+ }
+ /* Note: the system call expects 7 values but on most architectures
+ we can only pass in 6 directly. If there is an architecture with
+ support for more parameters a new version of this file needs to
+ be created. */
+ struct {
+ __kernel_ulong_t ss;
+ __kernel_size_t ss_len;
+ } data;
+ if (sigmask != NULL) {
+ data.ss = (__kernel_ulong_t) sigmask;
+ data.ss_len = __SYSCALL_SIGSET_T_SIZE;
-/* Check the first NFDS descriptors each in READFDS (if not NULL) for read
- readiness, in WRITEFDS (if not NULL) for write readiness, and in EXCEPTFDS
- (if not NULL) for exceptional conditions. If TIMEOUT is not NULL, time out
- after waiting the interval specified therein. Additionally set the sigmask
- SIGMASK for this call. Returns the number of ready descriptors, or -1 for
- errors. */
-int
-__libc_pselect (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
- const struct timespec *timeout, const sigset_t *sigmask)
-{
- struct timeval tval;
- int retval;
- sigset_t savemask;
-
- /* Change nanosecond number to microseconds. This might mean losing
- precision and therefore the `pselect` should be available. But
- for now it is hardly found. */
- if (timeout != NULL)
- TIMESPEC_TO_TIMEVAL (&tval, timeout);
-
- /* The setting and restoring of the signal mask and the select call
- should be an atomic operation. This can't be done without kernel
- help. */
- if (sigmask != NULL)
- sigprocmask (SIG_SETMASK, sigmask, &savemask);
-
- /* Note the pselect() is a cancellation point. But since we call
- select() which itself is a cancellation point we do not have
- to do anything here. */
- retval = select (nfds, readfds, writefds, exceptfds,
- timeout != NULL ? &tval : NULL);
-
- if (sigmask != NULL)
- sigprocmask (SIG_SETMASK, &savemask, NULL);
-
- return retval;
+ sigmask = (void *)&data;
+ }
+
+ return INLINE_SYSCALL(pselect6, 6, nfds, readfds, writefds, exceptfds, timeout, sigmask);
+#else
+ struct timeval tval;
+ int retval;
+ sigset_t savemask;
+
+ /* Change nanosecond number to microseconds. This might mean losing
+ precision and therefore the `pselect` should be available. But
+ for now it is hardly found. */
+ if (timeout != NULL)
+ TIMESPEC_TO_TIMEVAL (&tval, timeout);
+
+ /* The setting and restoring of the signal mask and the select call
+ should be an atomic operation. This can't be done without kernel
+ help. */
+ if (sigmask != NULL)
+ sigprocmask (SIG_SETMASK, sigmask, &savemask);
+
+ /* The comment below does not apply on uClibc, since we use __select_nocancel */
+ /* Note the pselect() is a cancellation point. But since we call
+ select() which itself is a cancellation point we do not have
+ to do anything here. */
+ retval = __NC(select)(nfds, readfds, writefds, exceptfds,
+ timeout != NULL ? &tval : NULL);
+
+ if (sigmask != NULL)
+ sigprocmask (SIG_SETMASK, &savemask, NULL);
+
+ return retval;
+#endif
}
-weak_alias(__libc_pselect,pselect)
+CANCELLABLE_SYSCALL(int, pselect, (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
+ const struct timespec *timeout, const sigset_t *sigmask),
+ (nfds, readfds, writefds, exceptfds, timeout, sigmask))
+
+#endif
diff --git a/libc/sysdeps/linux/common/ptrace.c b/libc/sysdeps/linux/common/ptrace.c
index 4f11260b8..8b8ebf086 100644
--- a/libc/sysdeps/linux/common/ptrace.c
+++ b/libc/sysdeps/linux/common/ptrace.c
@@ -13,7 +13,7 @@
#define __NR___syscall_ptrace __NR_ptrace
static __inline__ _syscall4(long, __syscall_ptrace, enum __ptrace_request, request,
- __kernel_pid_t, pid, void*, addr, void*, data);
+ __kernel_pid_t, pid, void*, addr, void*, data)
long int
ptrace (enum __ptrace_request request, ...)
diff --git a/libc/sysdeps/linux/common/query_module.c b/libc/sysdeps/linux/common/query_module.c
index b0b72dea9..7c168df45 100644
--- a/libc/sysdeps/linux/common/query_module.c
+++ b/libc/sysdeps/linux/common/query_module.c
@@ -12,12 +12,5 @@ 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);
#ifdef __NR_query_module
_syscall5(int, query_module, const char *, name, int, which,
- void *, buf, size_t, bufsize, size_t *, ret);
-#else
-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;
-}
+ void *, buf, size_t, bufsize, size_t *, ret)
#endif
diff --git a/libc/sysdeps/linux/common/quotactl.c b/libc/sysdeps/linux/common/quotactl.c
index cb044a4e8..edd509256 100644
--- a/libc/sysdeps/linux/common/quotactl.c
+++ b/libc/sysdeps/linux/common/quotactl.c
@@ -12,5 +12,5 @@
#if defined __USE_BSD
#include <sys/quota.h>
_syscall4(int, quotactl, int, cmd, const char *, special,
- int, id, caddr_t, addr);
+ int, id, caddr_t, addr)
#endif
diff --git a/libc/sysdeps/linux/common/read.c b/libc/sysdeps/linux/common/read.c
index f837e9f07..67c29b5c1 100644
--- a/libc/sysdeps/linux/common/read.c
+++ b/libc/sysdeps/linux/common/read.c
@@ -9,10 +9,11 @@
#include <sys/syscall.h>
#include <unistd.h>
+#include <cancel.h>
-extern __typeof(read) __libc_read;
-#define __NR___libc_read __NR_read
-_syscall3(ssize_t, __libc_read, int, fd, __ptr_t, buf, size_t, count);
-libc_hidden_proto(read)
-weak_alias(__libc_read,read)
-libc_hidden_weak(read)
+#define __NR___read_nocancel __NR_read
+_syscall3(ssize_t, __NC(read), int, fd, void *, buf, size_t, count)
+
+CANCELLABLE_SYSCALL(ssize_t, read, (int fd, void *buf, size_t count),
+ (fd, buf, count))
+lt_libc_hidden(read)
diff --git a/libc/sysdeps/linux/common/readahead.c b/libc/sysdeps/linux/common/readahead.c
index 94e2481cf..bda0de2c7 100644
--- a/libc/sysdeps/linux/common/readahead.c
+++ b/libc/sysdeps/linux/common/readahead.c
@@ -13,46 +13,33 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/types.h>
#include <sys/syscall.h>
-#include <bits/wordsize.h>
-#ifdef __UCLIBC_HAS_LFS__
+#if defined __NR_readahead && defined __UCLIBC_HAS_LFS__ && defined __USE_GNU
-#include <_lfs_64.h>
-
-#ifdef __NR_readahead
-
-# define __NR___readahead __NR_readahead
+# include <fcntl.h>
+# include <bits/wordsize.h>
# if __WORDSIZE == 64
-static __inline__ _syscall3(ssize_t, __readahead, int, fd,
- off_t, offset, size_t, count);
-
-ssize_t readahead(int fd, off_t offset, size_t count)
-{
- return __readahead(fd, offset, count);
-}
+_syscall3(ssize_t, readahead, int, fd, off_t, offset, size_t, count)
# else
-static __inline__ _syscall4(ssize_t, __readahead, int, fd,
- off_t, high_offset, off_t, low_offset, size_t, count);
-
ssize_t readahead(int fd, off64_t offset, size_t count)
{
- return __readahead(fd, (off_t) (offset >> 32), (off_t) (offset & 0xffffffff), count);
+ return INLINE_SYSCALL(readahead,
+# if defined(__UCLIBC_SYSCALL_ALIGN_64BIT__)
+ 5, fd, 0,
+# else
+ 4, fd,
+# endif
+ OFF64_HI_LO(offset), count);
}
# endif
#endif
-
-#endif /* __UCLIBC_HAS_LFS__ */
diff --git a/libc/sysdeps/linux/common/readlink.c b/libc/sysdeps/linux/common/readlink.c
index d68391302..f64aeb947 100644
--- a/libc/sysdeps/linux/common/readlink.c
+++ b/libc/sysdeps/linux/common/readlink.c
@@ -10,6 +10,13 @@
#include <sys/syscall.h>
#include <unistd.h>
-libc_hidden_proto(readlink)
-_syscall3(ssize_t, readlink, const char *, path, char *, buf, size_t, bufsiz);
+#if defined(__NR_readlinkat) && !defined(__NR_readlink)
+# include <fcntl.h>
+ssize_t readlink (const char *path, char *buf, size_t len)
+{
+ return readlinkat(AT_FDCWD, path, buf, len);
+}
+#else
+_syscall3(ssize_t, readlink, const char *, path, char *, buf, size_t, bufsiz)
+#endif
libc_hidden_def(readlink)
diff --git a/libc/sysdeps/linux/common/readlinkat.c b/libc/sysdeps/linux/common/readlinkat.c
new file mode 100644
index 000000000..995b9e2c1
--- /dev/null
+++ b/libc/sysdeps/linux/common/readlinkat.c
@@ -0,0 +1,17 @@
+/*
+ * readlinkat() for uClibc
+ *
+ * Copyright (C) 2009 Analog Devices Inc.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <unistd.h>
+
+#ifdef __NR_readlinkat
+_syscall4(ssize_t, readlinkat, int, fd, const char *, path, char *, buf, size_t, len)
+libc_hidden_def(readlinkat)
+#else
+/* should add emulation with readlink() and /proc/self/fd/ ... */
+#endif
diff --git a/libc/sysdeps/linux/common/readv.c b/libc/sysdeps/linux/common/readv.c
index d9fbfd6bd..9418ea430 100644
--- a/libc/sysdeps/linux/common/readv.c
+++ b/libc/sysdeps/linux/common/readv.c
@@ -2,17 +2,29 @@
/*
* readv() for uClibc
*
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ * Copyright (C) 2006 by Steven J. Hill <sjhill@realitydiluted.com>
+ * Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org>
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
#include <sys/syscall.h>
#include <sys/uio.h>
+#include <cancel.h>
-extern __typeof(readv) __libc_readv;
+/* We should deal with kernel which have a smaller UIO_FASTIOV as well
+ as a very big count. */
+static ssize_t __NC(readv)(int fd, const struct iovec *vector, int count)
+{
+ ssize_t bytes_read = INLINE_SYSCALL(readv, 3, fd, vector, count);
-#define __NR___libc_readv __NR_readv
-_syscall3(ssize_t, __libc_readv, int, filedes, const struct iovec *, vector,
- int, count);
-weak_alias(__libc_readv,readv)
+ if (bytes_read >= 0 || errno != EINVAL || count <= UIO_FASTIOV)
+ return bytes_read;
+
+ /* glibc tries again, but we do not. */
+ /* return __atomic_readv_replacement (fd, vector, count); */
+
+ return -1;
+}
+CANCELLABLE_SYSCALL(ssize_t, readv, (int fd, const struct iovec *vector, int count),
+ (fd, vector, count))
diff --git a/libc/sysdeps/linux/common/reboot.c b/libc/sysdeps/linux/common/reboot.c
index 9ce57b1ec..ec271b179 100644
--- a/libc/sysdeps/linux/common/reboot.c
+++ b/libc/sysdeps/linux/common/reboot.c
@@ -10,7 +10,7 @@
#include <sys/syscall.h>
#include <sys/reboot.h>
#define __NR__reboot __NR_reboot
-static __inline__ _syscall3(int, _reboot, int, magic, int, magic2, int, flag);
+static __inline__ _syscall3(int, _reboot, int, magic, int, magic2, int, flag)
int reboot(int flag)
{
return (_reboot((int) 0xfee1dead, 672274793, flag));
diff --git a/libc/sysdeps/linux/common/remap_file_pages.c b/libc/sysdeps/linux/common/remap_file_pages.c
index 2af53a32e..0512b8837 100644
--- a/libc/sysdeps/linux/common/remap_file_pages.c
+++ b/libc/sysdeps/linux/common/remap_file_pages.c
@@ -11,6 +11,6 @@
#ifdef __NR_remap_file_pages
_syscall5(int, remap_file_pages, void *, __start, size_t, __size,
- int, __prot, size_t, __pgoff, int, __flags);
+ int, __prot, size_t, __pgoff, int, __flags)
#endif
diff --git a/libc/sysdeps/linux/common/rename.c b/libc/sysdeps/linux/common/rename.c
index fd7318f02..3ce5a5e3e 100644
--- a/libc/sysdeps/linux/common/rename.c
+++ b/libc/sysdeps/linux/common/rename.c
@@ -8,17 +8,15 @@
*/
#include <sys/syscall.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/param.h>
#include <stdio.h>
+#include <unistd.h>
-#define __NR___syscall_rename __NR_rename
-static __inline__ _syscall2(int, __syscall_rename, const char *, oldpath,
- const char *, newpath);
-
-int rename(const char * oldpath, const char * newpath)
+#if defined __NR_renameat && !defined __NR_rename
+# include <fcntl.h>
+int rename(const char *oldpath, const char *newpath)
{
- return __syscall_rename(oldpath, newpath);
+ return renameat(AT_FDCWD, oldpath, AT_FDCWD, newpath);
}
-
+#else
+_syscall2(int, rename, const char *, oldpath, const char *, newpath)
+#endif
diff --git a/libc/sysdeps/linux/common/renameat.c b/libc/sysdeps/linux/common/renameat.c
new file mode 100644
index 000000000..b0b91fa3e
--- /dev/null
+++ b/libc/sysdeps/linux/common/renameat.c
@@ -0,0 +1,17 @@
+/*
+ * renameat() for uClibc
+ *
+ * Copyright (C) 2009 Analog Devices Inc.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <stdio.h>
+
+#ifdef __NR_renameat
+_syscall4(int, renameat, int, oldfd, const char *, old, int, newfd, const char *, new)
+libc_hidden_def(renameat)
+#else
+/* should add emulation with rename() and /proc/self/fd/ ... */
+#endif
diff --git a/libc/sysdeps/linux/common/rmdir.c b/libc/sysdeps/linux/common/rmdir.c
index 845b3e371..d534b40b1 100644
--- a/libc/sysdeps/linux/common/rmdir.c
+++ b/libc/sysdeps/linux/common/rmdir.c
@@ -10,7 +10,14 @@
#include <sys/syscall.h>
#include <unistd.h>
-libc_hidden_proto(rmdir)
-_syscall1(int, rmdir, const char *, pathname);
+#if defined __NR_unlinkat && !defined __NR_rmdir
+# include <fcntl.h>
+int rmdir(const char *pathname)
+{
+ return unlinkat(AT_FDCWD, pathname, AT_REMOVEDIR);
+}
+#else
+_syscall1(int, rmdir, const char *, pathname)
+#endif
libc_hidden_def(rmdir)
diff --git a/libc/sysdeps/linux/common/sbrk.c b/libc/sysdeps/linux/common/sbrk.c
index 734a4ce01..4f0a8c40d 100644
--- a/libc/sysdeps/linux/common/sbrk.c
+++ b/libc/sysdeps/linux/common/sbrk.c
@@ -7,7 +7,6 @@
#include <unistd.h>
#include <errno.h>
-libc_hidden_proto(brk)
/* Defined in brk.c. */
extern void *__curbrk attribute_hidden;
@@ -15,7 +14,6 @@ extern void *__curbrk attribute_hidden;
/* Extend the process's data space by INCREMENT.
If INCREMENT is negative, shrink data space by - INCREMENT.
Return start of new space allocated, or -1 for errors. */
-libc_hidden_proto(sbrk)
void * sbrk (intptr_t increment)
{
void *oldbrk;
diff --git a/libc/sysdeps/linux/common/sched_cpucount.c b/libc/sysdeps/linux/common/sched_cpucount.c
new file mode 100644
index 000000000..318f65fb6
--- /dev/null
+++ b/libc/sysdeps/linux/common/sched_cpucount.c
@@ -0,0 +1,59 @@
+/* Copyright (C) 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <limits.h>
+#include <sched.h>
+
+
+int
+__sched_cpucount (size_t setsize, const cpu_set_t *setp)
+{
+ int s = 0;
+ const __cpu_mask *p = setp->__bits;
+ const __cpu_mask *end = &setp->__bits[setsize / sizeof (__cpu_mask)];
+
+ while (p < end)
+ {
+ __cpu_mask l = *p++;
+
+#ifdef POPCNT
+ s += POPCNT (l);
+#else
+ if (l == 0)
+ continue;
+
+# if LONG_BIT > 32
+ l = (l & 0x5555555555555555ul) + ((l >> 1) & 0x5555555555555555ul);
+ l = (l & 0x3333333333333333ul) + ((l >> 2) & 0x3333333333333333ul);
+ l = (l & 0x0f0f0f0f0f0f0f0ful) + ((l >> 4) & 0x0f0f0f0f0f0f0f0ful);
+ l = (l & 0x00ff00ff00ff00fful) + ((l >> 8) & 0x00ff00ff00ff00fful);
+ l = (l & 0x0000ffff0000fffful) + ((l >> 16) & 0x0000ffff0000fffful);
+ l = (l & 0x00000000fffffffful) + ((l >> 32) & 0x00000000fffffffful);
+# else
+ l = (l & 0x55555555ul) + ((l >> 1) & 0x55555555ul);
+ l = (l & 0x33333333ul) + ((l >> 2) & 0x33333333ul);
+ l = (l & 0x0f0f0f0ful) + ((l >> 4) & 0x0f0f0f0ful);
+ l = (l & 0x00ff00fful) + ((l >> 8) & 0x00ff00fful);
+ l = (l & 0x0000fffful) + ((l >> 16) & 0x0000fffful);
+# endif
+
+ s += l;
+#endif
+ }
+
+ return s;
+}
diff --git a/libc/sysdeps/linux/common/sched_get_priority_max.c b/libc/sysdeps/linux/common/sched_get_priority_max.c
index a9ab24639..cf5447ca7 100644
--- a/libc/sysdeps/linux/common/sched_get_priority_max.c
+++ b/libc/sysdeps/linux/common/sched_get_priority_max.c
@@ -9,4 +9,4 @@
#include <sys/syscall.h>
#include <sched.h>
-_syscall1(int, sched_get_priority_max, int, policy);
+_syscall1(int, sched_get_priority_max, int, policy)
diff --git a/libc/sysdeps/linux/common/sched_get_priority_min.c b/libc/sysdeps/linux/common/sched_get_priority_min.c
index 5a78f9393..884efed60 100644
--- a/libc/sysdeps/linux/common/sched_get_priority_min.c
+++ b/libc/sysdeps/linux/common/sched_get_priority_min.c
@@ -9,4 +9,4 @@
#include <sys/syscall.h>
#include <sched.h>
-_syscall1(int, sched_get_priority_min, int, policy);
+_syscall1(int, sched_get_priority_min, int, policy)
diff --git a/libc/sysdeps/linux/common/sched_getaffinity.c b/libc/sysdeps/linux/common/sched_getaffinity.c
index 678571239..9f5b78c3b 100644
--- a/libc/sysdeps/linux/common/sched_getaffinity.c
+++ b/libc/sysdeps/linux/common/sched_getaffinity.c
@@ -12,25 +12,19 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
-#include <features.h>
-#ifdef __USE_GNU
-
-#include <sched.h>
-#include <sys/types.h>
#include <sys/syscall.h>
-#include <string.h>
-#include <sys/param.h>
-
-/* Experimentally off - libc_hidden_proto(memset) */
-
-#define __NR___syscall_sched_getaffinity __NR_sched_getaffinity
-static __inline__ _syscall3(int, __syscall_sched_getaffinity, __kernel_pid_t, pid,
- size_t, cpusetsize, cpu_set_t *, cpuset);
+#if defined __NR_sched_getaffinity && defined __USE_GNU
+# include <sched.h>
+# include <string.h>
+# include <sys/types.h>
+# include <sys/param.h>
+# define __NR___syscall_sched_getaffinity __NR_sched_getaffinity
+static __always_inline _syscall3(int, __syscall_sched_getaffinity, __kernel_pid_t, pid,
+ size_t, cpusetsize, cpu_set_t *, cpuset)
int sched_getaffinity(pid_t pid, size_t cpusetsize, cpu_set_t *cpuset)
{
@@ -45,5 +39,4 @@ int sched_getaffinity(pid_t pid, size_t cpusetsize, cpu_set_t *cpuset)
}
return res;
}
-
#endif
diff --git a/libc/sysdeps/linux/common/sched_getcpu.c b/libc/sysdeps/linux/common/sched_getcpu.c
new file mode 100644
index 000000000..bc858ba8e
--- /dev/null
+++ b/libc/sysdeps/linux/common/sched_getcpu.c
@@ -0,0 +1,24 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * sched_getcpu() for uClibc
+ *
+ * Copyright (C) 2011 Bernhard Reutner-Fischer <uclibc@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <stdlib.h>
+#include <errno.h>
+#include <sched.h>
+#include <sysdep.h>
+
+#if defined __NR_getcpu
+int
+sched_getcpu (void)
+{
+ unsigned int cpu;
+ int r = INLINE_SYSCALL (getcpu, 3, &cpu, NULL, NULL);
+
+ return r == -1 ? r : cpu;
+}
+#endif
diff --git a/libc/sysdeps/linux/common/sched_getparam.c b/libc/sysdeps/linux/common/sched_getparam.c
index af5ba6071..eb17e255e 100644
--- a/libc/sysdeps/linux/common/sched_getparam.c
+++ b/libc/sysdeps/linux/common/sched_getparam.c
@@ -13,7 +13,7 @@
#define __NR___syscall_sched_getparam __NR_sched_getparam
static __inline__ _syscall2(int, __syscall_sched_getparam,
- __kernel_pid_t, pid, struct sched_param *, p);
+ __kernel_pid_t, pid, struct sched_param *, p)
int sched_getparam(pid_t pid, struct sched_param *p)
{
diff --git a/libc/sysdeps/linux/common/sched_getscheduler.c b/libc/sysdeps/linux/common/sched_getscheduler.c
index 9564da7fd..e657abd77 100644
--- a/libc/sysdeps/linux/common/sched_getscheduler.c
+++ b/libc/sysdeps/linux/common/sched_getscheduler.c
@@ -12,7 +12,7 @@
#include <sys/syscall.h>
#define __NR___syscall_sched_getscheduler __NR_sched_getscheduler
-static __inline__ _syscall1(int, __syscall_sched_getscheduler, __kernel_pid_t, pid);
+static __inline__ _syscall1(int, __syscall_sched_getscheduler, __kernel_pid_t, pid)
int sched_getscheduler(pid_t pid)
{
diff --git a/libc/sysdeps/linux/common/sched_rr_get_interval.c b/libc/sysdeps/linux/common/sched_rr_get_interval.c
index c59812d94..31d620fd3 100644
--- a/libc/sysdeps/linux/common/sched_rr_get_interval.c
+++ b/libc/sysdeps/linux/common/sched_rr_get_interval.c
@@ -13,7 +13,7 @@
#define __NR___syscall_sched_rr_get_interval __NR_sched_rr_get_interval
static __inline__ _syscall2(int, __syscall_sched_rr_get_interval,
- __kernel_pid_t, pid, struct timespec *, tp);
+ __kernel_pid_t, pid, struct timespec *, tp)
int sched_rr_get_interval(pid_t pid, struct timespec *tp)
{
diff --git a/libc/sysdeps/linux/common/sched_setaffinity.c b/libc/sysdeps/linux/common/sched_setaffinity.c
index 7a854a819..927744ea5 100644
--- a/libc/sysdeps/linux/common/sched_setaffinity.c
+++ b/libc/sysdeps/linux/common/sched_setaffinity.c
@@ -12,29 +12,20 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
-#include <features.h>
-#ifdef __USE_GNU
-
-#include <sched.h>
-#include <sys/types.h>
#include <sys/syscall.h>
-#ifdef INTERNAL_SYSCALL /* remove this when all archs has this #defined */
-
-#include <string.h>
-#include <unistd.h>
-#include <sys/param.h>
-#include <alloca.h>
-
-libc_hidden_proto(getpid)
-
-#define __NR___syscall_sched_setaffinity __NR_sched_setaffinity
-static __inline__ _syscall3(int, __syscall_sched_setaffinity, __kernel_pid_t, pid,
- size_t, cpusetsize, cpu_set_t *, cpuset);
+#if defined __NR_sched_setaffinity && defined __USE_GNU
+# include <sched.h>
+# include <sys/types.h>
+# include <string.h>
+# include <unistd.h>
+# include <alloca.h>
+# define __NR___syscall_sched_setaffinity __NR_sched_setaffinity
+static __always_inline _syscall3(int, __syscall_sched_setaffinity, __kernel_pid_t, pid,
+ size_t, cpusetsize, const cpu_set_t *, cpuset)
static size_t __kernel_cpumask_size;
@@ -71,7 +62,6 @@ int sched_setaffinity(pid_t pid, size_t cpusetsize, const cpu_set_t *cpuset)
return -1;
}
- return INLINE_SYSCALL (sched_setaffinity, 3, pid, cpusetsize, cpuset);
+ return __syscall_sched_setaffinity(pid, cpusetsize, cpuset);
}
#endif
-#endif
diff --git a/libc/sysdeps/linux/common/sched_setparam.c b/libc/sysdeps/linux/common/sched_setparam.c
index 1e1f8cf2d..0f5f74f0d 100644
--- a/libc/sysdeps/linux/common/sched_setparam.c
+++ b/libc/sysdeps/linux/common/sched_setparam.c
@@ -13,7 +13,7 @@
#define __NR___syscall_sched_setparam __NR_sched_setparam
static __inline__ _syscall2(int, __syscall_sched_setparam,
- __kernel_pid_t, pid, const struct sched_param *, p);
+ __kernel_pid_t, pid, const struct sched_param *, p)
int sched_setparam(pid_t pid, const struct sched_param *p)
{
diff --git a/libc/sysdeps/linux/common/sched_setscheduler.c b/libc/sysdeps/linux/common/sched_setscheduler.c
index fe2630871..0af498fc2 100644
--- a/libc/sysdeps/linux/common/sched_setscheduler.c
+++ b/libc/sysdeps/linux/common/sched_setscheduler.c
@@ -13,7 +13,7 @@
#define __NR___syscall_sched_setscheduler __NR_sched_setscheduler
static __inline__ _syscall3(int, __syscall_sched_setscheduler,
- __kernel_pid_t, pid, int, policy, const struct sched_param *, p);
+ __kernel_pid_t, pid, int, policy, const struct sched_param *, p)
int sched_setscheduler(pid_t pid, int policy, const struct sched_param *p)
{
diff --git a/libc/sysdeps/linux/common/sched_yield.c b/libc/sysdeps/linux/common/sched_yield.c
index 2ae5396c9..2d584bdc7 100644
--- a/libc/sysdeps/linux/common/sched_yield.c
+++ b/libc/sysdeps/linux/common/sched_yield.c
@@ -9,4 +9,4 @@
#include <sys/syscall.h>
#include <sched.h>
-_syscall0(int, sched_yield);
+_syscall0(int, sched_yield)
diff --git a/libc/sysdeps/linux/common/select.c b/libc/sysdeps/linux/common/select.c
index 71a4990ab..c13bd0418 100644
--- a/libc/sysdeps/linux/common/select.c
+++ b/libc/sysdeps/linux/common/select.c
@@ -9,39 +9,53 @@
#include <sys/syscall.h>
#include <sys/select.h>
+#include <cancel.h>
-extern __typeof(select) __libc_select;
+#ifdef __NR__newselect
+# undef __NR_select
+# define __NR_select __NR__newselect
+#endif
-#if !defined(__NR__newselect) && !defined(__NR_select) && defined __USE_XOPEN2K
-# define __NR___libc_pselect6 __NR_pselect6
-_syscall6(int, __libc_pselect6, int, n, fd_set *, readfds, fd_set *, writefds,
- fd_set *, exceptfds, const struct timespec *, timeout,
- const sigset_t *, sigmask);
+#if !defined __NR_select && defined __NR_pselect6
+# include <stdint.h>
+# define USEC_PER_SEC 1000000L
+#endif
-int __libc_select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
- struct timeval *timeout)
+int __NC(select)(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
+ struct timeval *timeout)
{
+#ifdef __NR_select
+ return INLINE_SYSCALL(select, 5, n, readfds, writefds, exceptfds, timeout);
+#elif defined __NR_pselect6
struct timespec _ts, *ts = 0;
if (timeout) {
+ uint32_t usec;
_ts.tv_sec = timeout->tv_sec;
- _ts.tv_nsec = timeout->tv_usec * 1000;
- ts = &_ts;
- }
- return __libc_pselect6(n, readfds, writefds, exceptfds, ts, 0);
-}
-#else
+ /* GNU extension: allow for timespec values where the sub-sec
+ * field is equal to or more than 1 second. The kernel will
+ * reject this on us, so take care of the time shift ourself.
+ * Some applications (like readline and linphone) do this.
+ * See 'clarification on select() type calls and invalid timeouts'
+ * on the POSIX general list for more information.
+ */
+ usec = timeout->tv_usec;
+ if (usec >= USEC_PER_SEC) {
+ _ts.tv_sec += usec / USEC_PER_SEC;
+ usec %= USEC_PER_SEC;
+ }
+ _ts.tv_nsec = usec * 1000;
-#ifdef __NR__newselect
-# define __NR___libc_select __NR__newselect
-#else
-# define __NR___libc_select __NR_select
+ ts = &_ts;
+ }
+ return INLINE_SYSCALL(pselect6, 6, n, readfds, writefds, exceptfds, ts, 0);
#endif
-_syscall5(int, __libc_select, int, n, fd_set *, readfds, fd_set *, writefds,
- fd_set *, exceptfds, struct timeval *, timeout);
-
+}
+/* we should guard it, but we need it in other files, so let it fail
+ * if we miss any of the syscalls */
+#if 1 /*defined __NR_select || defined __NR_pselect6*/
+CANCELLABLE_SYSCALL(int, select, (int n, fd_set *readfds, fd_set *writefds,
+ fd_set *exceptfds, struct timeval *timeout),
+ (n, readfds, writefds, exceptfds, timeout))
+lt_libc_hidden(select)
#endif
-
-libc_hidden_proto(select)
-weak_alias(__libc_select,select)
-libc_hidden_weak(select)
diff --git a/libc/sysdeps/linux/common/sendfile.c b/libc/sysdeps/linux/common/sendfile.c
index 18427e85b..2f4887145 100644
--- a/libc/sysdeps/linux/common/sendfile.c
+++ b/libc/sysdeps/linux/common/sendfile.c
@@ -7,23 +7,58 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-/* need to hide the 64bit prototype or the strong_alias()
- * will fail when __NR_sendfile64 doesnt exist */
-#define sendfile64 __hidesendfile64
-
#include <sys/syscall.h>
-#include <unistd.h>
-#include <sys/sendfile.h>
-
-#undef sendfile64
-#ifdef __NR_sendfile
+# include <sys/sendfile.h>
+# include <bits/wordsize.h>
+#if defined __NR_sendfile
_syscall4(ssize_t, sendfile, int, out_fd, int, in_fd, __off_t *, offset,
- size_t, count);
+ size_t, count)
+# if defined __UCLIBC_HAS_LFS__ && (!defined __NR_sendfile64 || __WORDSIZE == 64)
+libc_hidden_def(sendfile64)
+strong_alias_untyped(sendfile,sendfile64)
+# endif
-#if ! defined __NR_sendfile64 && defined __UCLIBC_HAS_LFS__
-strong_alias(sendfile,sendfile64)
-#endif
+#elif defined __NR_sendfile64 && !defined __NR_sendfile
+# include <unistd.h>
+# include <stddef.h>
+
+ssize_t sendfile(int out_fd, int in_fd, __off_t *offset, size_t count)
+{
+ __off64_t off64, *off;
+ ssize_t res;
+
+ /*
+ * Check if valid fds and valid pointers were passed
+ * This does not prevent the user from passing
+ * an arbitrary pointer causing a segfault or
+ * other security issues
+ */
+
+ if (in_fd < 0 || out_fd < 0) {
+ __set_errno(EBADF);
+ return -1;
+ }
-#endif /* __NR_sendfile */
+ if (offset == NULL || (int)offset < 0) {
+ __set_errno(EFAULT);
+ return -1;
+ }
+
+ if (offset) {
+ off = &off64;
+ off64 = *offset;
+ } else {
+ off = NULL;
+ }
+
+ res = INLINE_SYSCALL(sendfile64, 4, out_fd, in_fd, off, count);
+
+ if (res >= 0)
+ *offset = off64;
+
+ return res;
+}
+
+#endif
diff --git a/libc/sysdeps/linux/common/sendfile64.c b/libc/sysdeps/linux/common/sendfile64.c
index 29cff5ec5..1c01ace7f 100644
--- a/libc/sysdeps/linux/common/sendfile64.c
+++ b/libc/sysdeps/linux/common/sendfile64.c
@@ -10,15 +10,12 @@
* just the macro we need to order things, __LONG_LONG_PAIR.
*/
-#include <features.h>
-#include <unistd.h>
-#include <errno.h>
-#include <endian.h>
-#include <stdint.h>
-#include <sys/sendfile.h>
+#include <_lfs_64.h>
#include <sys/syscall.h>
#include <bits/wordsize.h>
-#if defined __UCLIBC_HAS_LFS__ && defined __NR_sendfile64
-_syscall4(ssize_t,sendfile64, int, out_fd, int, in_fd, __off64_t *, offset, size_t, count);
+#if defined __NR_sendfile64 && __WORDSIZE != 64
+# include <sys/sendfile.h>
+_syscall4(ssize_t,sendfile64, int, out_fd, int, in_fd, __off64_t *, offset, size_t, count)
+libc_hidden_def(sendfile64)
#endif
diff --git a/libc/sysdeps/linux/common/setdomainname.c b/libc/sysdeps/linux/common/setdomainname.c
index e134b0d45..6b768b7f7 100644
--- a/libc/sysdeps/linux/common/setdomainname.c
+++ b/libc/sysdeps/linux/common/setdomainname.c
@@ -10,5 +10,5 @@
#include <sys/syscall.h>
#include <unistd.h>
#if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_UNIX98)
-_syscall2(int, setdomainname, const char *, name, size_t, len);
+_syscall2(int, setdomainname, const char *, name, size_t, len)
#endif
diff --git a/libc/sysdeps/linux/common/setegid.c b/libc/sysdeps/linux/common/setegid.c
index 33c627c51..eae57f585 100644
--- a/libc/sysdeps/linux/common/setegid.c
+++ b/libc/sysdeps/linux/common/setegid.c
@@ -11,10 +11,11 @@
#include <sys/types.h>
#include <sys/syscall.h>
-#if (defined __NR_setresgid || defined __NR_setresgid32) && defined __USE_GNU
-libc_hidden_proto(setresgid)
+
+#if !defined __UCLIBC_LINUX_SPECIFIC__
+#undef __NR_setresgid
+#undef __NR_setresgid32
#endif
-libc_hidden_proto(setregid)
int setegid(gid_t gid)
{
diff --git a/libc/sysdeps/linux/common/seteuid.c b/libc/sysdeps/linux/common/seteuid.c
index 5a6e9a25a..3e1611d08 100644
--- a/libc/sysdeps/linux/common/seteuid.c
+++ b/libc/sysdeps/linux/common/seteuid.c
@@ -16,13 +16,6 @@
#undef __NR_setresuid32
#endif
-libc_hidden_proto(seteuid)
-
-#if (defined __NR_setresuid || defined __NR_setresuid32) && defined __USE_GNU
-libc_hidden_proto(setresuid)
-#endif
-libc_hidden_proto(setreuid)
-
int seteuid(uid_t uid)
{
int result;
diff --git a/libc/sysdeps/linux/common/setfsgid.c b/libc/sysdeps/linux/common/setfsgid.c
index de005e28d..78d35dd5a 100644
--- a/libc/sysdeps/linux/common/setfsgid.c
+++ b/libc/sysdeps/linux/common/setfsgid.c
@@ -17,12 +17,12 @@
# define __NR_setfsgid __NR_setfsgid32
# endif
-_syscall1(int, setfsgid, gid_t, gid);
+_syscall1(int, setfsgid, gid_t, gid)
#else
# define __NR___syscall_setfsgid __NR_setfsgid
-static __inline__ _syscall1(int, __syscall_setfsgid, __kernel_gid_t, gid);
+static __inline__ _syscall1(int, __syscall_setfsgid, __kernel_gid_t, gid)
int setfsgid(gid_t gid)
{
diff --git a/libc/sysdeps/linux/common/setfsuid.c b/libc/sysdeps/linux/common/setfsuid.c
index 698117a1a..a7372bd29 100644
--- a/libc/sysdeps/linux/common/setfsuid.c
+++ b/libc/sysdeps/linux/common/setfsuid.c
@@ -17,12 +17,12 @@
# define __NR_setfsuid __NR_setfsuid32
# endif
-_syscall1(int, setfsuid, uid_t, uid);
+_syscall1(int, setfsuid, uid_t, uid)
#else
# define __NR___syscall_setfsuid __NR_setfsuid
-static __inline__ _syscall1(int, __syscall_setfsuid, __kernel_uid_t, uid);
+static __inline__ _syscall1(int, __syscall_setfsuid, __kernel_uid_t, uid)
int setfsuid(uid_t uid)
{
diff --git a/libc/sysdeps/linux/common/setgid.c b/libc/sysdeps/linux/common/setgid.c
index 37175cd7c..88341ba86 100644
--- a/libc/sysdeps/linux/common/setgid.c
+++ b/libc/sysdeps/linux/common/setgid.c
@@ -17,12 +17,12 @@
# define __NR_setgid __NR_setgid32
# endif
-_syscall1(int, setgid, gid_t, gid);
+_syscall1(int, setgid, gid_t, gid)
#else
# define __NR___syscall_setgid __NR_setgid
-static __inline__ _syscall1(int, __syscall_setgid, __kernel_gid_t, gid);
+static __inline__ _syscall1(int, __syscall_setgid, __kernel_gid_t, gid)
int setgid(gid_t gid)
{
diff --git a/libc/sysdeps/linux/common/setgroups.c b/libc/sysdeps/linux/common/setgroups.c
index 3c77250d0..d97859f0d 100644
--- a/libc/sysdeps/linux/common/setgroups.c
+++ b/libc/sysdeps/linux/common/setgroups.c
@@ -8,29 +8,27 @@
*/
#include <sys/syscall.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <grp.h>
#ifdef __USE_BSD
-
-libc_hidden_proto(setgroups)
+#include <grp.h>
#if defined(__NR_setgroups32)
# undef __NR_setgroups
# define __NR_setgroups __NR_setgroups32
-_syscall2(int, setgroups, size_t, size, const gid_t *, list);
+_syscall2(int, setgroups, size_t, size, const gid_t *, list)
#elif __WORDSIZE == 64
-_syscall2(int, setgroups, size_t, size, const gid_t *, list);
+_syscall2(int, setgroups, size_t, size, const gid_t *, list)
#else
+# include <errno.h>
+# include <stdlib.h>
+# include <unistd.h>
+# include <sys/types.h>
-libc_hidden_proto(sysconf)
-
-#define __NR___syscall_setgroups __NR_setgroups
-static __inline__ _syscall2(int, __syscall_setgroups,
- size_t, size, const __kernel_gid_t *, list);
+# define __NR___syscall_setgroups __NR_setgroups
+static __always_inline _syscall2(int, __syscall_setgroups,
+ size_t, size, const __kernel_gid_t *, list)
int setgroups(size_t size, const gid_t *groups)
{
diff --git a/libc/sysdeps/linux/common/sethostname.c b/libc/sysdeps/linux/common/sethostname.c
index 6bd4c2362..1ceb2a089 100644
--- a/libc/sysdeps/linux/common/sethostname.c
+++ b/libc/sysdeps/linux/common/sethostname.c
@@ -10,5 +10,5 @@
#include <sys/syscall.h>
#include <unistd.h>
#if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_UNIX98)
-_syscall2(int, sethostname, const char *, name, size_t, len);
+_syscall2(int, sethostname, const char *, name, size_t, len)
#endif
diff --git a/libc/sysdeps/linux/common/setitimer.c b/libc/sysdeps/linux/common/setitimer.c
index ca9db82d2..427ff1eff 100644
--- a/libc/sysdeps/linux/common/setitimer.c
+++ b/libc/sysdeps/linux/common/setitimer.c
@@ -10,8 +10,7 @@
#include <sys/syscall.h>
#include <sys/time.h>
-libc_hidden_proto(setitimer)
_syscall3(int, setitimer, __itimer_which_t, which,
- const struct itimerval *, new, struct itimerval *, old);
+ const struct itimerval *, new, struct itimerval *, old)
libc_hidden_def(setitimer)
diff --git a/libc/sysdeps/linux/common/setns.c b/libc/sysdeps/linux/common/setns.c
new file mode 100644
index 000000000..a697720b9
--- /dev/null
+++ b/libc/sysdeps/linux/common/setns.c
@@ -0,0 +1,15 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * setns() for uClibc
+ *
+ * Copyright (C) 2015 Bernhard Reutner-Fischer <uclibc@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <sched.h>
+
+#ifdef __NR_setns
+_syscall2(int, setns, int, fd, int, nstype)
+#endif
diff --git a/libc/sysdeps/linux/common/setpgid.c b/libc/sysdeps/linux/common/setpgid.c
index f91908ded..0410c64f3 100644
--- a/libc/sysdeps/linux/common/setpgid.c
+++ b/libc/sysdeps/linux/common/setpgid.c
@@ -12,11 +12,10 @@
#if defined __USE_UNIX98 || defined __USE_SVID
#include <unistd.h>
-libc_hidden_proto(setpgid)
#define __NR___syscall_setpgid __NR_setpgid
static __inline__ _syscall2(int, __syscall_setpgid,
- __kernel_pid_t, pid, __kernel_pid_t, pgid);
+ __kernel_pid_t, pid, __kernel_pid_t, pgid)
int setpgid(pid_t pid, pid_t pgid)
{
diff --git a/libc/sysdeps/linux/common/setpgrp.c b/libc/sysdeps/linux/common/setpgrp.c
index 38300dc2e..bc8e89442 100644
--- a/libc/sysdeps/linux/common/setpgrp.c
+++ b/libc/sysdeps/linux/common/setpgrp.c
@@ -4,11 +4,8 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#include <syscall.h>
#include <unistd.h>
-libc_hidden_proto(setpgid)
-
int setpgrp(void)
{
return setpgid(0,0);
diff --git a/libc/sysdeps/linux/common/setpriority.c b/libc/sysdeps/linux/common/setpriority.c
index 6674494ab..05d5dd995 100644
--- a/libc/sysdeps/linux/common/setpriority.c
+++ b/libc/sysdeps/linux/common/setpriority.c
@@ -10,7 +10,6 @@
#include <sys/syscall.h>
#include <sys/resource.h>
-libc_hidden_proto(setpriority)
-_syscall3(int, setpriority, __priority_which_t, which, id_t, who, int, prio);
+_syscall3(int, setpriority, __priority_which_t, which, id_t, who, int, prio)
libc_hidden_def(setpriority)
diff --git a/libc/sysdeps/linux/common/setregid.c b/libc/sysdeps/linux/common/setregid.c
index 3fe95d9d0..aaa729379 100644
--- a/libc/sysdeps/linux/common/setregid.c
+++ b/libc/sysdeps/linux/common/setregid.c
@@ -11,7 +11,6 @@
#include <unistd.h>
#include <bits/wordsize.h>
-libc_hidden_proto(setregid)
#if (__WORDSIZE == 32 && defined(__NR_setregid32)) || __WORDSIZE == 64
# ifdef __NR_setregid32
@@ -19,13 +18,13 @@ libc_hidden_proto(setregid)
# define __NR_setregid __NR_setregid32
# endif
-_syscall2(int, setregid, gid_t, rgid, gid_t, egid);
+_syscall2(int, setregid, gid_t, rgid, gid_t, egid)
#else
# define __NR___syscall_setregid __NR_setregid
static __inline__ _syscall2(int, __syscall_setregid,
- __kernel_gid_t, rgid, __kernel_gid_t, egid);
+ __kernel_gid_t, rgid, __kernel_gid_t, egid)
int setregid(gid_t rgid, gid_t egid)
{
@@ -38,4 +37,4 @@ int setregid(gid_t rgid, gid_t egid)
}
#endif
-libc_hidden_def(setregid)
+libc_hidden_weak(setregid)
diff --git a/libc/sysdeps/linux/common/setresgid.c b/libc/sysdeps/linux/common/setresgid.c
index 13e4b1d6d..b6d1647db 100644
--- a/libc/sysdeps/linux/common/setresgid.c
+++ b/libc/sysdeps/linux/common/setresgid.c
@@ -15,17 +15,15 @@
# undef __NR_setresgid
# define __NR_setresgid __NR_setresgid32
-libc_hidden_proto(setresgid)
_syscall3(int, setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
-libc_hidden_def(setresgid)
+libc_hidden_weak(setresgid)
#elif defined(__NR_setresgid)
# define __NR___syscall_setresgid __NR_setresgid
static __inline__ _syscall3(int, __syscall_setresgid,
- __kernel_gid_t, rgid, __kernel_gid_t, egid, __kernel_gid_t, sgid);
+ __kernel_gid_t, rgid, __kernel_gid_t, egid, __kernel_gid_t, sgid)
-libc_hidden_proto(setresgid)
int setresgid(gid_t rgid, gid_t egid, gid_t sgid)
{
if (((rgid + 1) > (gid_t) ((__kernel_gid_t) - 1U))
@@ -36,7 +34,7 @@ int setresgid(gid_t rgid, gid_t egid, gid_t sgid)
}
return (__syscall_setresgid(rgid, egid, sgid));
}
-libc_hidden_def(setresgid)
+libc_hidden_weak(setresgid)
#endif
diff --git a/libc/sysdeps/linux/common/setresuid.c b/libc/sysdeps/linux/common/setresuid.c
index 764b90523..a2a218332 100644
--- a/libc/sysdeps/linux/common/setresuid.c
+++ b/libc/sysdeps/linux/common/setresuid.c
@@ -15,17 +15,15 @@
# undef __NR_setresuid
# define __NR_setresuid __NR_setresuid32
-libc_hidden_proto(setresuid)
_syscall3(int, setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
-libc_hidden_def(setresuid)
+libc_hidden_weak(setresuid)
#elif defined(__NR_setresuid)
# define __NR___syscall_setresuid __NR_setresuid
static __inline__ _syscall3(int, __syscall_setresuid,
- __kernel_uid_t, rgid, __kernel_uid_t, egid, __kernel_uid_t, sgid);
+ __kernel_uid_t, rgid, __kernel_uid_t, egid, __kernel_uid_t, sgid)
-libc_hidden_proto(setresuid)
int setresuid(uid_t ruid, uid_t euid, uid_t suid)
{
if (((ruid + 1) > (uid_t) ((__kernel_uid_t) - 1U))
@@ -36,7 +34,7 @@ int setresuid(uid_t ruid, uid_t euid, uid_t suid)
}
return (__syscall_setresuid(ruid, euid, suid));
}
-libc_hidden_def(setresuid)
+libc_hidden_weak(setresuid)
#endif
diff --git a/libc/sysdeps/linux/common/setreuid.c b/libc/sysdeps/linux/common/setreuid.c
index bca7f8f43..583a987c0 100644
--- a/libc/sysdeps/linux/common/setreuid.c
+++ b/libc/sysdeps/linux/common/setreuid.c
@@ -11,7 +11,6 @@
#include <unistd.h>
#include <bits/wordsize.h>
-libc_hidden_proto(setreuid)
#if (__WORDSIZE == 32 && defined(__NR_setreuid32)) || __WORDSIZE == 64
# ifdef __NR_setreuid32
@@ -19,13 +18,13 @@ libc_hidden_proto(setreuid)
# define __NR_setreuid __NR_setreuid32
# endif
-_syscall2(int, setreuid, uid_t, ruid, uid_t, euid);
+_syscall2(int, setreuid, uid_t, ruid, uid_t, euid)
#else
# define __NR___syscall_setreuid __NR_setreuid
static __inline__ _syscall2(int, __syscall_setreuid,
- __kernel_uid_t, ruid, __kernel_uid_t, euid);
+ __kernel_uid_t, ruid, __kernel_uid_t, euid)
int setreuid(uid_t ruid, uid_t euid)
{
@@ -38,4 +37,4 @@ int setreuid(uid_t ruid, uid_t euid)
}
#endif
-libc_hidden_def(setreuid)
+libc_hidden_weak(setreuid)
diff --git a/libc/sysdeps/linux/common/setrlimit.c b/libc/sysdeps/linux/common/setrlimit.c
index ce9fe2275..d96700aec 100644
--- a/libc/sysdeps/linux/common/setrlimit.c
+++ b/libc/sysdeps/linux/common/setrlimit.c
@@ -7,13 +7,9 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define setrlimit64 __hide_setrlimit64
#include <sys/syscall.h>
-#include <unistd.h>
#include <sys/resource.h>
-#undef setrlimit64
-
-libc_hidden_proto(setrlimit)
+#include <bits/wordsize.h>
/* Only wrap setrlimit if the new usetrlimit is not present and setrlimit sucks */
@@ -21,26 +17,31 @@ libc_hidden_proto(setrlimit)
/* just call usetrlimit() */
# define __NR___syscall_usetrlimit __NR_usetrlimit
-static inline
+static __always_inline
_syscall2(int, __syscall_usetrlimit, enum __rlimit_resource, resource,
- const struct rlimit *, rlim);
+ const struct rlimit *, rlim)
int setrlimit(__rlimit_resource_t resource, struct rlimit *rlimits)
{
- return (__syscall_usetrlimit(resource, rlimits));
+ return __syscall_usetrlimit(resource, rlimits);
}
#elif !defined(__UCLIBC_HANDLE_OLDER_RLIMIT__)
/* We don't need to wrap setrlimit() */
_syscall2(int, setrlimit, __rlimit_resource_t, resource,
- const struct rlimit *, rlim);
+ const struct rlimit *, rlim)
#else
+# define __need_NULL
+# include <stddef.h>
+# include <errno.h>
+# include <sys/param.h>
+
/* we have to handle old style setrlimit() */
# define __NR___syscall_setrlimit __NR_setrlimit
-static inline
-_syscall2(int, __syscall_setrlimit, int, resource, const struct rlimit *, rlim);
+static __always_inline
+_syscall2(int, __syscall_setrlimit, int, resource, const struct rlimit *, rlim)
int setrlimit(__rlimit_resource_t resource, const struct rlimit *rlimits)
{
@@ -53,18 +54,15 @@ int setrlimit(__rlimit_resource_t resource, const struct rlimit *rlimits)
/* We might have to correct the limits values. Since the old values
* were signed the new values might be too large. */
-# define RMIN(x, y) ((x) < (y) ? (x) : (y))
- rlimits_small.rlim_cur = RMIN((unsigned long int) rlimits->rlim_cur,
+ rlimits_small.rlim_cur = MIN((unsigned long int) rlimits->rlim_cur,
RLIM_INFINITY >> 1);
- rlimits_small.rlim_max = RMIN((unsigned long int) rlimits->rlim_max,
+ rlimits_small.rlim_max = MIN((unsigned long int) rlimits->rlim_max,
RLIM_INFINITY >> 1);
-#undef RMIN
- return (__syscall_setrlimit(resource, &rlimits_small));
+ return __syscall_setrlimit(resource, &rlimits_small);
}
#endif
-
libc_hidden_def(setrlimit)
#if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64
-strong_alias(setrlimit, setrlimit64)
+strong_alias_untyped(setrlimit, setrlimit64)
#endif
diff --git a/libc/sysdeps/linux/common/setrlimit64.c b/libc/sysdeps/linux/common/setrlimit64.c
index 90b8eebd7..fee14f4ad 100644
--- a/libc/sysdeps/linux/common/setrlimit64.c
+++ b/libc/sysdeps/linux/common/setrlimit64.c
@@ -12,21 +12,16 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <_lfs_64.h>
-
-#include <sys/types.h>
-#include <sys/resource.h>
#include <bits/wordsize.h>
/* the regular setrlimit will work just fine for 64bit users */
+#if __WORDSIZE == 32
-#if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 32
-
-libc_hidden_proto(setrlimit)
+# include <sys/resource.h>
/* Set the soft and hard limits for RESOURCE to *RLIMITS.
Only the super-user can increase hard limits.
diff --git a/libc/sysdeps/linux/common/setsid.c b/libc/sysdeps/linux/common/setsid.c
index 7e5bd33a4..5da65b966 100644
--- a/libc/sysdeps/linux/common/setsid.c
+++ b/libc/sysdeps/linux/common/setsid.c
@@ -10,7 +10,5 @@
#include <sys/syscall.h>
#include <unistd.h>
-libc_hidden_proto(setsid)
-
-_syscall0(pid_t, setsid);
+_syscall0(pid_t, setsid)
libc_hidden_def(setsid)
diff --git a/libc/sysdeps/linux/common/settimeofday.c b/libc/sysdeps/linux/common/settimeofday.c
index 7f7c24d26..e6b396e15 100644
--- a/libc/sysdeps/linux/common/settimeofday.c
+++ b/libc/sysdeps/linux/common/settimeofday.c
@@ -8,13 +8,36 @@
*/
#include <sys/syscall.h>
-#include <sys/time.h>
#ifdef __USE_BSD
+# include <sys/time.h>
+# ifdef __NR_settimeofday
+_syscall2(int, settimeofday, const struct timeval *, tv,
+ const struct timezone *, tz)
+# elif defined __USE_SVID && defined __NR_stime
+# define __need_NULL
+# include <stddef.h>
+# include <errno.h>
+# include <time.h>
+int settimeofday(const struct timeval *tv, const struct timezone *tz)
+{
+ time_t when;
-libc_hidden_proto(settimeofday)
+ if (tv == NULL) {
+ __set_errno(EINVAL);
+ return -1;
+ }
-_syscall2(int, settimeofday, const struct timeval *, tv,
- const struct timezone *, tz);
+ if (tz != NULL || tv->tv_usec % 1000000 != 0) {
+ __set_errno(ENOSYS);
+ return -1;
+ }
+
+ when = tv->tv_sec + (tv->tv_usec / 1000000);
+ return stime(&when);
+}
+# endif
+# if defined __NR_settimeofday || (defined __USE_SVID && defined __NR_stime)
libc_hidden_def(settimeofday)
+# endif
#endif
diff --git a/libc/sysdeps/linux/common/setuid.c b/libc/sysdeps/linux/common/setuid.c
index 32a4cd79e..470be1f0f 100644
--- a/libc/sysdeps/linux/common/setuid.c
+++ b/libc/sysdeps/linux/common/setuid.c
@@ -17,12 +17,12 @@
# define __NR_setuid __NR_setuid32
# endif
-_syscall1(int, setuid, uid_t, uid);
+_syscall1(int, setuid, uid_t, uid)
#else
# define __NR___syscall_setuid __NR_setuid
-static __inline__ _syscall1(int, __syscall_setuid, __kernel_uid_t, uid);
+static __always_inline _syscall1(int, __syscall_setuid, __kernel_uid_t, uid)
int setuid(uid_t uid)
{
@@ -30,6 +30,6 @@ int setuid(uid_t uid)
__set_errno(EINVAL);
return -1;
}
- return (__syscall_setuid(uid));
+ return __syscall_setuid(uid);
}
#endif
diff --git a/libc/sysdeps/linux/common/sigaltstack.c b/libc/sysdeps/linux/common/sigaltstack.c
index 0c9308408..964e16f99 100644
--- a/libc/sysdeps/linux/common/sigaltstack.c
+++ b/libc/sysdeps/linux/common/sigaltstack.c
@@ -13,5 +13,5 @@
#if defined __NR_sigaltstack && (defined __USE_BSD || defined __USE_UNIX98)
_syscall2(int, sigaltstack, const struct sigaltstack *, ss,
- struct sigaltstack *, oss);
+ struct sigaltstack *, oss)
#endif
diff --git a/libc/sysdeps/linux/common/signalfd.c b/libc/sysdeps/linux/common/signalfd.c
new file mode 100644
index 000000000..c9584f015
--- /dev/null
+++ b/libc/sysdeps/linux/common/signalfd.c
@@ -0,0 +1,37 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * signalfd() for uClibc
+ *
+ * Copyright (C) 2008 Bernhard Reutner-Fischer <uclibc@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <signal.h>
+#include <sys/signalfd.h>
+
+#if defined __NR_signalfd4
+#define __NR___syscall_signalfd4 __NR_signalfd4
+static __inline__ _syscall4(int, __syscall_signalfd4, int, fd,
+ const sigset_t *, mask, size_t, sizemask, int, flags)
+#elif defined __NR_signalfd
+#define __NR___syscall_signalfd __NR_signalfd
+static __inline__ _syscall3(int, __syscall_signalfd, int, fd,
+ const sigset_t *, mask, size_t, sizemask)
+#endif
+
+#if defined __NR_signalfd4 || defined __NR_signalfd
+int signalfd (int fd, const sigset_t *mask, int flags)
+{
+#if defined __NR___syscall_signalfd4
+ return __syscall_signalfd4(fd, mask, __SYSCALL_SIGSET_T_SIZE, flags);
+#elif defined __NR___syscall_signalfd
+ if (flags != 0) {
+ __set_errno(EINVAL);
+ return -1;
+ }
+ return __syscall_signalfd(fd, mask, __SYSCALL_SIGSET_T_SIZE);
+#endif
+}
+#endif
diff --git a/libc/sysdeps/linux/common/sigpending.c b/libc/sysdeps/linux/common/sigpending.c
index 0a74afaa4..78a0d84ee 100644
--- a/libc/sysdeps/linux/common/sigpending.c
+++ b/libc/sysdeps/linux/common/sigpending.c
@@ -15,13 +15,13 @@
#ifdef __NR_rt_sigpending
# define __NR___rt_sigpending __NR_rt_sigpending
-static __inline__ _syscall2(int, __rt_sigpending, sigset_t *, set, size_t, size);
+static __inline__ _syscall2(int, __rt_sigpending, sigset_t *, set, size_t, size)
int sigpending(sigset_t * set)
{
- return __rt_sigpending(set, _NSIG / 8);
+ return __rt_sigpending(set, __SYSCALL_SIGSET_T_SIZE);
}
#else
-_syscall1(int, sigpending, sigset_t *, set);
+_syscall1(int, sigpending, sigset_t *, set)
#endif
#endif
diff --git a/libc/sysdeps/linux/common/sigprocmask.c b/libc/sysdeps/linux/common/sigprocmask.c
index d36a5045e..efe440fde 100644
--- a/libc/sysdeps/linux/common/sigprocmask.c
+++ b/libc/sysdeps/linux/common/sigprocmask.c
@@ -11,6 +11,9 @@
#if defined __USE_POSIX
#include <signal.h>
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+# include <pthreadP.h> /* SIGCANCEL */
+#endif
#undef sigprocmask
@@ -19,53 +22,69 @@ libc_hidden_proto(sigprocmask)
#ifdef __NR_rt_sigprocmask
# define __NR___rt_sigprocmask __NR_rt_sigprocmask
-static inline
+static __always_inline
_syscall4(int, __rt_sigprocmask, int, how, const sigset_t *, set,
- sigset_t *, oldset, size_t, size);
+ sigset_t *, oldset, size_t, size)
int sigprocmask(int how, const sigset_t * set, sigset_t * oldset)
{
- if (set &&
-# if (SIG_BLOCK == 0) && (SIG_UNBLOCK == 1) && (SIG_SETMASK == 2)
- (((unsigned int) how) > 2)
-#elif (SIG_BLOCK == 1) && (SIG_UNBLOCK == 2) && (SIG_SETMASK == 3)
- (((unsigned int)(how-1)) > 2)
-# else
-# warning "compile time assumption violated.. slow path..."
- ((how != SIG_BLOCK) && (how != SIG_UNBLOCK)
- && (how != SIG_SETMASK))
+#ifdef SIGCANCEL
+ sigset_t local_newmask;
+
+ /*
+ * The only thing we have to make sure here is that SIGCANCEL and
+ * SIGSETXID are not blocked.
+ */
+ if (set != NULL && (unlikely (__sigismember (set, SIGCANCEL))
+# ifdef SIGSETXID
+ || unlikely (__sigismember (set, SIGSETXID))
+# endif
+ ))
+ {
+ local_newmask = *set;
+ __sigdelset (&local_newmask, SIGCANCEL);
+# ifdef SIGSETXID
+ __sigdelset (&local_newmask, SIGSETXID);
# endif
- ) {
- __set_errno(EINVAL);
- return -1;
+ set = &local_newmask;
}
- return __rt_sigprocmask(how, set, oldset, _NSIG / 8);
+#endif
+
+ return __rt_sigprocmask(how, set, oldset, __SYSCALL_SIGSET_T_SIZE);
}
#else
# define __NR___syscall_sigprocmask __NR_sigprocmask
-static inline
+static __always_inline
_syscall3(int, __syscall_sigprocmask, int, how, const sigset_t *, set,
- sigset_t *, oldset);
+ sigset_t *, oldset)
int sigprocmask(int how, const sigset_t * set, sigset_t * oldset)
{
- if (set &&
-# if (SIG_BLOCK == 0) && (SIG_UNBLOCK == 1) && (SIG_SETMASK == 2)
- (((unsigned int) how) > 2)
-#elif (SIG_BLOCK == 1) && (SIG_UNBLOCK == 2) && (SIG_SETMASK == 3)
- (((unsigned int)(how-1)) > 2)
-# else
-# warning "compile time assumption violated.. slow path..."
- ((how != SIG_BLOCK) && (how != SIG_UNBLOCK)
- && (how != SIG_SETMASK))
+#ifdef SIGCANCEL
+ sigset_t local_newmask;
+
+ /*
+ * The only thing we have to make sure here is that SIGCANCEL and
+ * SIGSETXID are not blocked.
+ */
+ if (set != NULL && (unlikely (__sigismember (set, SIGCANCEL))
+# ifdef SIGSETXID
+ || unlikely (__sigismember (set, SIGSETXID))
+# endif
+ ))
+ {
+ local_newmask = *set;
+ __sigdelset (&local_newmask, SIGCANCEL);
+# ifdef SIGSETXID
+ __sigdelset (&local_newmask, SIGSETXID);
# endif
- ) {
- __set_errno(EINVAL);
- return -1;
+ set = &local_newmask;
}
+#endif
+
return (__syscall_sigprocmask(how, set, oldset));
}
#endif
diff --git a/libc/sysdeps/linux/common/sigqueue.c b/libc/sysdeps/linux/common/sigqueue.c
index 2bff597c1..ed57550f0 100644
--- a/libc/sysdeps/linux/common/sigqueue.c
+++ b/libc/sysdeps/linux/common/sigqueue.c
@@ -12,44 +12,35 @@
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 <errno.h>
-#include <signal.h>
-#include <unistd.h>
-#include <string.h>
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <sys/syscall.h>
-#if defined __USE_POSIX199309
-
-libc_hidden_proto(getpid)
-libc_hidden_proto(getuid)
-/* Experimentally off - libc_hidden_proto(memset) */
-#ifdef __NR_rt_sigqueueinfo
+#if defined __NR_rt_sigqueueinfo && defined __USE_POSIX199309
+# include <signal.h>
+# include <unistd.h>
+# include <string.h>
-# define __NR___libc_rt_sigqueueinfo __NR_rt_sigqueueinfo
-static __inline__ _syscall3(int, __libc_rt_sigqueueinfo, pid_t, pid, int, sig, void*, value);
+# define __NR___syscall_rt_sigqueueinfo __NR_rt_sigqueueinfo
+static __always_inline _syscall3(int, __syscall_rt_sigqueueinfo, pid_t, pid, int, sig, void*, value)
/* Return any pending signal or wait for one for the given time. */
int sigqueue (pid_t pid, int sig, const union sigval val)
{
- siginfo_t info;
-
- /* First, clear the siginfo_t structure, so that we don't pass our
- stack content to other tasks. */
- memset (&info, 0, sizeof (siginfo_t));
- /* We must pass the information about the data in a siginfo_t value. */
- info.si_signo = sig;
- info.si_code = SI_QUEUE;
- info.si_pid = getpid ();
- info.si_uid = getuid ();
- info.si_value = val;
-
- return __libc_rt_sigqueueinfo(pid, sig, __ptrvalue (&info));
+ siginfo_t info;
+
+ /* First, clear the siginfo_t structure, so that we don't pass our
+ stack content to other tasks. */
+ memset(&info, 0, sizeof(info));
+ /* We must pass the information about the data in a siginfo_t value. */
+ info.si_signo = sig;
+ info.si_code = SI_QUEUE;
+ info.si_pid = getpid ();
+ info.si_uid = getuid ();
+ info.si_value = val;
+
+ return __syscall_rt_sigqueueinfo(pid, sig, &info);
}
#endif
-#endif
diff --git a/libc/sysdeps/linux/common/sigsuspend.c b/libc/sysdeps/linux/common/sigsuspend.c
index 8495e35b5..57a1a44a7 100644
--- a/libc/sysdeps/linux/common/sigsuspend.c
+++ b/libc/sysdeps/linux/common/sigsuspend.c
@@ -9,30 +9,18 @@
#include <sys/syscall.h>
-#if defined __USE_POSIX
+#ifdef __USE_POSIX
#include <signal.h>
+#include <cancel.h>
-extern __typeof(sigsuspend) __libc_sigsuspend;
-
-#ifdef __NR_rt_sigsuspend
-# define __NR___rt_sigsuspend __NR_rt_sigsuspend
-static __inline__ _syscall2(int, __rt_sigsuspend, const sigset_t *, mask, size_t, size);
-
-int __libc_sigsuspend(const sigset_t * mask)
+int __NC(sigsuspend)(const sigset_t *set)
{
- return __rt_sigsuspend(mask, _NSIG / 8);
-}
+#ifdef __NR_rt_sigsuspend
+ return INLINE_SYSCALL(rt_sigsuspend, 2, set, __SYSCALL_SIGSET_T_SIZE);
#else
-# define __NR___syscall_sigsuspend __NR_sigsuspend
-static __inline__ _syscall3(int, __syscall_sigsuspend, int, a, unsigned long int, b,
- unsigned long int, c);
-
-int __libc_sigsuspend(const sigset_t * set)
-{
- return __syscall_sigsuspend(0, 0, set->__val[0]);
-}
+ return INLINE_SYSCALL(sigsuspend, 3, 0, 0, set->__val[0]);
#endif
-libc_hidden_proto(sigsuspend)
-weak_alias(__libc_sigsuspend,sigsuspend)
-libc_hidden_weak(sigsuspend)
+}
+CANCELLABLE_SYSCALL(int, sigsuspend, (const sigset_t *set), (set))
+lt_libc_hidden(sigsuspend)
#endif
diff --git a/libc/sysdeps/linux/common/splice.c b/libc/sysdeps/linux/common/splice.c
index 7e8f4e3e0..4a32c54a8 100644
--- a/libc/sysdeps/linux/common/splice.c
+++ b/libc/sysdeps/linux/common/splice.c
@@ -8,21 +8,10 @@
*/
#include <sys/syscall.h>
-#include <fcntl.h>
-libc_hidden_proto(splice)
+#if defined __NR_splice && defined __UCLIBC_HAS_LFS__ && defined __USE_GNU
+# include <fcntl.h>
-#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;
-}
+_syscall6(ssize_t, splice, int, __fdin, off64_t *, __offin, int, __fdout,
+ off64_t *, __offout, size_t, __len, unsigned int, __flags)
#endif
-
-libc_hidden_def(splice)
-
diff --git a/libc/sysdeps/linux/common/ssp-local.c b/libc/sysdeps/linux/common/ssp-local.c
index 202d956a5..c0fafcfcf 100644
--- a/libc/sysdeps/linux/common/ssp-local.c
+++ b/libc/sysdeps/linux/common/ssp-local.c
@@ -12,18 +12,19 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/*
* Peter S. Mazinger ps.m[@]gmx.net
* copied stack_chk_fail_local.c from glibc and adapted for uClibc
*/
-#include <features.h>
+#if defined __SSP__ || defined __SSP_ALL__
+# error "file must not be compiled with stack protection enabled on it. Use -fno-stack-protector"
+#endif
-extern void __stack_chk_fail (void) attribute_noreturn;
+#include <features.h>
/* On some architectures, this helps needless PIC pointer setup
that would be needed just for the __stack_chk_fail call. */
@@ -31,5 +32,5 @@ extern void __stack_chk_fail (void) attribute_noreturn;
void __stack_chk_fail_local (void) attribute_noreturn attribute_hidden;
void __stack_chk_fail_local (void)
{
- __stack_chk_fail ();
+ __stack_chk_fail ();
}
diff --git a/libc/sysdeps/linux/common/ssp.c b/libc/sysdeps/linux/common/ssp.c
index d8088ef60..8dcc3dc59 100644
--- a/libc/sysdeps/linux/common/ssp.c
+++ b/libc/sysdeps/linux/common/ssp.c
@@ -20,108 +20,113 @@
#error "file must not be compiled with stack protection enabled on it. Use -fno-stack-protector"
#endif
-#ifdef __PROPOLICE_BLOCK_SEGV__
-# define SSP_SIGTYPE SIGSEGV
-#else
-# define SSP_SIGTYPE SIGABRT
-#endif
-
#include <string.h>
#include <unistd.h>
#include <signal.h>
+#ifdef __UCLIBC_HAS_SYSLOG__
#include <sys/syslog.h>
+#endif
-/* Experimentally off - libc_hidden_proto(memset) */
-/* Experimentally off - libc_hidden_proto(strlen) */
-libc_hidden_proto(sigaction)
-libc_hidden_proto(sigfillset)
-libc_hidden_proto(sigdelset)
-libc_hidden_proto(sigprocmask)
-libc_hidden_proto(write)
-libc_hidden_proto(openlog)
-libc_hidden_proto(syslog)
-libc_hidden_proto(closelog)
-libc_hidden_proto(kill)
-libc_hidden_proto(getpid)
-libc_hidden_proto(_exit)
+#ifdef __PROPOLICE_BLOCK_SEGV__
+# define SSP_SIGTYPE SIGSEGV
+#else
+# define SSP_SIGTYPE SIGABRT
+#endif
-static void block_signals(void)
+static void do_write(const char *msg)
{
- struct sigaction sa;
- sigset_t mask;
-
- sigfillset(&mask);
-
- sigdelset(&mask, SSP_SIGTYPE); /* Block all signal handlers */
- sigprocmask(SIG_BLOCK, &mask, NULL); /* except SSP_SIGTYPE */
-
- /* Make the default handler associated with the signal handler */
- memset(&sa, 0, sizeof(struct sigaction));
- sigfillset(&sa.sa_mask); /* Block all signals */
- sa.sa_flags = 0;
- sa.sa_handler = SIG_DFL;
- sigaction(SSP_SIGTYPE, &sa, NULL);
+ /* could use inlined syscall here to be sure ... */
+ return (void) write(STDERR_FILENO, msg, strlen(msg));
}
-static void ssp_write(int fd, const char *msg1, const char *msg2, const char *msg3)
+static void __cold do_msg(const char *msg1, const char *msg2, const char *msg3)
{
- write(fd, msg1, strlen(msg1));
- write(fd, msg2, strlen(msg2));
- write(fd, msg3, strlen(msg3));
- write(fd, "()\n", 3);
- openlog("ssp", LOG_CONS | LOG_PID, LOG_USER);
+ do_write(msg1);
+ do_write(msg2);
+ do_write(msg3);
+ do_write("\n");
+#ifdef __UCLIBC_HAS_SYSLOG__
syslog(LOG_INFO, "%s%s%s()", msg1, msg2, msg3);
- closelog();
+#endif
}
-static attribute_noreturn void terminate(void)
+static void __cold attribute_noreturn
+#ifdef __UCLIBC_HAS_SSP_COMPAT__
+ssp_handler(char func[])
+#else
+ssp_handler(void)
+#endif
{
- (void) kill(getpid(), SSP_SIGTYPE);
- _exit(127);
-}
+ pid_t pid;
+ static const char msg_ssd[] = "*** stack smashing detected ***: ";
+ static const char msg_terminated[] = " terminated";
+#ifdef __UCLIBC_HAS_SSP_COMPAT__
+ static const char msg_ssa[] = ": stack smashing attack in function ";
+#endif
-void __stack_smash_handler(char func[], int damaged __attribute__ ((unused))) attribute_noreturn;
-void __stack_smash_handler(char func[], int damaged)
-{
- static const char message[] = ": stack smashing attack in function ";
+#ifdef __DODEBUG__
+ struct sigaction sa;
+ sigset_t mask;
- block_signals();
+ __sigfillset(&mask);
+ __sigdelset(&mask, SSP_SIGTYPE); /* Block all signal handlers */
+ sigprocmask(SIG_BLOCK, &mask, NULL); /* except SSP_SIGTYPE */
+#endif
- ssp_write(STDERR_FILENO, __uclibc_progname, message, func);
+#ifdef __UCLIBC_HAS_SSP_COMPAT__
+ if (func != NULL)
+ do_msg(__uclibc_progname, msg_ssa, func);
+ else
+#endif
+ do_msg(msg_ssd, __uclibc_progname, msg_terminated);
+ pid = getpid();
+#ifdef __DODEBUG__
+ /* Make the default handler associated with the signal handler */
+ memset(&sa, 0, sizeof(sa));
+ __sigfillset(&sa.sa_mask); /* Block all signals */
+ if (SIG_DFL) /* if it's constant zero, it's already done */
+ sa.sa_handler = SIG_DFL;
+ if (sigaction(SSP_SIGTYPE, &sa, NULL) == 0)
+ (void)kill(pid, SSP_SIGTYPE);
+#endif
+ (void)kill(pid, SIGKILL);
/* The loop is added only to keep gcc happy. */
while(1)
- terminate();
+ _exit(127);
}
-void __stack_chk_fail(void) attribute_noreturn;
-void __stack_chk_fail(void)
+#ifdef __UCLIBC_HAS_SSP_COMPAT__
+void __stack_smash_handler(char func[], int damaged) attribute_noreturn __cold;
+void __stack_smash_handler(char func[], int damaged attribute_unused)
{
- static const char msg1[] = "stack smashing detected: ";
- static const char msg3[] = " terminated";
-
- block_signals();
-
- ssp_write(STDERR_FILENO, msg1, __uclibc_progname, msg3);
+ ssp_handler(func);
+}
- /* The loop is added only to keep gcc happy. */
- while(1)
- terminate();
+void __stack_chk_fail(void)
+{
+ ssp_handler(NULL);
}
+#else
+strong_alias(ssp_handler,__stack_chk_fail)
+#endif
-#if 0
-void __chk_fail(void) attribute_noreturn;
+#ifdef __UCLIBC_HAS_FORTIFY__
+/* should be redone when activated to use common code above.
+ * for now, it works without debugging support */
void __chk_fail(void)
{
- static const char msg1[] = "buffer overflow detected: ";
- static const char msg3[] = " terminated";
-
- block_signals();
+ static const char msg_fail[] = "*** buffer overflow detected ***: ";
+ static const char msg_terminated[] = " terminated";
+ pid_t pid;
- ssp_write(STDERR_FILENO, msg1, __uclibc_progname, msg3);
+ do_msg(msg_fail, __uclibc_progname, msg_terminated);
+ pid = getpid();
+ (void)kill(pid, SIGKILL);
/* The loop is added only to keep gcc happy. */
while(1)
- terminate();
+ _exit(127);
}
+libc_hidden_def(__chk_fail)
#endif
diff --git a/libc/sysdeps/linux/common/stat.c b/libc/sysdeps/linux/common/stat.c
index 78211334e..c7e213838 100644
--- a/libc/sysdeps/linux/common/stat.c
+++ b/libc/sysdeps/linux/common/stat.c
@@ -7,40 +7,52 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-/* need to hide the 64bit prototype or the strong_alias()
- * will fail when __NR_stat64 doesnt exist */
-#define stat64 __hidestat64
-
#include <sys/syscall.h>
#include <unistd.h>
#include <sys/stat.h>
-#include "xstatconv.h"
-#undef stat64
+#undef stat
-libc_hidden_proto(stat)
+#if defined __NR_fstatat64 && !defined __NR_stat
+# include <fcntl.h>
-#define __NR___syscall_stat __NR_stat
-#undef stat
-static __inline__ _syscall2(int, __syscall_stat,
- const char *, file_name, struct kernel_stat *, buf);
+int stat(const char *file_name, struct stat *buf)
+{
+ return fstatat(AT_FDCWD, file_name, buf, 0);
+}
+
+#else
+# include "xstatconv.h"
int stat(const char *file_name, struct stat *buf)
{
int result;
+# ifdef __NR_stat64
+ /* normal stat call has limited values for various stat elements
+ * e.g. uid device major/minor etc.
+ * so we use 64 variant if available
+ * in order to get newer versions of stat elements
+ */
+ struct kernel_stat64 kbuf;
+ result = INLINE_SYSCALL(stat64, 2, file_name, &kbuf);
+ if (result == 0) {
+ __xstat32_conv(&kbuf, buf);
+ }
+# else
struct kernel_stat kbuf;
- result = __syscall_stat(file_name, &kbuf);
+ result = INLINE_SYSCALL(stat, 2, file_name, &kbuf);
if (result == 0) {
__xstat_conv(&kbuf, buf);
}
+# endif /* __NR_stat64 */
return result;
}
+#endif /* __NR_fstat64 */
libc_hidden_def(stat)
-#if ! defined __NR_stat64 && defined __UCLIBC_HAS_LFS__
-extern __typeof(stat) stat64;
-libc_hidden_proto(stat64)
-strong_alias(stat,stat64)
+#if ! defined __NR_stat64 && ! defined __NR_fstatat64 && \
+ defined __UCLIBC_HAS_LFS__
+strong_alias_untyped(stat,stat64)
libc_hidden_def(stat64)
#endif
diff --git a/libc/sysdeps/linux/common/stat64.c b/libc/sysdeps/linux/common/stat64.c
index ee4260d03..cb3a0e169 100644
--- a/libc/sysdeps/linux/common/stat64.c
+++ b/libc/sysdeps/linux/common/stat64.c
@@ -7,18 +7,28 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+#include <_lfs_64.h>
#include <sys/syscall.h>
#include <sys/stat.h>
-#if defined __UCLIBC_HAS_LFS__ && defined __NR_stat64
-libc_hidden_proto(stat64)
+#if defined __UCLIBC_HAS_LFS__
-# define __NR___syscall_stat64 __NR_stat64
+# if defined __NR_fstatat64 && !defined __NR_stat64
+# include <fcntl.h>
# include <unistd.h>
-# include "xstatconv.h"
-static __inline__ _syscall2(int, __syscall_stat64,
- const char *, file_name, struct kernel_stat64 *, buf);
+int stat64(const char *file_name, struct stat64 *buf)
+{
+ return fstatat64(AT_FDCWD, file_name, buf, 0);
+}
+libc_hidden_def(stat64)
+
+/* For systems which have both, prefer the old one */
+# elif defined __NR_stat64
+# define __NR___syscall_stat64 __NR_stat64
+# include "xstatconv.h"
+static __always_inline _syscall2(int, __syscall_stat64,
+ const char *, file_name, struct kernel_stat64 *, buf)
int stat64(const char *file_name, struct stat64 *buf)
{
@@ -32,4 +42,6 @@ int stat64(const char *file_name, struct stat64 *buf)
return result;
}
libc_hidden_def(stat64)
-#endif
+# endif
+
+#endif /* __UCLIBC_HAS_LFS__ */
diff --git a/libc/sysdeps/linux/common/statfs.c b/libc/sysdeps/linux/common/statfs.c
index 38c277fad..3dfeb0b2c 100644
--- a/libc/sysdeps/linux/common/statfs.c
+++ b/libc/sysdeps/linux/common/statfs.c
@@ -12,14 +12,41 @@
#include <sys/param.h>
#include <sys/vfs.h>
-extern __typeof(statfs) __libc_statfs;
-libc_hidden_proto(__libc_statfs)
-#define __NR___libc_statfs __NR_statfs
-_syscall2(int, __libc_statfs, const char *, path, struct statfs *, buf);
-libc_hidden_def(__libc_statfs)
-
-#if defined __UCLIBC_LINUX_SPECIFIC__
-libc_hidden_proto(statfs)
-weak_alias(__libc_statfs,statfs)
-libc_hidden_weak(statfs)
+extern __typeof(statfs) __libc_statfs attribute_hidden;
+
+#if defined __NR_statfs64 && !defined __NR_statfs
+
+int __libc_statfs(const char *path, struct statfs *buf)
+{
+ int err = INLINE_SYSCALL(statfs64, 3, path, sizeof(*buf), buf);
+
+ if (err == 0) {
+ /* Did we overflow? */
+ if (buf->__pad1 || buf->__pad2 || buf->__pad3 ||
+ buf->__pad4 || buf->__pad5) {
+ __set_errno(EOVERFLOW);
+ return -1;
+ }
+ }
+
+ return err;
+}
+# if defined __UCLIBC_LINUX_SPECIFIC__ || defined __UCLIBC_HAS_THREADS_NATIVE__
+/* statfs is used by NPTL, so it must exported in case */
+weak_alias(__libc_statfs, statfs)
+libc_hidden_def(statfs)
+# endif
+
+/* For systems which have both, prefer the old one */
+#else
+
+# define __NR___libc_statfs __NR_statfs
+_syscall2(int, __libc_statfs, const char *, path, struct statfs *, buf)
+
+# if defined __UCLIBC_LINUX_SPECIFIC__ || defined __UCLIBC_HAS_THREADS_NATIVE__
+/* statfs is used by NPTL, so it must exported in case */
+weak_alias(__libc_statfs, statfs)
+libc_hidden_def(statfs)
+# endif
+
#endif
diff --git a/libc/sysdeps/linux/common/stime.c b/libc/sysdeps/linux/common/stime.c
index af8595533..b30884dd7 100644
--- a/libc/sysdeps/linux/common/stime.c
+++ b/libc/sysdeps/linux/common/stime.c
@@ -8,16 +8,17 @@
*/
#include <sys/syscall.h>
-#include <time.h>
-#include <sys/time.h>
#ifdef __USE_SVID
-#ifdef __NR_stime
-_syscall1(int, stime, const time_t *, t);
-#else
-libc_hidden_proto(settimeofday)
-
-int stime(const time_t * when)
+# include <time.h>
+# ifdef __NR_stime
+_syscall1(int, stime, const time_t *, t)
+# elif defined __USE_BSD && defined __NR_settimeofday
+# define __need_NULL
+# include <stddef.h>
+# include <errno.h>
+# include <sys/time.h>
+int stime(const time_t *when)
{
struct timeval tv;
@@ -29,5 +30,8 @@ int stime(const time_t * when)
tv.tv_usec = 0;
return settimeofday(&tv, (struct timezone *) 0);
}
-#endif
+# endif
+# if defined __NR_stime || (defined __USE_BSD && defined __NR_settimeofday)
+libc_hidden_def(stime)
+# endif
#endif
diff --git a/libc/sysdeps/linux/common/stubs.c b/libc/sysdeps/linux/common/stubs.c
new file mode 100644
index 000000000..19a33714a
--- /dev/null
+++ b/libc/sysdeps/linux/common/stubs.c
@@ -0,0 +1,490 @@
+/*
+ * 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.
+ */
+
+/* Please keep the list sorted alphabetically, in ascending order
+ * of the stub name! */
+
+#include <errno.h>
+#include <bits/wordsize.h>
+#include <sys/syscall.h>
+
+#ifdef __UCLIBC_HAS_STUBS__
+
+__attribute_used__ static int enosys_stub(void)
+{
+ __set_errno(ENOSYS);
+ return -1;
+}
+
+__attribute_used__ static int ret_enosys_stub(void)
+{
+ return ENOSYS;
+}
+
+#define make_stub(stub) \
+ link_warning(stub, #stub ": this function is not implemented") \
+ strong_alias(enosys_stub, stub)
+
+#define make_ret_stub(stub) \
+ link_warning(stub, #stub ": this function is not implemented") \
+ strong_alias(ret_enosys_stub, stub)
+
+#ifndef __ARCH_USE_MMU__
+# undef __NR_fork
+#endif
+
+#ifdef __arm__
+# define __NR_fadvise64_64 __NR_arm_fadvise64_64
+# define __NR_fadvise64 __NR_arm_fadvise64_64
+/* ARM always provides funcs w/out syscalls; disable the stubs */
+# define __NR_ioperm 0
+# define __NR_iopl 0
+#endif
+
+#ifdef __mips__
+# define __NR_fadvise64_64 __NR_fadvise64
+#endif
+
+#ifdef __xtensa__
+# define __NR_fadvise64 __NR_fadvise64_64
+#endif
+
+#if !defined __NR_accept && !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__
+make_stub(accept)
+#endif
+
+#if !defined __NR_accept4 && !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__ && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(accept4)
+#endif
+
+#if !defined __NR_arch_prctl && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(arch_prctl)
+#endif
+
+#if !defined __NR_bdflush && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(bdflush)
+#endif
+
+#if !defined __NR_bind && !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__
+make_stub(bind)
+#endif
+
+#if !defined __NR_capget && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(capget)
+#endif
+
+#if !defined __NR_capset && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(capset)
+#endif
+
+#if !defined __NR_connect && !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__
+make_stub(connect)
+#endif
+
+#if !defined __NR_create_module && defined __UCLIBC_LINUX_MODULE_24__
+make_stub(create_module)
+#endif
+
+#if !defined __NR_delete_module && defined __UCLIBC_LINUX_MODULE_26__
+make_stub(delete_module)
+#endif
+
+#if !defined __NR_epoll_create && defined __UCLIBC_HAS_EPOLL__ \
+ && !defined __NR_epoll_create1
+make_stub(epoll_create)
+#endif
+
+#if !defined __NR_epoll_ctl && defined __UCLIBC_HAS_EPOLL__
+make_stub(epoll_ctl)
+#endif
+
+#if !defined __NR_epoll_pwait && defined __UCLIBC_HAS_EPOLL__
+make_stub(epoll_pwait)
+#endif
+
+#if !defined __NR_epoll_wait && defined __UCLIBC_HAS_EPOLL__ \
+ && !defined __NR_epoll_pwait
+make_stub(epoll_wait)
+#endif
+
+#if !defined __NR_eventfd && !defined __NR_eventfd2 && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(eventfd)
+#endif
+
+#if !defined __NR_fdatasync && !defined __NR_osf_fdatasync
+make_stub(fdatasync)
+#endif
+
+#ifndef __NR_fgetxattr
+make_stub(fgetxattr)
+#endif
+
+#ifndef __NR_flistxattr
+make_stub(flistxattr)
+#endif
+
+#if !defined __NR_fork && !defined __NR_clone
+make_stub(fork)
+#endif
+
+#ifndef __NR_fremovexattr
+make_stub(fremovexattr)
+#endif
+
+#ifndef __NR_fsetxattr
+make_stub(fsetxattr)
+#endif
+
+#if !defined __NR_fstatfs && !defined __NR_fstatfs64 \
+ && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(fstatfs)
+#endif
+
+#ifndef __NR_get_kernel_syms
+make_stub(get_kernel_syms)
+#endif
+
+#if !defined __NR_getpeername && !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__
+make_stub(getpeername)
+#endif
+
+#if !defined __NR_getpgrp && !defined __NR_getpgid
+make_stub(getpgrp)
+#endif
+
+#if !defined __NR_getrandom && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(getrandom)
+#endif
+
+#if !defined __NR_getsockname && !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__
+make_stub(getsockname)
+#endif
+
+#if !defined __NR_getsockopt && !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__
+make_stub(getsockopt)
+#endif
+
+#ifndef __NR_getxattr
+make_stub(getxattr)
+#endif
+
+#if !defined __NR_init_module && defined __UCLIBC_LINUX_MODULE_26__
+make_stub(init_module)
+#endif
+
+#if !defined __NR_inotify_add_watch && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(inotify_add_watch)
+#endif
+
+#if !defined __NR_inotify_init && defined __UCLIBC_LINUX_SPECIFIC__ \
+ && !defined __NR_inotify_init1
+make_stub(inotify_init)
+#endif
+
+#if !defined __NR_inotify_init1 && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(inotify_init1)
+#endif
+
+#if !defined __NR_inotify_rm_watch && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(inotify_rm_watch)
+#endif
+
+#if !defined __NR_ioperm && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(ioperm)
+#endif
+
+#if !defined __NR_iopl && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(iopl)
+#endif
+
+#ifndef __NR_lgetxattr
+make_stub(lgetxattr)
+#endif
+
+#if !defined __NR_listen && !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__
+make_stub(listen)
+#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
+
+#if !defined __NR_madvise && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(madvise)
+#endif
+
+#if !defined __NR_modify_ldt && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(modify_ldt)
+#endif
+
+#ifndef __NR_openat
+make_stub(openat)
+# ifdef __UCLIBC_HAS_LFS__
+make_stub(openat64)
+# endif
+#endif
+
+#if !defined __NR_personality && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(personality)
+#endif
+
+#if !defined __NR_pipe2 && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(pipe2)
+#endif
+
+#if !defined __NR_pivot_root && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(pivot_root)
+#endif
+
+#if !defined __NR_fadvise64 && defined __UCLIBC_HAS_LFS__
+make_ret_stub(posix_fadvise)
+#endif
+
+#if !defined __NR_fadvise64_64 && defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 32
+make_ret_stub(posix_fadvise64)
+#endif
+
+#ifndef __NR_madvise
+make_ret_stub(posix_madvise)
+#endif
+
+#if !defined __NR_ppoll && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(ppoll)
+#endif
+
+#if !defined __NR_prctl && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(prctl)
+#endif
+
+#if !defined __NR_query_module && defined __UCLIBC_LINUX_MODULE_24__
+make_stub(query_module)
+#endif
+
+#if !defined __NR_readahead && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(readahead)
+#endif
+
+#if !defined __NR_reboot && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(reboot)
+#endif
+
+#if !defined __NR_recv && !defined __NR_socketcall && !defined __NR_recvfrom && defined __UCLIBC_HAS_SOCKET__
+make_stub(recv)
+#endif
+
+#if !defined __NR_recvfrom && !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__
+make_stub(recvfrom)
+#endif
+
+#if !defined __NR_recvmsg && !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__
+make_stub(recvmsg)
+#endif
+
+#if !defined __NR_remap_file_pages && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(remap_file_pages)
+#endif
+
+#ifndef __NR_removexattr
+make_stub(removexattr)
+#endif
+
+#ifndef __NR_renameat
+make_stub(renameat)
+#endif
+
+#if !defined __NR_sched_getaffinity && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(sched_getaffinity)
+#endif
+
+#if !defined __NR_getcpu && defined __UCLIBC_LINUX_SPECIFIC__ && ((defined __x86_64__ && !defined __UCLIBC_HAS_TLS__) || !defined __x86_64__)
+make_stub(sched_getcpu)
+#endif
+
+#if !defined __NR_sched_setaffinity && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(sched_setaffinity)
+#endif
+
+#if !defined __NR_send && !defined __NR_socketcall && !defined __NR_sendto && defined __UCLIBC_HAS_SOCKET__
+make_stub(send)
+#endif
+
+#if !defined __NR_sendfile && !defined __NR_sendfile64 \
+ && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(sendfile)
+#endif
+
+#if !defined __NR_sendfile64 && !defined __NR_sendfile && defined __UCLIBC_LINUX_SPECIFIC__ && defined __UCLIBC_HAS_LFS__
+make_stub(sendfile64)
+#endif
+
+#if !defined __NR_sendmsg && !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__
+make_stub(sendmsg)
+#endif
+
+#if !defined __NR_sendto && !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__
+make_stub(sendto)
+#endif
+
+#if ((__WORDSIZE == 32 && (!defined __NR_setfsgid32 && !defined __NR_setfsgid)) || (__WORDSIZE == 64 && !defined __NR_setfsgid)) && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(setfsgid)
+#endif
+
+#if ((__WORDSIZE == 32 && (!defined __NR_setfsuid32 && !defined __NR_setfsuid)) || (__WORDSIZE == 64 && !defined __NR_setfsuid)) && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(setfsuid)
+#endif
+
+#if !defined __NR_setns && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(setns)
+#endif
+
+#if !defined __NR_setresgid32 && !defined __NR_setresgid && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(setresgid)
+#endif
+
+#if !defined __NR_setresuid32 && !defined __NR_setresuid && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(setresuid)
+#endif
+
+#if !defined __NR_setsockopt && !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__
+make_stub(setsockopt)
+#endif
+
+#ifndef __NR_setxattr
+make_stub(setxattr)
+#endif
+
+#if !defined __NR_shutdown && !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__
+make_stub(shutdown)
+#endif
+
+#if !defined __NR_signalfd4 && !defined __NR_signalfd && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(signalfd)
+#endif
+
+#ifndef __NR_rt_sigtimedwait
+make_stub(sigtimedwait)
+make_stub(sigwaitinfo)
+#endif
+
+#ifndef __NR_rt_sigqueueinfo
+make_stub(sigqueue)
+#endif
+
+#if !defined __NR_socket && !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__
+make_stub(socket)
+#endif
+
+#if !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__
+make_stub(socketcall)
+#endif
+
+#if !defined __NR_socketpair && !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__
+make_stub(socketpair)
+#endif
+
+#if !defined __NR_stime && !defined __NR_settimeofday
+make_stub(stime)
+make_stub(settimeofday)
+#endif
+
+#if !defined __NR_splice && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(splice)
+#endif
+
+#if !defined __NR_swapoff && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(swapoff)
+#endif
+
+#if !defined __NR_swapon && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(swapon)
+#endif
+
+#if !defined __NR_symlink && !defined __NR_symlinkat
+make_stub(symlink)
+#endif
+
+#if !defined __NR_sync_file_range && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(sync_file_range)
+#endif
+
+#if !defined __NR__sysctl && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(_sysctl)
+#endif
+
+#if !defined __NR_sysinfo && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(sysinfo)
+#endif
+
+#if !defined __NR_tee && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(tee)
+#endif
+
+#if !defined __NR_timerfd_create && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(timerfd_create)
+#endif
+
+#if !defined __NR_timerfd_settime && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(timerfd_settime)
+#endif
+
+#if !defined __NR_timerfd_gettime && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(timerfd_gettime)
+#endif
+
+#ifndef __NR_utimensat
+make_stub(futimens)
+make_stub(utimensat)
+# ifndef __NR_lutimes
+make_stub(lutimes)
+# endif
+#endif
+
+#ifndef __NR_utimensat
+#if !defined __NR_utime && !defined __NR_utimes
+/*make_stub(utime) obsoleted */
+make_stub(utimes)
+#endif
+#endif
+
+#if !defined __NR_umount && !defined __NR_umount2 && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(umount)
+#endif
+
+#if !defined __NR_umount2 && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(umount2)
+#endif
+
+#if !defined __NR_unshare && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(unshare)
+#endif
+
+#if defined __UCLIBC_SV4_DEPRECATED__ && !defined __NR_ustat
+make_stub(ustat)
+#endif
+
+#if !defined __NR_vhangup && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(vhangup)
+#endif
+
+#if !defined __NR_vmsplice && defined __UCLIBC_LINUX_SPECIFIC__
+make_stub(vmsplice)
+#endif
+
+#endif
diff --git a/libc/sysdeps/linux/common/swapoff.c b/libc/sysdeps/linux/common/swapoff.c
index a0de283ed..db0b9befc 100644
--- a/libc/sysdeps/linux/common/swapoff.c
+++ b/libc/sysdeps/linux/common/swapoff.c
@@ -12,6 +12,6 @@
#ifdef __NR_swapoff
#include <sys/swap.h>
-_syscall1(int, swapoff, const char *, path);
+_syscall1(int, swapoff, const char *, path)
#endif
diff --git a/libc/sysdeps/linux/common/swapon.c b/libc/sysdeps/linux/common/swapon.c
index e9ffb6347..5d6b6e2de 100644
--- a/libc/sysdeps/linux/common/swapon.c
+++ b/libc/sysdeps/linux/common/swapon.c
@@ -12,6 +12,6 @@
#ifdef __NR_swapon
#include <sys/swap.h>
-_syscall2(int, swapon, const char *, path, int, swapflags);
+_syscall2(int, swapon, const char *, path, int, swapflags)
#endif
diff --git a/libc/sysdeps/linux/common/symlink.c b/libc/sysdeps/linux/common/symlink.c
index 97f34eb8f..eee6e8fa0 100644
--- a/libc/sysdeps/linux/common/symlink.c
+++ b/libc/sysdeps/linux/common/symlink.c
@@ -9,6 +9,19 @@
#include <sys/syscall.h>
#if defined __USE_BSD || defined __USE_UNIX98 || defined __USE_XOPEN2K
-#include <unistd.h>
-_syscall2(int, symlink, const char *, oldpath, const char *, newpath);
+# include <unistd.h>
+
+# if defined __NR_symlinkat && !defined __NR_symlink
+# include <fcntl.h>
+int symlink(const char *oldpath, const char *newpath)
+{
+ return symlinkat(oldpath, AT_FDCWD, newpath);
+}
+
+# elif defined(__NR_symlink)
+
+_syscall2(int, symlink, const char *, oldpath, const char *, newpath)
+
+# endif
+
#endif
diff --git a/libc/sysdeps/linux/common/symlinkat.c b/libc/sysdeps/linux/common/symlinkat.c
new file mode 100644
index 000000000..91815810c
--- /dev/null
+++ b/libc/sysdeps/linux/common/symlinkat.c
@@ -0,0 +1,17 @@
+/*
+ * symlinkat() for uClibc
+ *
+ * Copyright (C) 2009 Analog Devices Inc.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <unistd.h>
+
+#ifdef __NR_symlinkat
+_syscall3(int, symlinkat, const char *, from, int, tofd, const char *, to)
+libc_hidden_def(symlinkat)
+#else
+/* should add emulation with symlink() and /proc/self/fd/ ... */
+#endif
diff --git a/libc/sysdeps/linux/common/sync.c b/libc/sysdeps/linux/common/sync.c
index d2f81229c..d7ac44967 100644
--- a/libc/sysdeps/linux/common/sync.c
+++ b/libc/sysdeps/linux/common/sync.c
@@ -8,18 +8,8 @@
*/
#include <sys/syscall.h>
-# if defined __USE_BSD || defined __USE_UNIX98
-#include <sys/types.h>
-#include <unistd.h>
-#ifndef INLINE_SYSCALL
-#define INLINE_SYSCALL(name, nr, args...) __syscall_sync (args)
-#define __NR___syscall_sync __NR_sync
-static __inline__ _syscall0(void, __syscall_sync);
-#endif
-
-void sync(void)
-{
- INLINE_SYSCALL(sync, 0);
-}
+#if defined __USE_BSD || defined __USE_UNIX98
+# include <unistd.h>
+_syscall0(void, sync)
#endif
diff --git a/libc/sysdeps/linux/common/sync_file_range.c b/libc/sysdeps/linux/common/sync_file_range.c
index 53f7ae6a1..52bc9d7af 100644
--- a/libc/sysdeps/linux/common/sync_file_range.c
+++ b/libc/sysdeps/linux/common/sync_file_range.c
@@ -4,30 +4,44 @@
*
* Copyright (C) 2008 Bernhard Reutner-Fischer <uclibc@uclibc.org>
*
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
*/
#include <sys/syscall.h>
-#if defined __USE_GNU
-#include <fcntl.h>
+#if defined __UCLIBC_HAS_LFS__ && defined __USE_GNU
+# include <bits/wordsize.h>
+# include <endian.h>
+# include <fcntl.h>
+# include <cancel.h>
-#if defined __NR_sync_file_range && defined __UCLIBC_HAS_LFS__
-#define __NR___syscall_sync_file_range __NR_sync_file_range
-static __inline__ _syscall6(int, __syscall_sync_file_range, int, fd,
- off_t, offset_hi, off_t, offset_lo,
- off_t, nbytes_hi, off_t, nbytes_lo, unsigned int, flags);
-int sync_file_range(int fd, off64_t offset, off64_t nbytes, unsigned int flags)
-{
- return __syscall_sync_file_range(fd,
- __LONG_LONG_PAIR((long)(offset >> 32), (long)(offset & 0xffffffff)),
- __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)
+# ifdef __NR_sync_file_range2
+# undef __NR_sync_file_range
+# define __NR_sync_file_range __NR_sync_file_range2
+# endif
+
+# ifdef __NR_sync_file_range
+static int __NC(sync_file_range)(int fd, off64_t offset, off64_t nbytes, unsigned int flags)
{
- __set_errno(ENOSYS);
- return -1;
+# if defined __powerpc__ && __WORDSIZE == 64
+ return INLINE_SYSCALL(sync_file_range, 4, fd, flags, offset, nbytes);
+# elif defined __arm__ && defined __thumb__
+ return INLINE_SYSCALL(sync_file_range, 6, fd,
+ OFF64_HI_LO(offset), OFF64_HI_LO(nbytes), flags);
+# elif (defined __mips__ && _MIPS_SIM == _ABIO32) || \
+ (defined(__UCLIBC_SYSCALL_ALIGN_64BIT__) && !(defined(__powerpc__) || defined(__xtensa__)))
+ /* arch with 64-bit data in even reg alignment #2: [arcv2/others-in-future]
+ * stock syscall handler in kernel (reg hole punched)
+ * see libc/sysdeps/linux/common/posix_fadvise.c for more details */
+ return INLINE_SYSCALL(sync_file_range, 7, fd, 0,
+ OFF64_HI_LO(offset), OFF64_HI_LO(nbytes), flags);
+# elif defined __NR_sync_file_range2
+ return INLINE_SYSCALL(sync_file_range, 6, fd, flags,
+ OFF64_HI_LO(offset), OFF64_HI_LO(nbytes));
+# else
+ return INLINE_SYSCALL(sync_file_range, 6, fd,
+ OFF64_HI_LO(offset), OFF64_HI_LO(nbytes), flags);
+# endif
}
-#endif
+CANCELLABLE_SYSCALL(int, sync_file_range, (int fd, off64_t offset, off64_t nbytes, unsigned int flags), (fd, offset, nbytes, flags))
+# endif
#endif
diff --git a/libc/sysdeps/linux/common/syncfs.c b/libc/sysdeps/linux/common/syncfs.c
new file mode 100644
index 000000000..831f76568
--- /dev/null
+++ b/libc/sysdeps/linux/common/syncfs.c
@@ -0,0 +1,13 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Copyright (C) 2015 Bartosz Golaszewski <bartekgola@gmail.com>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+
+#if defined(__NR_syncfs) && __USE_GNU
+#include <unistd.h>
+_syscall1(int, syncfs, int, fd)
+#endif
diff --git a/libc/sysdeps/linux/common/sys/acct.h b/libc/sysdeps/linux/common/sys/acct.h
index 9ee8564f7..a816786fc 100644
--- a/libc/sysdeps/linux/common/sys/acct.h
+++ b/libc/sysdeps/linux/common/sys/acct.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998, 1999, 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
@@ -12,15 +12,15 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_ACCT_H
#define _SYS_ACCT_H 1
#include <features.h>
+#include <endian.h>
#define __need_time_t
#include <time.h>
#include <sys/types.h>
@@ -38,25 +38,51 @@ __BEGIN_DECLS
typedef u_int16_t comp_t;
struct acct
- {
- char ac_flag; /* Accounting flags. */
- u_int16_t ac_uid; /* Accounting user ID. */
- u_int16_t ac_gid; /* Accounting group ID. */
- u_int16_t ac_tty; /* Controlling tty. */
- u_int32_t ac_btime; /* Beginning time. */
- comp_t ac_utime; /* Accounting user time. */
- comp_t ac_stime; /* Accounting system time. */
- comp_t ac_etime; /* Accounting elapsed time. */
- comp_t ac_mem; /* Accounting average memory usage. */
- comp_t ac_io; /* Accounting chars transferred. */
- comp_t ac_rw; /* Accounting blocks read or written. */
- comp_t ac_minflt; /* Accounting minor pagefaults. */
- comp_t ac_majflt; /* Accounting major pagefaults. */
- comp_t ac_swaps; /* Accounting number of swaps. */
- u_int32_t ac_exitcode; /* Accounting process exitcode. */
- char ac_comm[ACCT_COMM+1]; /* Accounting command name. */
- char ac_pad[10]; /* Accounting padding bytes. */
- };
+{
+ char ac_flag; /* Flags. */
+ u_int16_t ac_uid; /* Real user ID. */
+ u_int16_t ac_gid; /* Real group ID. */
+ u_int16_t ac_tty; /* Controlling terminal. */
+ u_int32_t ac_btime; /* Beginning time. */
+ comp_t ac_utime; /* User time. */
+ comp_t ac_stime; /* System time. */
+ comp_t ac_etime; /* Elapsed time. */
+ comp_t ac_mem; /* Average memory usage. */
+ comp_t ac_io; /* Chars transferred. */
+ comp_t ac_rw; /* Blocks read or written. */
+ comp_t ac_minflt; /* Minor pagefaults. */
+ comp_t ac_majflt; /* Major pagefaults. */
+ comp_t ac_swaps; /* Number of swaps. */
+ u_int32_t ac_exitcode; /* Process exitcode. */
+ char ac_comm[ACCT_COMM+1]; /* Command name. */
+ char ac_pad[10]; /* Padding bytes. */
+};
+
+#if 0
+struct acct_v3
+{
+ char ac_flag; /* Flags */
+ char ac_version; /* Always set to ACCT_VERSION */
+ u_int16_t ac_tty; /* Control Terminal */
+ u_int32_t ac_exitcode; /* Exitcode */
+ u_int32_t ac_uid; /* Real User ID */
+ u_int32_t ac_gid; /* Real Group ID */
+ u_int32_t ac_pid; /* Process ID */
+ u_int32_t ac_ppid; /* Parent Process ID */
+ u_int32_t ac_btime; /* Process Creation Time */
+ float ac_etime; /* Elapsed Time */
+ comp_t ac_utime; /* User Time */
+ comp_t ac_stime; /* System Time */
+ comp_t ac_mem; /* Average Memory Usage */
+ comp_t ac_io; /* Chars Transferred */
+ comp_t ac_rw; /* Blocks Read or Written */
+ comp_t ac_minflt; /* Minor Pagefaults */
+ comp_t ac_majflt; /* Major Pagefaults */
+ comp_t ac_swaps; /* Number of Swaps */
+ char ac_comm[ACCT_COMM]; /* Command Name */
+};
+#endif
+
enum
{
@@ -66,11 +92,17 @@ enum
AXSIG = 0x10 /* Killed by a signal. */
};
+#if __BYTE_ORDER == __BIG_ENDIAN
+# define ACCT_BYTEORDER 0x80 /* Accounting file is big endian. */
+#else
+# define ACCT_BYTEORDER 0x00 /* Accounting file is little endian. */
+#endif
+
#define AHZ 100
/* Switch process accounting on and off. */
-extern int acct (__const char *__filename) __THROW;
+extern int acct (const char *__filename) __THROW;
__END_DECLS
diff --git a/libc/sysdeps/linux/common/sys/epoll.h b/libc/sysdeps/linux/common/sys/epoll.h
index 68f173a04..5551bed0d 100644
--- a/libc/sysdeps/linux/common/sys/epoll.h
+++ b/libc/sysdeps/linux/common/sys/epoll.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2012 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
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_EPOLL_H
#define _SYS_EPOLL_H 1
@@ -22,6 +21,20 @@
#include <stdint.h>
#include <sys/types.h>
+/* Get __sigset_t. */
+#include <bits/sigset.h>
+
+#ifndef __sigset_t_defined
+# define __sigset_t_defined
+typedef __sigset_t sigset_t;
+#endif
+
+/* Get the platform-dependent flags. */
+#include <bits/epoll.h>
+
+#ifndef __EPOLL_PACKED
+# define __EPOLL_PACKED
+#endif
enum EPOLL_EVENTS
{
@@ -45,17 +58,19 @@ enum EPOLL_EVENTS
#define EPOLLERR EPOLLERR
EPOLLHUP = 0x010,
#define EPOLLHUP EPOLLHUP
- EPOLLONESHOT = (1 << 30),
+ EPOLLRDHUP = 0x2000,
+#define EPOLLRDHUP EPOLLRDHUP
+ EPOLLONESHOT = 1u << 30,
#define EPOLLONESHOT EPOLLONESHOT
- EPOLLET = (1 << 31)
+ EPOLLET = 1u << 31
#define EPOLLET EPOLLET
};
/* Valid opcodes ( "op" parameter ) to issue to epoll_ctl(). */
-#define EPOLL_CTL_ADD 1 /* Add a file decriptor to the interface. */
-#define EPOLL_CTL_DEL 2 /* Remove a file decriptor from the interface. */
-#define EPOLL_CTL_MOD 3 /* Change file decriptor epoll_event structure. */
+#define EPOLL_CTL_ADD 1 /* Add a file descriptor to the interface. */
+#define EPOLL_CTL_DEL 2 /* Remove a file descriptor from the interface. */
+#define EPOLL_CTL_MOD 3 /* Change file descriptor epoll_event structure. */
typedef union epoll_data
@@ -70,7 +85,7 @@ struct epoll_event
{
uint32_t events; /* Epoll events */
epoll_data_t data; /* User data variable */
-};
+} __EPOLL_PACKED;
__BEGIN_DECLS
@@ -81,6 +96,10 @@ __BEGIN_DECLS
returned by epoll_create() should be closed with close(). */
extern int epoll_create (int __size) __THROW;
+/* Same as epoll_create but with a FLAGS parameter. The unused SIZE
+ parameter has been dropped. */
+extern int epoll_create1 (int __flags) __THROW;
+
/* Manipulate an epoll instance "epfd". Returns 0 in case of success,
-1 in case of error ( the "errno" variable will contain the
@@ -105,6 +124,16 @@ extern int epoll_ctl (int __epfd, int __op, int __fd,
extern int epoll_wait (int __epfd, struct epoll_event *__events,
int __maxevents, int __timeout);
+
+/* Same as epoll_wait, but the thread's signal mask is temporarily
+ and atomically replaced with the one provided as parameter.
+
+ This function is a cancellation point and therefore not marked with
+ __THROW. */
+extern int epoll_pwait (int __epfd, struct epoll_event *__events,
+ int __maxevents, int __timeout,
+ const __sigset_t *__ss);
+
__END_DECLS
#endif /* sys/epoll.h */
diff --git a/libc/sysdeps/linux/common/sys/eventfd.h b/libc/sysdeps/linux/common/sys/eventfd.h
new file mode 100644
index 000000000..a47b5fecf
--- /dev/null
+++ b/libc/sysdeps/linux/common/sys/eventfd.h
@@ -0,0 +1,44 @@
+/* Copyright (C) 2007-2013 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_EVENTFD_H
+#define _SYS_EVENTFD_H 1
+
+#include <stdint.h>
+
+/* Get the platform-dependent flags. */
+#include <bits/eventfd.h>
+
+/* Type for event counter. */
+typedef uint64_t eventfd_t;
+
+
+__BEGIN_DECLS
+
+/* Return file descriptor for generic event channel. Set initial
+ value to COUNT. */
+extern int eventfd (unsigned int __count, int __flags) __THROW;
+
+/* Read event counter and possibly wait for events. */
+extern int eventfd_read (int __fd, eventfd_t *__value);
+
+/* Increment event counter. */
+extern int eventfd_write (int __fd, eventfd_t __value);
+
+__END_DECLS
+
+#endif /* sys/eventfd.h */
diff --git a/libc/sysdeps/linux/common/sys/fanotify.h b/libc/sysdeps/linux/common/sys/fanotify.h
new file mode 100644
index 000000000..b1e9cca8e
--- /dev/null
+++ b/libc/sysdeps/linux/common/sys/fanotify.h
@@ -0,0 +1,96 @@
+/* Copyright (C) 2010-2015 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_FANOTIFY_H
+#define _SYS_FANOTIFY_H 1
+
+#include <stdint.h>
+
+struct fanotify_event_metadata {
+ unsigned event_len;
+ unsigned char vers;
+ unsigned char reserved;
+ unsigned short metadata_len;
+ unsigned long long mask
+#ifdef __GNUC__
+ __attribute__((__aligned__(8)))
+#endif
+ ;
+ int fd;
+ int pid;
+};
+
+struct fanotify_response {
+ int fd;
+ unsigned response;
+};
+
+#define FAN_ACCESS 0x01
+#define FAN_MODIFY 0x02
+#define FAN_CLOSE_WRITE 0x08
+#define FAN_CLOSE_NOWRITE 0x10
+#define FAN_OPEN 0x20
+#define FAN_Q_OVERFLOW 0x4000
+#define FAN_OPEN_PERM 0x10000
+#define FAN_ACCESS_PERM 0x20000
+#define FAN_ONDIR 0x40000000
+#define FAN_EVENT_ON_CHILD 0x08000000
+#define FAN_CLOSE (FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE)
+#define FAN_CLOEXEC 0x01
+#define FAN_NONBLOCK 0x02
+#define FAN_CLASS_NOTIF 0
+#define FAN_CLASS_CONTENT 0x04
+#define FAN_CLASS_PRE_CONTENT 0x08
+#define FAN_ALL_CLASS_BITS (FAN_CLASS_NOTIF | FAN_CLASS_CONTENT | FAN_CLASS_PRE_CONTENT)
+#define FAN_UNLIMITED_QUEUE 0x10
+#define FAN_UNLIMITED_MARKS 0x20
+#define FAN_ALL_INIT_FLAGS (FAN_CLOEXEC | FAN_NONBLOCK | FAN_ALL_CLASS_BITS | FAN_UNLIMITED_QUEUE | FAN_UNLIMITED_MARKS)
+#define FAN_MARK_ADD 0x01
+#define FAN_MARK_REMOVE 0x02
+#define FAN_MARK_DONT_FOLLOW 0x04
+#define FAN_MARK_ONLYDIR 0x08
+#define FAN_MARK_MOUNT 0x10
+#define FAN_MARK_IGNORED_MASK 0x20
+#define FAN_MARK_IGNORED_SURV_MODIFY 0x40
+#define FAN_MARK_FLUSH 0x80
+#define FAN_ALL_MARK_FLAGS (FAN_MARK_ADD | FAN_MARK_REMOVE | FAN_MARK_DONT_FOLLOW | FAN_MARK_ONLYDIR | FAN_MARK_MOUNT | FAN_MARK_IGNORED_MASK | FAN_MARK_IGNORED_SURV_MODIFY | FAN_MARK_FLUSH)
+#define FAN_ALL_EVENTS (FAN_ACCESS | FAN_MODIFY | FAN_CLOSE | FAN_OPEN)
+#define FAN_ALL_PERM_EVENTS (FAN_OPEN_PERM | FAN_ACCESS_PERM)
+#define FAN_ALL_OUTGOING_EVENTS (FAN_ALL_EVENTS | FAN_ALL_PERM_EVENTS | FAN_Q_OVERFLOW)
+#define FANOTIFY_METADATA_VERSION 3
+#define FAN_ALLOW 0x01
+#define FAN_DENY 0x02
+#define FAN_NOFD -1
+#define FAN_EVENT_METADATA_LEN (sizeof(struct fanotify_event_metadata))
+#define FAN_EVENT_NEXT(meta, len) ((len) -= (meta)->event_len, (struct fanotify_event_metadata*)(((char *)(meta)) + (meta)->event_len))
+#define FAN_EVENT_OK(meta, len) ((long)(len) >= (long)FAN_EVENT_METADATA_LEN && (long)(meta)->event_len >= (long)FAN_EVENT_METADATA_LEN && (long)(meta)->event_len <= (long)(len))
+
+
+__BEGIN_DECLS
+
+/* Create and initialize fanotify group. */
+extern int fanotify_init (unsigned int __flags, unsigned int __event_f_flags)
+ __THROW;
+
+/* Add, remove, or modify an fanotify mark on a filesystem object. */
+extern int fanotify_mark (int __fanotify_fd, unsigned int __flags,
+ uint64_t __mask, int __dfd, const char *__pathname)
+ __THROW;
+
+__END_DECLS
+
+#endif /* sys/fanotify.h */
diff --git a/libc/sysdeps/linux/common/sys/inotify.h b/libc/sysdeps/linux/common/sys/inotify.h
index 0131db9d3..a1d74d676 100644
--- a/libc/sysdeps/linux/common/sys/inotify.h
+++ b/libc/sysdeps/linux/common/sys/inotify.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2005-2012 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
@@ -12,15 +12,17 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_INOTIFY_H
#define _SYS_INOTIFY_H 1
#include <stdint.h>
+/* Get the platform-dependent flags. */
+#include <bits/inotify.h>
+
/* Structure describing an inotify event. */
struct inotify_event
@@ -62,6 +64,8 @@ struct inotify_event
#define IN_ONLYDIR 0x01000000 /* Only watch the path if it is a
directory. */
#define IN_DONT_FOLLOW 0x02000000 /* Do not follow a sym link. */
+#define IN_EXCL_UNLINK 0x04000000 /* Exclude events on unlinked
+ objects. */
#define IN_MASK_ADD 0x20000000 /* Add to the mask of an already
existing watch. */
#define IN_ISDIR 0x40000000 /* Event occurred against dir. */
@@ -79,13 +83,16 @@ __BEGIN_DECLS
/* Create and initialize inotify instance. */
extern int inotify_init (void) __THROW;
+/* Create and initialize inotify instance. */
+extern int inotify_init1 (int __flags) __THROW;
+
/* Add watch of object NAME to inotify instance FD. Notify about
events specified by MASK. */
extern int inotify_add_watch (int __fd, const char *__name, uint32_t __mask)
__THROW;
/* Remove the watch specified by WD from the inotify instance FD. */
-extern int inotify_rm_watch (int __fd, uint32_t __wd) __THROW;
+extern int inotify_rm_watch (int __fd, int __wd) __THROW;
__END_DECLS
diff --git a/libc/sysdeps/linux/common/sys/prctl.h b/libc/sysdeps/linux/common/sys/prctl.h
index 7e9b72d3a..dc23b6799 100644
--- a/libc/sysdeps/linux/common/sys/prctl.h
+++ b/libc/sysdeps/linux/common/sys/prctl.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_PRCTL_H
#define _SYS_PRCTL_H 1
diff --git a/libc/sysdeps/linux/common/sys/ptrace.h b/libc/sysdeps/linux/common/sys/ptrace.h
index b4aec4f20..7a7998a6c 100644
--- a/libc/sysdeps/linux/common/sys/ptrace.h
+++ b/libc/sysdeps/linux/common/sys/ptrace.h
@@ -1,5 +1,5 @@
/* `ptrace' debugger support interface. Linux version.
- Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1996-2012 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
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_PTRACE_H
#define _SYS_PTRACE_H 1
@@ -109,8 +108,77 @@ enum __ptrace_request
#define PT_SETFPXREGS PTRACE_SETFPXREGS
/* Continue and stop at the next (return from) syscall. */
- PTRACE_SYSCALL = 24
+ PTRACE_SYSCALL = 24,
#define PT_SYSCALL PTRACE_SYSCALL
+
+ /* 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
+
+ /* Get register content. */
+ PTRACE_GETREGSET = 0x4204,
+#define PTRACE_GETREGSET PTRACE_GETREGSET
+
+ /* Set register content. */
+ PTRACE_SETREGSET = 0x4205,
+#define PTRACE_SETREGSET PTRACE_SETREGSET
+
+ /* Like PTRACE_ATTACH, but do not force tracee to trap and do not affect
+ signal or group stop state. */
+ PTRACE_SEIZE = 0x4206,
+#define PTRACE_SEIZE PTRACE_SEIZE
+
+ /* Trap seized tracee. */
+ PTRACE_INTERRUPT = 0x4207,
+#define PTRACE_INTERRUPT PTRACE_INTERRUPT
+
+ /* Wait for next group event. */
+ PTRACE_LISTEN = 0x4208
+};
+
+
+/* Flag for PTRACE_LISTEN. */
+enum __ptrace_flags
+{
+ PTRACE_SEIZE_DEVEL = 0x80000000
+};
+
+/* 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_TRACESECCOMP = 0x00000080,
+ PTRACE_O_MASK = 0x000000ff
+};
+
+/* 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,
+ PTRAVE_EVENT_SECCOMP = 7
};
/* Perform process tracing functions. REQUEST is one of the values
diff --git a/libc/sysdeps/linux/common/sys/random.h b/libc/sysdeps/linux/common/sys/random.h
new file mode 100644
index 000000000..42f802576
--- /dev/null
+++ b/libc/sysdeps/linux/common/sys/random.h
@@ -0,0 +1,33 @@
+/* Copyright (C) 2015 Bernhard Reutner-Fischer
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+*/
+
+#ifndef _SYS_RANDOM_H
+#define _SYS_RANDOM_H 1
+#include <features.h>
+
+__BEGIN_DECLS
+
+#if defined __UCLIBC_LINUX_SPECIFIC__ && defined __USE_GNU
+# if 0 /*def __ASSUME_GETRANDOM_SYSCALL */
+# include <linux/random.h>
+# else
+# undef GRND_NONBLOCK
+# undef GRND_RANDOM
+/*
+ * Flags for getrandom(2)
+ *
+ * GRND_NONBLOCK Don't block and return EAGAIN instead
+ * GRND_RANDOM Use the /dev/random pool instead of /dev/urandom
+ */
+# define GRND_NONBLOCK 0x0001
+# define GRND_RANDOM 0x0002
+# endif
+/* FIXME: aren't there a couple of __restrict and const missing ? */
+extern int getrandom(void *__buf, size_t count, unsigned int flags)
+ __nonnull ((1)) __wur;
+#endif
+
+__END_DECLS
+
+#endif /* sys/random.h */
diff --git a/libc/sysdeps/linux/common/sys/signalfd.h b/libc/sysdeps/linux/common/sys/signalfd.h
new file mode 100644
index 000000000..46a8d479f
--- /dev/null
+++ b/libc/sysdeps/linux/common/sys/signalfd.h
@@ -0,0 +1,58 @@
+/* Copyright (C) 2007-2012 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_SIGNALFD_H
+#define _SYS_SIGNALFD_H 1
+
+#define __need_sigset_t
+#include <signal.h>
+#include <stdint.h>
+
+/* Get the platform-dependent flags. */
+#include <bits/signalfd.h>
+
+struct signalfd_siginfo
+{
+ uint32_t ssi_signo;
+ int32_t ssi_errno;
+ int32_t ssi_code;
+ uint32_t ssi_pid;
+ uint32_t ssi_uid;
+ int32_t ssi_fd;
+ uint32_t ssi_tid;
+ uint32_t ssi_band;
+ uint32_t ssi_overrun;
+ uint32_t ssi_trapno;
+ int32_t ssi_status;
+ int32_t ssi_int;
+ uint64_t ssi_ptr;
+ uint64_t ssi_utime;
+ uint64_t ssi_stime;
+ uint64_t ssi_addr;
+ uint8_t __pad[48];
+};
+
+__BEGIN_DECLS
+
+/* Request notification for delivery of signals in MASK to be
+ performed using descriptor FD.*/
+extern int signalfd (int __fd, const sigset_t *__mask, int __flags)
+ __THROW __nonnull ((2));
+
+__END_DECLS
+
+#endif /* sys/signalfd.h */
diff --git a/libc/sysdeps/linux/common/sys/timerfd.h b/libc/sysdeps/linux/common/sys/timerfd.h
new file mode 100644
index 000000000..989382a26
--- /dev/null
+++ b/libc/sysdeps/linux/common/sys/timerfd.h
@@ -0,0 +1,52 @@
+/* Copyright (C) 2008, 2012 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_TIMERFD_H
+#define _SYS_TIMERFD_H 1
+
+#include <time.h>
+
+/* Get the platform-dependent flags. */
+#include <bits/timerfd.h>
+
+
+/* Bits to be set in the FLAGS parameter of `timerfd_settime'. */
+enum
+ {
+ TFD_TIMER_ABSTIME = 1 << 0
+#define TFD_TIMER_ABSTIME TFD_TIMER_ABSTIME
+ };
+
+
+__BEGIN_DECLS
+
+/* Return file descriptor for new interval timer source. */
+extern int timerfd_create (clockid_t __clock_id, int __flags) __THROW;
+
+/* Set next expiration time of interval timer source UFD to UTMR. If
+ FLAGS has the TFD_TIMER_ABSTIME flag set the timeout value is
+ absolute. Optionally return the old expiration time in OTMR. */
+extern int timerfd_settime (int __ufd, int __flags,
+ const struct itimerspec *__utmr,
+ struct itimerspec *__otmr) __THROW;
+
+/* Return the next expiration time of UFD. */
+extern int timerfd_gettime (int __ufd, struct itimerspec *__otmr) __THROW;
+
+__END_DECLS
+
+#endif /* sys/timerfd.h */
diff --git a/libc/sysdeps/linux/common/sys/user.h b/libc/sysdeps/linux/common/sys/user.h
index 30e9b57ab..03e56c3d7 100644
--- a/libc/sysdeps/linux/common/sys/user.h
+++ b/libc/sysdeps/linux/common/sys/user.h
@@ -1 +1 @@
-#include <linux/user.h>
+#error "This file is machine-dependent and not provided for this machine."
diff --git a/libc/sysdeps/linux/common/syscall.c b/libc/sysdeps/linux/common/syscall.c
new file mode 100644
index 000000000..61f798e2c
--- /dev/null
+++ b/libc/sysdeps/linux/common/syscall.c
@@ -0,0 +1,12 @@
+/*
+ * syscall() library function
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+
+long syscall(long sysnum, long arg1, long arg2, long arg3, long arg4, long arg5, long arg6)
+{
+ return INLINE_SYSCALL_NCS(sysnum, 6, arg1, arg2, arg3, arg4, arg5, arg6);
+}
diff --git a/libc/sysdeps/linux/common/syscalls.h b/libc/sysdeps/linux/common/syscalls.h
deleted file mode 100644
index c4f6a44fd..000000000
--- a/libc/sysdeps/linux/common/syscalls.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * Common header file for uClibc syscalls
- *
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-#define _LARGEFILE64_SOURCE
-#include <features.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/syscall.h>
-#include <endian.h>
-
-#undef __OPTIMIZE__
-/* We absolutely do _NOT_ want interfaces silently
- * being renamed under us or very bad things will happen... */
-#ifdef __USE_FILE_OFFSET64
-# undef __USE_FILE_OFFSET64
-#endif
-
-#include <bits/kernel_types.h>
diff --git a/libc/sysdeps/linux/common/sysctl.c b/libc/sysdeps/linux/common/sysctl.c
index adee22837..dde00be46 100644
--- a/libc/sysdeps/linux/common/sysctl.c
+++ b/libc/sysdeps/linux/common/sysctl.c
@@ -11,9 +11,6 @@
#if defined __NR__sysctl && (defined __USE_GNU || defined __USE_BSD)
/* psm: including sys/sysctl.h would depend on kernel headers */
-extern int sysctl (int *__name, int __nlen, void *__oldval,
- size_t *__oldlenp, void *__newval, size_t __newlen) __THROW;
-
struct __sysctl_args {
int *name;
int nlen;
@@ -23,22 +20,19 @@ struct __sysctl_args {
size_t newlen;
unsigned long __unused[4];
};
-
-static inline
-_syscall1(int, _sysctl, struct __sysctl_args *, args);
-
+extern int sysctl (int *__name, int __nlen, void *__oldval,
+ size_t *__oldlenp, void *__newval, size_t __newlen) __THROW;
int sysctl(int *name, int nlen, void *oldval, size_t * oldlenp,
void *newval, size_t newlen)
{
- struct __sysctl_args args = {
- .name = name,
- .nlen = nlen,
- .oldval = oldval,
- .oldlenp = oldlenp,
- .newval = newval,
- .newlen = newlen
- };
-
- return _sysctl(&args);
+ /* avoid initializing on the stack as gcc will call memset() */
+ struct __sysctl_args args;
+ args.name = name;
+ args.nlen = nlen;
+ args.oldval = oldval;
+ args.oldlenp = oldlenp;
+ args.newval = newval;
+ args.newlen = newlen;
+ return INLINE_SYSCALL(_sysctl, 1, &args);
}
#endif
diff --git a/libc/sysdeps/linux/common/sysdep.h b/libc/sysdeps/linux/common/sysdep.h
new file mode 100644
index 000000000..d7fb31412
--- /dev/null
+++ b/libc/sysdeps/linux/common/sysdep.h
@@ -0,0 +1,176 @@
+/* Generic asm macros used on many machines.
+ Copyright (C) 1991,92,93,96,98,2002,2003 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sys/syscall.h>
+
+#ifndef C_LABEL
+
+/* Define a macro we can use to construct the asm name for a C symbol. */
+#ifndef __UCLIBC_UNDERSCORES__
+#ifdef __STDC__
+#define C_LABEL(name) name##:
+#else
+#define C_LABEL(name) name/**/:
+#endif
+#else
+#ifdef __STDC__
+#define C_LABEL(name) _##name##:
+#else
+#define C_LABEL(name) _/**/name/**/:
+#endif
+#endif
+
+#endif
+
+#ifdef __ASSEMBLER__
+/* Mark the end of function named SYM. This is used on some platforms
+ to generate correct debugging information. */
+#ifndef END
+#define END(sym)
+#endif
+
+#ifndef JUMPTARGET
+#define JUMPTARGET(sym) sym
+#endif
+
+#define ret_ERRVAL ret
+
+/* 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
+# define cfi_def_cfa_register(reg) .cfi_def_cfa_register reg
+# define cfi_def_cfa_offset(off) .cfi_def_cfa_offset off
+# define cfi_adjust_cfa_offset(off) .cfi_adjust_cfa_offset off
+# define cfi_offset(reg, off) .cfi_offset reg, off
+# define cfi_rel_offset(reg, off) .cfi_rel_offset reg, off
+# define cfi_register(r1, r2) .cfi_register r1, r2
+# define cfi_return_column(reg) .cfi_return_column reg
+# define cfi_restore(reg) .cfi_restore reg
+# define cfi_same_value(reg) .cfi_same_value reg
+# define cfi_undefined(reg) .cfi_undefined reg
+# define cfi_remember_state .cfi_remember_state
+# define cfi_restore_state .cfi_restore_state
+# define cfi_window_save .cfi_window_save
+# define cfi_personality(enc, exp) .cfi_personality enc, exp
+# 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)
+# define cfi_def_cfa_register(reg)
+# define cfi_def_cfa_offset(off)
+# define cfi_adjust_cfa_offset(off)
+# define cfi_offset(reg, off)
+# define cfi_rel_offset(reg, off)
+# define cfi_register(r1, r2)
+# define cfi_return_column(reg)
+# define cfi_restore(reg)
+# define cfi_same_value(reg)
+# define cfi_undefined(reg)
+# define cfi_remember_state
+# define cfi_restore_state
+# define cfi_window_save
+# define cfi_personality(enc, exp)
+# define cfi_lsda(enc, exp)
+# endif
+
+#else /* ! ASSEMBLER */
+# 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) \
+ ".cfi_def_cfa " CFI_STRINGIFY(reg) "," CFI_STRINGIFY(off)
+# define CFI_DEF_CFA_REGISTER(reg) \
+ ".cfi_def_cfa_register " CFI_STRINGIFY(reg)
+# define CFI_DEF_CFA_OFFSET(off) \
+ ".cfi_def_cfa_offset " CFI_STRINGIFY(off)
+# define CFI_ADJUST_CFA_OFFSET(off) \
+ ".cfi_adjust_cfa_offset " CFI_STRINGIFY(off)
+# define CFI_OFFSET(reg, off) \
+ ".cfi_offset " CFI_STRINGIFY(reg) "," CFI_STRINGIFY(off)
+# define CFI_REL_OFFSET(reg, off) \
+ ".cfi_rel_offset " CFI_STRINGIFY(reg) "," CFI_STRINGIFY(off)
+# define CFI_REGISTER(r1, r2) \
+ ".cfi_register " CFI_STRINGIFY(r1) "," CFI_STRINGIFY(r2)
+# define CFI_RETURN_COLUMN(reg) \
+ ".cfi_return_column " CFI_STRINGIFY(reg)
+# define CFI_RESTORE(reg) \
+ ".cfi_restore " CFI_STRINGIFY(reg)
+# define CFI_UNDEFINED(reg) \
+ ".cfi_undefined " CFI_STRINGIFY(reg)
+# define CFI_REMEMBER_STATE \
+ ".cfi_remember_state"
+# define CFI_RESTORE_STATE \
+ ".cfi_restore_state"
+# define CFI_WINDOW_SAVE \
+ ".cfi_window_save"
+# define CFI_PERSONALITY(enc, exp) \
+ ".cfi_personality " CFI_STRINGIFY(enc) "," CFI_STRINGIFY(exp)
+# 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)
+# define CFI_DEF_CFA_REGISTER(reg)
+# define CFI_DEF_CFA_OFFSET(off)
+# define CFI_ADJUST_CFA_OFFSET(off)
+# define CFI_OFFSET(reg, off)
+# define CFI_REL_OFFSET(reg, off)
+# define CFI_REGISTER(r1, r2)
+# define CFI_RETURN_COLUMN(reg)
+# define CFI_RESTORE(reg)
+# define CFI_UNDEFINED(reg)
+# define CFI_REMEMBER_STATE
+# define CFI_RESTORE_STATE
+# define CFI_WINDOW_SAVE
+# define CFI_PERSONALITY(enc, exp)
+# define CFI_LSDA(enc, exp)
+# endif
+
+#endif /* __ASSEMBLER__ */
+
+/* Values used for encoding parameter of cfi_personality and cfi_lsda. */
+#define DW_EH_PE_absptr 0x00
+#define DW_EH_PE_omit 0xff
+#define DW_EH_PE_uleb128 0x01
+#define DW_EH_PE_udata2 0x02
+#define DW_EH_PE_udata4 0x03
+#define DW_EH_PE_udata8 0x04
+#define DW_EH_PE_sleb128 0x09
+#define DW_EH_PE_sdata2 0x0a
+#define DW_EH_PE_sdata4 0x0b
+#define DW_EH_PE_sdata8 0x0c
+#define DW_EH_PE_signed 0x08
+#define DW_EH_PE_pcrel 0x10
+#define DW_EH_PE_textrel 0x20
+#define DW_EH_PE_datarel 0x30
+#define DW_EH_PE_funcrel 0x40
+#define DW_EH_PE_aligned 0x50
+#define DW_EH_PE_indirect 0x80
+
diff --git a/libc/sysdeps/linux/common/sysfs.c b/libc/sysdeps/linux/common/sysfs.c
index a4292f768..02f37d78d 100644
--- a/libc/sysdeps/linux/common/sysfs.c
+++ b/libc/sysdeps/linux/common/sysfs.c
@@ -12,6 +12,6 @@
#include <sys/syscall.h>
#if defined __USE_SVID
-_syscall3(int, sysfs, int, option, unsigned int, index, char, addr);
+_syscall3(int, sysfs, int, option, unsigned int, index, char, addr)
#endif
#endif
diff --git a/libc/sysdeps/linux/common/sysinfo.c b/libc/sysdeps/linux/common/sysinfo.c
index 78bf75150..7eb292699 100644
--- a/libc/sysdeps/linux/common/sysinfo.c
+++ b/libc/sysdeps/linux/common/sysinfo.c
@@ -8,5 +8,8 @@
*/
#include <sys/syscall.h>
-#include <sys/sysinfo.h>
-_syscall1(int, sysinfo, struct sysinfo *, info);
+
+#ifdef __NR_sysinfo
+# include <sys/sysinfo.h>
+_syscall1(int, sysinfo, struct sysinfo *, info)
+#endif
diff --git a/libc/sysdeps/linux/common/tee.c b/libc/sysdeps/linux/common/tee.c
index 6725e82bb..2b11d9ecb 100644
--- a/libc/sysdeps/linux/common/tee.c
+++ b/libc/sysdeps/linux/common/tee.c
@@ -8,9 +8,10 @@
*/
#include <sys/syscall.h>
-#include <fcntl.h>
-#ifdef __NR_tee
+#if defined __NR_tee && defined __USE_GNU
+# include <fcntl.h>
+
_syscall4(ssize_t, tee, int, __fdin, int, __fdout, size_t, __len,
- unsigned int, __flags);
+ unsigned int, __flags)
#endif
diff --git a/libc/sysdeps/linux/common/time.c b/libc/sysdeps/linux/common/time.c
index a7aa153d4..cd87fb331 100644
--- a/libc/sysdeps/linux/common/time.c
+++ b/libc/sysdeps/linux/common/time.c
@@ -9,28 +9,23 @@
#include <sys/syscall.h>
#include <time.h>
-#include <sys/time.h>
-
-/* Experimentally off - libc_hidden_proto(time) */
#ifdef __NR_time
-_syscall1(time_t, time, time_t *, t);
+_syscall_noerr1(time_t, time, time_t *, t)
#else
-libc_hidden_proto(gettimeofday)
-
+# include <sys/time.h>
time_t time(time_t * t)
{
time_t result;
struct timeval tv;
- if (gettimeofday(&tv, (struct timezone *) NULL)) {
- result = (time_t) - 1;
- } else {
- result = (time_t) tv.tv_sec;
- }
- if (t != NULL) {
+ /* In Linux, gettimeofday fails only on bad parameter.
+ * We know that here parameter isn't bad.
+ */
+ gettimeofday(&tv, NULL);
+ result = (time_t) tv.tv_sec;
+ if (t != NULL)
*t = result;
- }
return result;
}
#endif
diff --git a/libc/sysdeps/linux/common/timerfd.c b/libc/sysdeps/linux/common/timerfd.c
new file mode 100644
index 000000000..233204480
--- /dev/null
+++ b/libc/sysdeps/linux/common/timerfd.c
@@ -0,0 +1,32 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * timerfd_create() / timerfd_settime() / timerfd_gettime() for uClibc
+ *
+ * Copyright (C) 2009 Stephan Raue <stephan@openelec.tv>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <sys/timerfd.h>
+
+/*
+ * timerfd_create()
+ */
+#ifdef __NR_timerfd_create
+_syscall2(int, timerfd_create, int, clockid, int, flags)
+#endif
+
+/*
+ * timerfd_settime()
+ */
+#ifdef __NR_timerfd_settime
+_syscall4(int,timerfd_settime, int, ufd, int, flags, const struct itimerspec *, utmr, struct itimerspec *, otmr)
+#endif
+
+/*
+ * timerfd_gettime()
+ */
+#ifdef __NR_timerfd_gettime
+_syscall2(int, timerfd_gettime, int, ufd, struct itimerspec *, otmr)
+#endif
diff --git a/libc/sysdeps/linux/common/times.c b/libc/sysdeps/linux/common/times.c
index a68a2981f..e35c4efc0 100644
--- a/libc/sysdeps/linux/common/times.c
+++ b/libc/sysdeps/linux/common/times.c
@@ -10,7 +10,5 @@
#include <sys/syscall.h>
#include <sys/times.h>
-libc_hidden_proto(times)
-
-_syscall1(clock_t, times, struct tms *, buf);
+_syscall_noerr1(clock_t, times, struct tms *, buf)
libc_hidden_def(times)
diff --git a/libc/sysdeps/linux/common/truncate.c b/libc/sysdeps/linux/common/truncate.c
index 5ae8749ed..5cbf67351 100644
--- a/libc/sysdeps/linux/common/truncate.c
+++ b/libc/sysdeps/linux/common/truncate.c
@@ -10,7 +10,25 @@
#include <sys/syscall.h>
#include <unistd.h>
-libc_hidden_proto(truncate)
+#if defined(__NR_truncate64) && !defined(__NR_truncate)
+# include <endian.h>
+# include <stdint.h>
-_syscall2(int, truncate, const char *, path, __off_t, length);
+int truncate(const char *path, __off_t length)
+{
+# if defined __UCLIBC_HAS_LFS
+ return truncate64(path, length);
+# elif __WORDSIZE == 32
+# if defined(__UCLIBC_SYSCALL_ALIGN_64BIT__)
+ return INLINE_SYSCALL(truncate64, 4, path, 0, OFF_HI_LO(length));
+# else
+ return INLINE_SYSCALL(truncate64, 3, path, OFF_HI_LO(length));
+# endif
+# endif
+}
+libc_hidden_def(truncate);
+
+#else
+_syscall2(int, truncate, const char *, path, __off_t, length)
libc_hidden_def(truncate)
+#endif
diff --git a/libc/sysdeps/linux/common/truncate64.c b/libc/sysdeps/linux/common/truncate64.c
index d4a1798fe..159c794f5 100644
--- a/libc/sysdeps/linux/common/truncate64.c
+++ b/libc/sysdeps/linux/common/truncate64.c
@@ -7,64 +7,36 @@
* and on 32 bit machines this sends things into the kernel as
* two 32-bit arguments (high and low 32 bits of length) that
* are ordered based on endianess. It turns out endian.h has
- * just the macro we need to order things, __LONG_LONG_PAIR.
+ * just the macro we need to order things, OFF64_HI_LO.
*/
-#include <features.h>
-#include <unistd.h>
-#include <errno.h>
-#include <endian.h>
-#include <stdint.h>
-#include <sys/types.h>
+#include <_lfs_64.h>
#include <sys/syscall.h>
+#include <unistd.h>
-#if defined __UCLIBC_HAS_LFS__
-
-#if defined __NR_truncate64
-
-#if __WORDSIZE == 64
-
-/* For a 64 bit machine, life is simple... */
-_syscall2(int, truncate64, const char *, path, __off64_t, length);
-
-#elif __WORDSIZE == 32
-
-#ifndef INLINE_SYSCALL
-#define INLINE_SYSCALL(name, nr, args...) __syscall_truncate64 (args)
-#define __NR___syscall_truncate64 __NR_truncate64
-#if defined(__UCLIBC_TRUNCATE64_HAS_4_ARGS__)
-static __inline__ _syscall4(int, __syscall_truncate64, const char *, path,
- uint32_t, pad, unsigned long, high_length, unsigned long, low_length);
-#else
-static __inline__ _syscall3(int, __syscall_truncate64, const char *, path,
- unsigned long, high_length, unsigned long, low_length);
-#endif
-#endif
-
+#ifdef __NR_truncate64
+# include <bits/wordsize.h>
-/* The exported truncate64 function. */
-int truncate64 (const char * path, __off64_t length)
+# if __WORDSIZE == 64
+_syscall2(int, truncate64, const char *, path, __off64_t, length)
+# elif __WORDSIZE == 32
+# include <endian.h>
+# include <stdint.h>
+int truncate64(const char * path, __off64_t length)
{
- uint32_t low = length & 0xffffffff;
- uint32_t high = length >> 32;
-#if defined(__UCLIBC_TRUNCATE64_HAS_4_ARGS__)
- return INLINE_SYSCALL(truncate64, 4, path, 0,
- __LONG_LONG_PAIR (high, low));
-#else
- return INLINE_SYSCALL(truncate64, 3, path,
- __LONG_LONG_PAIR (high, low));
-#endif
+# if defined(__UCLIBC_SYSCALL_ALIGN_64BIT__)
+ return INLINE_SYSCALL(truncate64, 4, path, 0, OFF64_HI_LO(length));
+# else
+ return INLINE_SYSCALL(truncate64, 3, path, OFF64_HI_LO(length));
+# endif
}
+# else
+# error Your machine is not 64 bit nor 32 bit, I am dazed and confused.
+# endif
-#else /* __WORDSIZE */
-#error Your machine is not 64 bit nor 32 bit, I am dazed and confused.
-#endif /* __WORDSIZE */
-
-#else /* __NR_truncate64 */
-
-libc_hidden_proto(truncate)
-
-int truncate64 (const char * path, __off64_t length)
+#else
+# include <errno.h>
+int truncate64(const char * path, __off64_t length)
{
__off_t x = (__off_t) length;
@@ -78,5 +50,4 @@ int truncate64 (const char * path, __off64_t length)
}
#endif /* __NR_truncate64 */
-
-#endif /* __UCLIBC_HAS_LFS__ */
+libc_hidden_def(truncate64)
diff --git a/libc/sysdeps/linux/common/ulimit.c b/libc/sysdeps/linux/common/ulimit.c
index 2a1c88081..8be4a37aa 100644
--- a/libc/sysdeps/linux/common/ulimit.c
+++ b/libc/sysdeps/linux/common/ulimit.c
@@ -7,21 +7,11 @@
#include <sys/syscall.h>
-#ifdef __NR_ulimit
-
-extern long int ulimit(int cmd, long arg);
-_syscall2(long, ulimit, int, cmd, long, arg);
-
-#else
-
#include <stdarg.h>
#include <unistd.h>
#include <ulimit.h>
#include <sys/resource.h>
-libc_hidden_proto(sysconf)
-libc_hidden_proto(getrlimit)
-libc_hidden_proto(setrlimit)
long int ulimit(int cmd, ...)
{
@@ -56,4 +46,3 @@ long int ulimit(int cmd, ...)
va_end (va);
return result;
}
-#endif
diff --git a/libc/sysdeps/linux/common/umask.c b/libc/sysdeps/linux/common/umask.c
index 01a7b9eb3..b558885c1 100644
--- a/libc/sysdeps/linux/common/umask.c
+++ b/libc/sysdeps/linux/common/umask.c
@@ -10,10 +10,4 @@
#include <sys/syscall.h>
#include <sys/stat.h>
-#define __NR___syscall_umask __NR_umask
-static __inline__ _syscall1(__kernel_mode_t, __syscall_umask, __kernel_mode_t, mode);
-
-mode_t umask(mode_t mode)
-{
- return (__syscall_umask(mode));
-}
+_syscall_noerr1(mode_t, umask, mode_t, mode)
diff --git a/libc/sysdeps/linux/common/umount.c b/libc/sysdeps/linux/common/umount.c
index 9090696d5..916c6c815 100644
--- a/libc/sysdeps/linux/common/umount.c
+++ b/libc/sysdeps/linux/common/umount.c
@@ -9,33 +9,15 @@
#include <sys/syscall.h>
-#if defined __USE_GNU
#include <sys/mount.h>
-
-/* arch provides umount() syscall */
#ifdef __NR_umount
-
-_syscall1(int, umount, const char *, specialfile);
-
-/* arch provides umount2() syscall */
+_syscall1(int, umount, const char *, specialfile)
#elif defined __NR_umount2
-
-# define __NR___syscall_umount2 __NR_umount2
-static __inline__ _syscall2(int, __syscall_umount2, const char *, special_file, int, flags);
-
-int umount(const char *special_file)
-{
- return (__syscall_umount2(special_file, 0));
-}
-
-/* arch doesn't provide any umount syscall !? */
-#else
-
+# ifndef __UCLIBC_LINUX_SPECIFIC__
+static __always_inline _syscall2(int, umount2, const char *, special_file, int, flags)
+# endif
int umount(const char *special_file)
{
- __set_errno(ENOSYS);
- return -1;
+ return umount2(special_file, 0);
}
-
-#endif
#endif
diff --git a/libc/sysdeps/linux/common/umount2.c b/libc/sysdeps/linux/common/umount2.c
index 25c24d450..c86f3c80f 100644
--- a/libc/sysdeps/linux/common/umount2.c
+++ b/libc/sysdeps/linux/common/umount2.c
@@ -9,15 +9,13 @@
#include <sys/syscall.h>
-#if defined __USE_GNU
+#if defined __UCLIBC_LINUX_SPECIFIC__ && defined __NR_umount2
#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;
-}
+_syscall2(int, umount2, const char *, special_file, int, flags)
+libc_hidden_def(umount2)
#endif
+
+#if defined __UCLIBC_LINUX_SPECIFIC__ && defined __NR_oldumount
+_syscall2(int, umount, const char *, special_file, int, flags)
+strong_alias(umount,umount2)
#endif
diff --git a/libc/sysdeps/linux/common/uname.c b/libc/sysdeps/linux/common/uname.c
index 22b870370..72dd7dab9 100644
--- a/libc/sysdeps/linux/common/uname.c
+++ b/libc/sysdeps/linux/common/uname.c
@@ -10,7 +10,5 @@
#include <sys/syscall.h>
#include <sys/utsname.h>
-libc_hidden_proto(uname)
-
-_syscall1(int, uname, struct utsname *, buf);
+_syscall1(int, uname, struct utsname *, buf)
libc_hidden_def(uname)
diff --git a/libc/sysdeps/linux/common/unlink.c b/libc/sysdeps/linux/common/unlink.c
index 313be9e0b..317bc5da8 100644
--- a/libc/sysdeps/linux/common/unlink.c
+++ b/libc/sysdeps/linux/common/unlink.c
@@ -10,7 +10,13 @@
#include <sys/syscall.h>
#include <unistd.h>
-libc_hidden_proto(unlink)
-
-_syscall1(int, unlink, const char *, pathname);
+#if defined __NR_unlinkat && !defined __NR_unlink
+# include <fcntl.h>
+int unlink(const char *pathname)
+{
+ return unlinkat(AT_FDCWD, pathname, 0);
+}
+#else
+_syscall1(int, unlink, const char *, pathname)
+#endif
libc_hidden_def(unlink)
diff --git a/libc/sysdeps/linux/common/unlinkat.c b/libc/sysdeps/linux/common/unlinkat.c
new file mode 100644
index 000000000..432af1b75
--- /dev/null
+++ b/libc/sysdeps/linux/common/unlinkat.c
@@ -0,0 +1,17 @@
+/*
+ * unlinkat() for uClibc
+ *
+ * Copyright (C) 2009 Analog Devices Inc.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <unistd.h>
+
+#ifdef __NR_unlinkat
+_syscall3(int, unlinkat, int, fd, const char *, file, int, flag)
+libc_hidden_def(unlinkat)
+#else
+/* should add emulation with unlink() and /proc/self/fd/ ... */
+#endif
diff --git a/libc/sysdeps/linux/common/unshare.c b/libc/sysdeps/linux/common/unshare.c
new file mode 100644
index 000000000..624ca12e3
--- /dev/null
+++ b/libc/sysdeps/linux/common/unshare.c
@@ -0,0 +1,15 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * unshare() for uClibc
+ *
+ * Copyright (C) 2011 Henning Heinold <heinold@inf.fu-berlin.de>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <sched.h>
+
+#if defined __NR_unshare
+_syscall1(int, unshare, int, flags)
+#endif
diff --git a/libc/sysdeps/linux/common/unwind.h b/libc/sysdeps/linux/common/unwind.h
new file mode 100644
index 000000000..2bdf01686
--- /dev/null
+++ b/libc/sysdeps/linux/common/unwind.h
@@ -0,0 +1,219 @@
+/* Exception handling and frame unwind runtime interface routines.
+ Copyright (C) 2001, 2003 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, see
+ <http://www.gnu.org/licenses/>. */
+
+/* This is derived from the C++ ABI for IA-64. Where we diverge
+ for cross-architecture compatibility are noted with "@@@". */
+
+#ifndef _UNWIND_H
+#define _UNWIND_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Level 1: Base ABI */
+
+/* @@@ The IA-64 ABI uses uint64 throughout. Most places this is
+ inefficient for 32-bit and smaller machines. */
+typedef unsigned _Unwind_Word __attribute__((__mode__(__word__)));
+typedef signed _Unwind_Sword __attribute__((__mode__(__word__)));
+#if defined(__ia64__) && defined(__hpux__)
+typedef unsigned _Unwind_Ptr __attribute__((__mode__(__word__)));
+#else
+typedef unsigned _Unwind_Ptr __attribute__((__mode__(__pointer__)));
+#endif
+typedef unsigned _Unwind_Internal_Ptr __attribute__((__mode__(__pointer__)));
+
+/* @@@ The IA-64 ABI uses a 64-bit word to identify the producer and
+ consumer of an exception. We'll go along with this for now even on
+ 32-bit machines. We'll need to provide some other option for
+ 16-bit machines and for machines with > 8 bits per byte. */
+typedef unsigned _Unwind_Exception_Class __attribute__((__mode__(__DI__)));
+
+/* The unwind interface uses reason codes in several contexts to
+ identify the reasons for failures or other actions. */
+typedef enum
+{
+ _URC_NO_REASON = 0,
+ _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
+ _URC_FATAL_PHASE2_ERROR = 2,
+ _URC_FATAL_PHASE1_ERROR = 3,
+ _URC_NORMAL_STOP = 4,
+ _URC_END_OF_STACK = 5,
+ _URC_HANDLER_FOUND = 6,
+ _URC_INSTALL_CONTEXT = 7,
+ _URC_CONTINUE_UNWIND = 8
+} _Unwind_Reason_Code;
+
+
+/* The unwind interface uses a pointer to an exception header object
+ as its representation of an exception being thrown. In general, the
+ full representation of an exception object is language- and
+ implementation-specific, but it will be prefixed by a header
+ understood by the unwind interface. */
+
+struct _Unwind_Exception;
+
+typedef void (*_Unwind_Exception_Cleanup_Fn) (_Unwind_Reason_Code,
+ struct _Unwind_Exception *);
+
+struct _Unwind_Exception
+{
+ _Unwind_Exception_Class exception_class;
+ _Unwind_Exception_Cleanup_Fn exception_cleanup;
+ _Unwind_Word private_1;
+ _Unwind_Word private_2;
+
+ /* @@@ The IA-64 ABI says that this structure must be double-word aligned.
+ Taking that literally does not make much sense generically. Instead we
+ provide the maximum alignment required by any type for the machine. */
+} __attribute__((__aligned__));
+
+
+/* The ACTIONS argument to the personality routine is a bitwise OR of one
+ or more of the following constants. */
+typedef int _Unwind_Action;
+
+#define _UA_SEARCH_PHASE 1
+#define _UA_CLEANUP_PHASE 2
+#define _UA_HANDLER_FRAME 4
+#define _UA_FORCE_UNWIND 8
+#define _UA_END_OF_STACK 16
+
+/* This is an opaque type used to refer to a system-specific data
+ structure used by the system unwinder. This context is created and
+ destroyed by the system, and passed to the personality routine
+ during unwinding. */
+struct _Unwind_Context;
+
+/* Raise an exception, passing along the given exception object. */
+extern _Unwind_Reason_Code _Unwind_RaiseException (struct _Unwind_Exception *);
+
+/* Raise an exception for forced unwinding. */
+
+typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)
+ (int, _Unwind_Action, _Unwind_Exception_Class,
+ struct _Unwind_Exception *, struct _Unwind_Context *, void *);
+
+extern _Unwind_Reason_Code _Unwind_ForcedUnwind (struct _Unwind_Exception *,
+ _Unwind_Stop_Fn,
+ void *);
+
+/* Helper to invoke the exception_cleanup routine. */
+extern void _Unwind_DeleteException (struct _Unwind_Exception *);
+
+/* Resume propagation of an existing exception. This is used after
+ e.g. executing cleanup code, and not to implement rethrowing. */
+extern void _Unwind_Resume (struct _Unwind_Exception *);
+
+/* @@@ Use unwind data to perform a stack backtrace. The trace callback
+ is called for every stack frame in the call chain, but no cleanup
+ actions are performed. */
+typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn)
+ (struct _Unwind_Context *, void *);
+
+extern _Unwind_Reason_Code _Unwind_Backtrace (_Unwind_Trace_Fn, void *);
+
+/* These functions are used for communicating information about the unwind
+ context (i.e. the unwind descriptors and the user register state) between
+ the unwind library and the personality routine and landing pad. Only
+ selected registers maybe manipulated. */
+
+extern _Unwind_Word _Unwind_GetGR (struct _Unwind_Context *, int);
+extern void _Unwind_SetGR (struct _Unwind_Context *, int, _Unwind_Word);
+
+extern _Unwind_Ptr _Unwind_GetIP (struct _Unwind_Context *);
+extern void _Unwind_SetIP (struct _Unwind_Context *, _Unwind_Ptr);
+
+/* @@@ Retrieve the CFA of the given context. */
+extern _Unwind_Word _Unwind_GetCFA (struct _Unwind_Context *);
+
+extern void *_Unwind_GetLanguageSpecificData (struct _Unwind_Context *);
+
+extern _Unwind_Ptr _Unwind_GetRegionStart (struct _Unwind_Context *);
+
+
+/* The personality routine is the function in the C++ (or other language)
+ runtime library which serves as an interface between the system unwind
+ library and language-specific exception handling semantics. It is
+ specific to the code fragment described by an unwind info block, and
+ it is always referenced via the pointer in the unwind info block, and
+ hence it has no ABI-specified name.
+
+ Note that this implies that two different C++ implementations can
+ use different names, and have different contents in the language
+ specific data area. Moreover, that the language specific data
+ area contains no version info because name of the function invoked
+ provides more effective versioning by detecting at link time the
+ lack of code to handle the different data format. */
+
+typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)
+ (int, _Unwind_Action, _Unwind_Exception_Class,
+ struct _Unwind_Exception *, struct _Unwind_Context *);
+
+/* @@@ The following alternate entry points are for setjmp/longjmp
+ based unwinding. */
+
+struct SjLj_Function_Context;
+extern void _Unwind_SjLj_Register (struct SjLj_Function_Context *);
+extern void _Unwind_SjLj_Unregister (struct SjLj_Function_Context *);
+
+extern _Unwind_Reason_Code _Unwind_SjLj_RaiseException
+ (struct _Unwind_Exception *);
+extern _Unwind_Reason_Code _Unwind_SjLj_ForcedUnwind
+ (struct _Unwind_Exception *, _Unwind_Stop_Fn, void *);
+extern void _Unwind_SjLj_Resume (struct _Unwind_Exception *);
+
+/* @@@ The following provide access to the base addresses for text
+ and data-relative addressing in the LDSA. In order to stay link
+ compatible with the standard ABI for IA-64, we inline these. */
+
+#ifdef __ia64__
+#include <stdlib.h>
+
+static inline _Unwind_Ptr
+_Unwind_GetDataRelBase (struct _Unwind_Context *_C)
+{
+ /* The GP is stored in R1. */
+ return _Unwind_GetGR (_C, 1);
+}
+
+static inline _Unwind_Ptr
+_Unwind_GetTextRelBase (struct _Unwind_Context *_C)
+{
+ abort ();
+ return 0;
+}
+
+/* @@@ Retrieve the Backing Store Pointer of the given context. */
+extern _Unwind_Word _Unwind_GetBSP (struct _Unwind_Context *);
+#else
+extern _Unwind_Ptr _Unwind_GetDataRelBase (struct _Unwind_Context *);
+extern _Unwind_Ptr _Unwind_GetTextRelBase (struct _Unwind_Context *);
+#endif
+
+/* @@@ Given an address, return the entry point of the function that
+ contains it. */
+extern void * _Unwind_FindEnclosingFunction (void *pc);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* unwind.h */
diff --git a/libc/sysdeps/linux/common/uselib.c b/libc/sysdeps/linux/common/uselib.c
index ffc5d77a1..b2b806f39 100644
--- a/libc/sysdeps/linux/common/uselib.c
+++ b/libc/sysdeps/linux/common/uselib.c
@@ -13,6 +13,6 @@ linux specific and we do not use it in uClibc.
#include <unistd.h>
#ifdef __NR_uselib
int uselib (const char *library);
-_syscall1(int, uselib, const char *, library);
+_syscall1(int, uselib, const char *, library)
#endif
#endif
diff --git a/libc/sysdeps/linux/common/ustat.c b/libc/sysdeps/linux/common/ustat.c
index 578763cb5..dbb545f52 100644
--- a/libc/sysdeps/linux/common/ustat.c
+++ b/libc/sysdeps/linux/common/ustat.c
@@ -11,15 +11,18 @@
#include <sys/ustat.h>
#include <sys/sysmacros.h>
-#define __NR___syscall_ustat __NR_ustat
-static __inline__ _syscall2(int, __syscall_ustat,
- unsigned short int, kdev_t, struct ustat *, ubuf);
+#ifdef __NR_ustat
+# define __NR___syscall_ustat __NR_ustat
+/* Kernel's fs/super.c defines this:
+ * long sys_ustat(unsigned dev, struct ustat __user * ubuf),
+ * thus we use unsigned, not __kernel_dev_t.
+ */
+static __always_inline _syscall2(int, __syscall_ustat,
+ unsigned, kdev_t,
+ struct ustat *, ubuf)
int ustat(dev_t dev, struct ustat *ubuf)
{
- /* We must convert the dev_t value to a __kernel_dev_t */
- __kernel_dev_t k_dev;
-
- k_dev = ((major(dev) & 0xff) << 8) | (minor(dev) & 0xff);
- return __syscall_ustat(k_dev, ubuf);
+ return __syscall_ustat(dev, ubuf);
}
+#endif
diff --git a/libc/sysdeps/linux/common/utime.c b/libc/sysdeps/linux/common/utime.c
index 6e35be2c1..a2ce8a5d5 100644
--- a/libc/sysdeps/linux/common/utime.c
+++ b/libc/sysdeps/linux/common/utime.c
@@ -10,16 +10,33 @@
#include <sys/syscall.h>
#include <utime.h>
-libc_hidden_proto(utime)
+#if defined __NR_utimensat && !defined __NR_utime
+# include <fcntl.h>
+# include <stddef.h>
-#ifdef __NR_utime
-_syscall2(int, utime, const char *, file, const struct utimbuf *, times);
-#else
-#include <stdlib.h>
-#include <sys/time.h>
+int utime(const char *file, const struct utimbuf *times)
+{
+ struct timespec tspecs[2], *ts;
+
+ if (times) {
+ ts = tspecs;
+ ts[0].tv_sec = times->actime;
+ ts[0].tv_nsec = 0;
+ ts[1].tv_sec = times->modtime;
+ ts[1].tv_nsec = 0;
+ } else {
+ ts = NULL;
+ }
-libc_hidden_proto(utimes)
-libc_hidden_proto(gettimeofday)
+ return utimensat(AT_FDCWD, file, ts, 0);
+}
+
+#elif defined(__NR_utime)
+_syscall2(int, utime, const char *, file, const struct utimbuf *, times)
+#elif defined __NR_utimes /* alpha || ia64 */
+# define __need_NULL
+# include <stddef.h>
+# include <sys/time.h>
int utime(const char *file, const struct utimbuf *times)
{
@@ -28,10 +45,14 @@ int utime(const char *file, const struct utimbuf *times)
if (times != NULL) {
timevals[0].tv_usec = 0L;
timevals[1].tv_usec = 0L;
- timevals[0].tv_sec = (long int) times->actime;
- timevals[1].tv_sec = (long int) times->modtime;
+ timevals[0].tv_sec = (time_t) times->actime;
+ timevals[1].tv_sec = (time_t) times->modtime;
}
return utimes(file, times ? timevals : NULL);
}
#endif
+
+#if (defined __NR_utimensat && !defined __NR_utime) || \
+ defined __NR_utime || defined __NR_utimes
libc_hidden_def(utime)
+#endif
diff --git a/libc/sysdeps/linux/common/utimensat.c b/libc/sysdeps/linux/common/utimensat.c
new file mode 100644
index 000000000..2cfb8247d
--- /dev/null
+++ b/libc/sysdeps/linux/common/utimensat.c
@@ -0,0 +1,18 @@
+/*
+ * utimensat() for uClibc
+ *
+ * Copyright (C) 2009 Analog Devices Inc.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <sys/stat.h>
+
+#ifdef __NR_utimensat
+_syscall4(int, utimensat, int, fd, const char *, path, const struct timespec *, times, int, flags)
+libc_hidden_def(utimensat)
+#else
+/* should add emulation with utimens() and /proc/self/fd/ ... */
+#endif
+
diff --git a/libc/sysdeps/linux/common/utimes.c b/libc/sysdeps/linux/common/utimes.c
index 37909a7b3..b5e76cc59 100644
--- a/libc/sysdeps/linux/common/utimes.c
+++ b/libc/sysdeps/linux/common/utimes.c
@@ -8,17 +8,33 @@
*/
#include <sys/syscall.h>
-#include <utime.h>
#include <sys/time.h>
-libc_hidden_proto(utimes)
+#if defined __NR_utimensat && !defined __NR_utimes
+# include <fcntl.h>
+# include <stddef.h>
+int utimes(const char *file, const struct timeval tvp[2])
+{
+ struct timespec ts[2], *times;
+ if (tvp) {
+ times = ts;
+ times[0].tv_sec = tvp[0].tv_sec;
+ times[0].tv_nsec = tvp[0].tv_usec * 1000;
+ times[1].tv_sec = tvp[1].tv_sec;
+ times[1].tv_nsec = tvp[1].tv_usec * 1000;
+ } else {
+ times = NULL;
+ }
-#ifdef __NR_utimes
-_syscall2(int, utimes, const char *, file, const struct timeval *, tvp);
-#else
-#include <stdlib.h>
+ return utimensat(AT_FDCWD, file, times, 0);
+}
-libc_hidden_proto(utime)
+#elif defined __NR_utimes
+_syscall2(int, utimes, const char *, file, const struct timeval *, tvp)
+#elif defined __NR_utime
+# define __need_NULL
+# include <stddef.h>
+# include <utime.h>
int utimes(const char *file, const struct timeval tvp[2])
{
@@ -34,5 +50,7 @@ int utimes(const char *file, const struct timeval tvp[2])
return utime(file, times);
}
#endif
-link_warning(utimes, "the use of LEGACY `utimes' is discouraged, use `utime'")
+
+#if defined __NR_utimensat || defined __NR_utimes || defined __NR_utime
libc_hidden_def(utimes)
+#endif
diff --git a/libc/sysdeps/linux/common/vfork.c b/libc/sysdeps/linux/common/vfork.c
index f9634cd5c..81bcfc175 100644
--- a/libc/sysdeps/linux/common/vfork.c
+++ b/libc/sysdeps/linux/common/vfork.c
@@ -4,24 +4,37 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-/* Trivial implementation for arches that lack vfork */
-#include <unistd.h>
-#include <sys/types.h>
#include <sys/syscall.h>
-#ifdef __ARCH_USE_MMU__
+#if (defined __NR_vfork || defined __NR_clone || (defined __ARCH_USE_MMU__ && defined __NR_fork)) && (defined __USE_BSD || defined __USE_XOPEN_EXTENDED)
+# include <unistd.h>
+extern __typeof(vfork) __vfork attribute_hidden;
-#ifdef __NR_fork
-libc_hidden_proto(fork)
+# if defined __NR_clone && !defined __NR_vfork
+# include <signal.h>
+# include <sys/types.h>
-extern __typeof(vfork) __vfork attribute_hidden;
+pid_t __vfork(void)
+{
+ pid_t pid = INLINE_SYSCALL(clone, 4, SIGCHLD,
+ NULL, NULL, NULL);
+
+ if (pid < 0)
+ return -1;
+
+ return pid;
+}
+
+# elif defined __NR_vfork
+# define __NR___vfork __NR_vfork
+_syscall0(pid_t, __vfork)
+# else
+/* Trivial implementation for arches that lack vfork */
pid_t __vfork(void)
{
return fork();
}
-libc_hidden_proto(vfork)
-weak_alias(__vfork,vfork)
+# endif
+strong_alias(__vfork,vfork)
libc_hidden_weak(vfork)
#endif
-
-#endif
diff --git a/libc/sysdeps/linux/common/vhangup.c b/libc/sysdeps/linux/common/vhangup.c
index 8989a69d6..77910e68f 100644
--- a/libc/sysdeps/linux/common/vhangup.c
+++ b/libc/sysdeps/linux/common/vhangup.c
@@ -10,5 +10,5 @@
#include <sys/syscall.h>
#include <unistd.h>
#if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_UNIX98)
-_syscall0(int, vhangup);
+_syscall0(int, vhangup)
#endif
diff --git a/libc/sysdeps/linux/common/vmsplice.c b/libc/sysdeps/linux/common/vmsplice.c
index a0156d772..b0d71935c 100644
--- a/libc/sysdeps/linux/common/vmsplice.c
+++ b/libc/sysdeps/linux/common/vmsplice.c
@@ -8,21 +8,10 @@
*/
#include <sys/syscall.h>
-#include <fcntl.h>
-libc_hidden_proto(vmsplice)
+#if defined __NR_vmsplice && defined __USE_GNU
+# include <fcntl.h>
-#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;
-}
+ size_t, __count, unsigned int, __flags)
#endif
-
-libc_hidden_def(vmsplice)
-
diff --git a/libc/sysdeps/linux/common/wait.c b/libc/sysdeps/linux/common/wait.c
index 39d0e47b9..df4005839 100644
--- a/libc/sysdeps/linux/common/wait.c
+++ b/libc/sysdeps/linux/common/wait.c
@@ -1,23 +1,14 @@
/*
+ * Copyright (C) 2006 Steven J. Hill <sjhill@realitydiluted.com>
* Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-
-#include <stdlib.h>
-#include <syscall.h>
-#include <sys/types.h>
#include <sys/wait.h>
-#include <sys/resource.h>
-
-libc_hidden_proto(wait4)
-
-extern __typeof(wait) __libc_wait;
+#include <cancel.h>
-/* Wait for a child to die. When one does, put its status in *STAT_LOC
- * and return its process ID. For errors, return (pid_t) -1. */
-__pid_t __libc_wait (__WAIT_STATUS_DEFN stat_loc)
+static pid_t __NC(wait)(__WAIT_STATUS_DEFN stat_loc)
{
- return wait4 (WAIT_ANY, stat_loc, 0, (struct rusage *) NULL);
+ return __wait4_nocancel(WAIT_ANY, stat_loc, 0, (struct rusage *)NULL);
}
-weak_alias(__libc_wait,wait)
+CANCELLABLE_SYSCALL(pid_t, wait, (__WAIT_STATUS_DEFN stat_loc), (stat_loc))
diff --git a/libc/sysdeps/linux/common/wait3.c b/libc/sysdeps/linux/common/wait3.c
index 8a2d43f7a..a4391fd18 100644
--- a/libc/sysdeps/linux/common/wait3.c
+++ b/libc/sysdeps/linux/common/wait3.c
@@ -5,21 +5,12 @@
*/
#include <sys/syscall.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <sys/resource.h>
-#if defined __USE_BSD
+#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
+# include <sys/wait.h>
-libc_hidden_proto(wait4)
-
-/* Wait for a child to exit. When one does, put its status in *STAT_LOC and
- * return its process ID. For errors return (pid_t) -1. If USAGE is not nil,
- * store information about the child's resource usage (as a `struct rusage')
- * there. If the WUNTRACED bit is set in OPTIONS, return status for stopped
- * children; otherwise don't. */
-pid_t wait3 (__WAIT_STATUS stat_loc, int options, struct rusage * usage)
+pid_t wait3(__WAIT_STATUS stat_loc, int options, struct rusage *usage)
{
- return wait4 (WAIT_ANY, stat_loc, options, usage);
+ return __wait4_nocancel(WAIT_ANY, stat_loc, options, usage);
}
#endif
diff --git a/libc/sysdeps/linux/common/wait4.c b/libc/sysdeps/linux/common/wait4.c
index 5c51116fa..b7952ad81 100644
--- a/libc/sysdeps/linux/common/wait4.c
+++ b/libc/sysdeps/linux/common/wait4.c
@@ -8,19 +8,16 @@
*/
#include <sys/syscall.h>
-#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
#include <sys/wait.h>
-#include <sys/resource.h>
-libc_hidden_proto(wait4)
+# define __NR___syscall_wait4 __NR_wait4
+static __always_inline _syscall4(int, __syscall_wait4, __kernel_pid_t, pid,
+ int *, status, int, opts, struct rusage *, rusage)
-#define __NR___syscall_wait4 __NR_wait4
-static __inline__ _syscall4(int, __syscall_wait4, __kernel_pid_t, pid,
- int *, status, int, opts, struct rusage *, rusage);
-
-pid_t wait4(pid_t pid, int *status, int opts, struct rusage *rusage)
+pid_t __wait4_nocancel(pid_t pid, int *status, int opts, struct rusage *rusage)
{
- return (__syscall_wait4(pid, status, opts, rusage));
+ return __syscall_wait4(pid, status, opts, rusage);
}
-libc_hidden_def(wait4)
+#ifdef __USE_BSD
+strong_alias(__wait4_nocancel,wait4)
#endif
diff --git a/libc/sysdeps/linux/common/waitid.c b/libc/sysdeps/linux/common/waitid.c
index b8d2f70ba..58f467320 100644
--- a/libc/sysdeps/linux/common/waitid.c
+++ b/libc/sysdeps/linux/common/waitid.c
@@ -5,12 +5,53 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#include <sys/syscall.h>
+#include <features.h>
#if defined __USE_SVID || defined __USE_XOPEN
-#include <unistd.h>
-#include <sys/types.h>
+
+#include <sys/syscall.h>
#include <sys/wait.h>
+#include <cancel.h>
+#ifndef __NR_waitid
+# include <string.h>
+#endif
+
+static int __NC(waitid)(idtype_t idtype, id_t id, siginfo_t *infop, int options)
+{
+#ifdef __NR_waitid
+ return INLINE_SYSCALL(waitid, 5, idtype, id, infop, options, NULL);
+#else
+ switch (idtype) {
+ case P_PID:
+ if (id <= 0)
+ goto invalid;
+ break;
+ case P_PGID:
+ if (id < 0 || id == 1)
+ goto invalid;
+ id = -id;
+ break;
+ case P_ALL:
+ id = -1;
+ break;
+ default:
+ invalid:
+ __set_errno(EINVAL);
+ return -1;
+ }
+
+ memset(infop, 0, sizeof *infop);
+ infop->si_pid = __NC(waitpid)(id, &infop->si_status, options
+# ifdef WEXITED
+ &~ WEXITED
+# endif
+ );
+ if (infop->si_pid < 0)
+ return infop->si_pid;
+ return 0;
+#endif
+}
+CANCELLABLE_SYSCALL(int, waitid, (idtype_t idtype, id_t id, siginfo_t *infop, int options),
+ (idtype, id, infop, options))
-_syscall4(int, waitid, idtype_t, idtype, id_t, id, siginfo_t*, infop, int, options);
#endif
diff --git a/libc/sysdeps/linux/common/waitpid.c b/libc/sysdeps/linux/common/waitpid.c
index c1766be6b..2309d5bb8 100644
--- a/libc/sysdeps/linux/common/waitpid.c
+++ b/libc/sysdeps/linux/common/waitpid.c
@@ -1,22 +1,21 @@
/* vi: set sw=4 ts=4: */
/*
+ * Copyright (C) 2006 Steven J. Hill <sjhill@realitydiluted.com>
* Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#include <stdlib.h>
-#include <sys/types.h>
#include <sys/wait.h>
-#include <sys/resource.h>
+#include <cancel.h>
-libc_hidden_proto(wait4)
-
-extern __typeof(waitpid) __libc_waitpid;
-__pid_t __libc_waitpid(__pid_t pid, int *wait_stat, int options)
+pid_t __NC(waitpid)(pid_t pid, int *wait_stat, int options)
{
- return wait4(pid, wait_stat, options, NULL);
+#if 1 /* kernel/exit.c says to avoid waitpid syscall */
+ return __wait4_nocancel(pid, wait_stat, options, NULL);
+#else
+ return INLINE_SYSCALL(waitpid, 3, pid, wait_stat, options);
+#endif
}
-libc_hidden_proto(waitpid)
-weak_alias(__libc_waitpid,waitpid)
-libc_hidden_weak(waitpid)
+CANCELLABLE_SYSCALL(pid_t, waitpid, (pid_t pid, int *wait_stat, int options), (pid, wait_stat, options))
+lt_libc_hidden(waitpid)
diff --git a/libc/sysdeps/linux/common/write.c b/libc/sysdeps/linux/common/write.c
index dbe5c12e6..e4d3ab897 100644
--- a/libc/sysdeps/linux/common/write.c
+++ b/libc/sysdeps/linux/common/write.c
@@ -9,15 +9,11 @@
#include <sys/syscall.h>
#include <unistd.h>
+#include <cancel.h>
-extern __typeof(write) __libc_write;
-#define __NR___libc_write __NR_write
-_syscall3(ssize_t, __libc_write, int, fd, const __ptr_t, buf, size_t, count);
-libc_hidden_proto(write)
-weak_alias(__libc_write,write)
-libc_hidden_weak(write)
-#if 0
-/* Stupid libgcc.a from gcc 2.95.x uses __write in pure.o
- * which is a blatent GNU libc-ism... */
-strong_alias(__libc_write,__write)
-#endif
+#define __NR___write_nocancel __NR_write
+_syscall3(ssize_t, __NC(write), int, fd, const void *, buf, size_t, count)
+
+CANCELLABLE_SYSCALL(ssize_t, write, (int fd, const void *buf, size_t count),
+ (fd, buf, count))
+lt_libc_hidden(write)
diff --git a/libc/sysdeps/linux/common/writev.c b/libc/sysdeps/linux/common/writev.c
index 377af312c..9b59228c3 100644
--- a/libc/sysdeps/linux/common/writev.c
+++ b/libc/sysdeps/linux/common/writev.c
@@ -9,10 +9,20 @@
#include <sys/syscall.h>
#include <sys/uio.h>
+#include <cancel.h>
-extern __typeof(writev) __libc_writev;
+/* We should deal with kernel which have a smaller UIO_FASTIOV as well
+ as a very big count. */
+static ssize_t __NC(writev)(int fd, const struct iovec *vector, int count)
+{
+ ssize_t bytes_written = INLINE_SYSCALL(writev, 3, fd, vector, count);
-#define __NR___libc_writev __NR_writev
-_syscall3(ssize_t, __libc_writev, int, filedes, const struct iovec *, vector,
- int, count);
-weak_alias(__libc_writev,writev)
+ if (bytes_written >= 0 || errno != EINVAL || count <= UIO_FASTIOV)
+ return bytes_written;
+
+ /* glibc tries again, but we do not. */
+ /* return __atomic_writev_replacement (fd, vector, count); */
+
+ return -1;
+}
+CANCELLABLE_SYSCALL(ssize_t, writev, (int fd, const struct iovec *vector, int count), (fd, vector, count))
diff --git a/libc/sysdeps/linux/common/xattr.c b/libc/sysdeps/linux/common/xattr.c
index 5b4c2f5bf..dea471ad6 100644
--- a/libc/sysdeps/linux/common/xattr.c
+++ b/libc/sysdeps/linux/common/xattr.c
@@ -28,137 +28,59 @@
/* sets */
#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;
-}
+ const void *, value, size_t, size, int, flags)
#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;
-}
+ const void *, value, size_t, size, int, flags)
#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;
-}
+ value, size_t, size, int, flags)
#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;
-}
+ void *, value, size_t, size)
#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;
-}
+ void *, value, size_t, size)
#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;
-}
+ value, size_t, size)
#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;
-}
+ size)
#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;
-}
+ size)
#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;
-}
+_syscall3(ssize_t, flistxattr, int, filedes, char *, list, size_t, size)
#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;
-}
+_syscall2(int, removexattr, const char *, path, const char *, name)
#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;
-}
+_syscall2(int, lremovexattr, const char *, path, const char *, name)
#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;
-}
+_syscall2(int, fremovexattr, int, filedes, const char *, name)
#endif
diff --git a/libc/sysdeps/linux/common/xstatconv.c b/libc/sysdeps/linux/common/xstatconv.c
index abcb496b8..a21579c41 100644
--- a/libc/sysdeps/linux/common/xstatconv.c
+++ b/libc/sysdeps/linux/common/xstatconv.c
@@ -13,21 +13,17 @@
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.
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>.
Modified for uClibc by Erik Andersen <andersen@codepoet.org>
*/
-#include <sys/syscall.h>
#include <sys/stat.h>
#include <string.h>
#include "xstatconv.h"
-/* Experimentally off - libc_hidden_proto(memset) */
-
-void attribute_hidden __xstat_conv(struct kernel_stat *kbuf, struct stat *buf)
+void __xstat_conv(struct kernel_stat *kbuf, struct stat *buf)
{
/* Convert to current kernel version of `struct stat'. */
memset(buf, 0x00, sizeof(*buf));
@@ -41,19 +37,39 @@ void attribute_hidden __xstat_conv(struct kernel_stat *kbuf, struct stat *buf)
buf->st_size = kbuf->st_size;
buf->st_blksize = kbuf->st_blksize;
buf->st_blocks = kbuf->st_blocks;
- buf->st_atime = kbuf->st_atime;
- buf->st_mtime = kbuf->st_mtime;
- buf->st_ctime = kbuf->st_ctime;
-#ifdef STAT_HAVE_NSEC
- buf->st_atimensec = kbuf->st_atime_nsec;
- buf->st_mtimensec = kbuf->st_mtime_nsec;
- buf->st_ctimensec = kbuf->st_ctime_nsec;
-#endif
+ buf->st_atim.tv_sec = kbuf->st_atim.tv_sec;
+ buf->st_atim.tv_nsec = kbuf->st_atim.tv_nsec;
+ buf->st_mtim.tv_sec = kbuf->st_mtim.tv_sec;
+ buf->st_mtim.tv_nsec = kbuf->st_mtim.tv_nsec;
+ buf->st_ctim.tv_sec = kbuf->st_ctim.tv_sec;
+ buf->st_ctim.tv_nsec = kbuf->st_ctim.tv_nsec;
+}
+
+void __xstat32_conv(struct kernel_stat64 *kbuf, struct stat *buf)
+{
+ /* Convert to current kernel version of `struct stat64'. */
+ memset(buf, 0x00, sizeof(*buf));
+ buf->st_dev = kbuf->st_dev;
+ buf->st_ino = kbuf->st_ino;
+ buf->st_mode = kbuf->st_mode;
+ buf->st_nlink = kbuf->st_nlink;
+ buf->st_uid = kbuf->st_uid;
+ buf->st_gid = kbuf->st_gid;
+ buf->st_rdev = kbuf->st_rdev;
+ buf->st_size = kbuf->st_size;
+ buf->st_blksize = kbuf->st_blksize;
+ buf->st_blocks = kbuf->st_blocks;
+ buf->st_atim.tv_sec = kbuf->st_atim.tv_sec;
+ buf->st_atim.tv_nsec = kbuf->st_atim.tv_nsec;
+ buf->st_mtim.tv_sec = kbuf->st_mtim.tv_sec;
+ buf->st_mtim.tv_nsec = kbuf->st_mtim.tv_nsec;
+ buf->st_ctim.tv_sec = kbuf->st_ctim.tv_sec;
+ buf->st_ctim.tv_nsec = kbuf->st_ctim.tv_nsec;
}
#ifdef __UCLIBC_HAS_LFS__
-void attribute_hidden __xstat64_conv(struct kernel_stat64 *kbuf, struct stat64 *buf)
+void __xstat64_conv(struct kernel_stat64 *kbuf, struct stat64 *buf)
{
/* Convert to current kernel version of `struct stat64'. */
memset(buf, 0x00, sizeof(*buf));
@@ -70,14 +86,12 @@ void attribute_hidden __xstat64_conv(struct kernel_stat64 *kbuf, struct stat64 *
buf->st_size = kbuf->st_size;
buf->st_blksize = kbuf->st_blksize;
buf->st_blocks = kbuf->st_blocks;
- buf->st_atime = kbuf->st_atime;
- buf->st_mtime = kbuf->st_mtime;
- buf->st_ctime = kbuf->st_ctime;
-# ifdef STAT_HAVE_NSEC
- buf->st_atimensec = kbuf->st_atime_nsec;
- buf->st_mtimensec = kbuf->st_mtime_nsec;
- buf->st_ctimensec = kbuf->st_ctime_nsec;
-# endif
+ buf->st_atim.tv_sec = kbuf->st_atim.tv_sec;
+ buf->st_atim.tv_nsec = kbuf->st_atim.tv_nsec;
+ buf->st_mtim.tv_sec = kbuf->st_mtim.tv_sec;
+ buf->st_mtim.tv_nsec = kbuf->st_mtim.tv_nsec;
+ buf->st_ctim.tv_sec = kbuf->st_ctim.tv_sec;
+ buf->st_ctim.tv_nsec = kbuf->st_ctim.tv_nsec;
}
#endif /* __UCLIBC_HAS_LFS__ */
diff --git a/libc/sysdeps/linux/common/xstatconv.h b/libc/sysdeps/linux/common/xstatconv.h
index 57c8bcbe2..cd4d7e9cf 100644
--- a/libc/sysdeps/linux/common/xstatconv.h
+++ b/libc/sysdeps/linux/common/xstatconv.h
@@ -13,9 +13,8 @@
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.
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>.
Modified for uClibc by Erik Andersen <andersen@codepoet.org>
*/
@@ -23,10 +22,14 @@
/* Pull in whatever this particular arch's kernel thinks the kernel version of
* struct stat should look like. It turns out that each arch has a different
* opinion on the subject, and different kernel revs use different names... */
+#include <features.h>
#include <bits/kernel_stat.h>
+#ifdef __ARCH_HAS_DEPRECATED_SYSCALLS__
extern void __xstat_conv(struct kernel_stat *kbuf, struct stat *buf) attribute_hidden;
+extern void __xstat32_conv(struct kernel_stat64 *kbuf, struct stat *buf) attribute_hidden;
#if defined __UCLIBC_HAS_LFS__
extern void __xstat64_conv(struct kernel_stat64 *kbuf, struct stat64 *buf) attribute_hidden;
#endif
+#endif
diff --git a/libc/sysdeps/linux/cris/Makefile.arch b/libc/sysdeps/linux/cris/Makefile.arch
index 850c83de5..178294215 100644
--- a/libc/sysdeps/linux/cris/Makefile.arch
+++ b/libc/sysdeps/linux/cris/Makefile.arch
@@ -5,11 +5,7 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-CSRC := __init_brk.c brk.c sbrk.c
+CSRC-y := __init_brk.c brk.c sbrk.c
-SSRC := setjmp.S __longjmp.S clone.S sysdep.S syscall.S
-ifeq ($(UNIFIED_SYSCALL),y)
-SSRC += __uClibc_syscall.S
-endif
-
-include $(top_srcdir)libc/sysdeps/linux/Makefile.commonarch
+SSRC-y := setjmp.S __longjmp.S clone.S sysdep.S syscall.S vfork.S
+SSRC-$(UNIFIED_SYSCALL) += __uClibc_syscall.S
diff --git a/libc/sysdeps/linux/cris/__longjmp.S b/libc/sysdeps/linux/cris/__longjmp.S
index 52a986fd9..196fdfd1f 100644
--- a/libc/sysdeps/linux/cris/__longjmp.S
+++ b/libc/sysdeps/linux/cris/__longjmp.S
@@ -14,14 +14,9 @@
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. */
+ see <http://www.gnu.org/licenses/>. */
-#include <features.h>
#include "sysdep.h"
-#define _SETJMP_H
-#define _ASM
-#include <bits/setjmp.h>
.syntax no_register_prefix
diff --git a/libc/sysdeps/linux/cris/bits/byteswap.h b/libc/sysdeps/linux/cris/bits/byteswap.h
index 4027456ac..a82f9c098 100644
--- a/libc/sysdeps/linux/cris/bits/byteswap.h
+++ b/libc/sysdeps/linux/cris/bits/byteswap.h
@@ -1,83 +1,20 @@
-#ifndef _BITS_BYTESWAP_H
-#define _BITS_BYTESWAP_H 1
+#ifndef _ASM_BITS_BYTESWAP_H
+#define _ASM_BITS_BYTESWAP_H 1
/* CRIS specific byte swap operations: 16, 32 and 64-bit */
-/* Swap bytes in 16 bit value. */
-#define __bswap_constant_16(x) \
-({ \
- unsigned short __x = (x); \
- ((unsigned short)( \
- (((unsigned short)(__x) & (unsigned short)0x00ffu) << 8) | \
- (((unsigned short)(__x) & (unsigned short)0xff00u) >> 8) )); \
-})
-
-#if defined __GNUC__ && __GNUC__ >= 2
-# define __bswap_16(x) \
+#define __bswap_non_constant_16(x) \
__extension__ \
({ unsigned short __bswap_16_v; \
- if (__builtin_constant_p (x)) \
- __bswap_16_v = __bswap_constant_16 (x); \
- else \
- __asm__ ("swapb %0" : "=r" (__bswap_16_v) : "0" (x)); \
+ __asm__ ("swapb %0" : "=r" (__bswap_16_v) : "0" (x)); \
__bswap_16_v; })
-#else
-# define __bswap_16(x) __bswap_constant_16 (x)
-#endif
-
-
-/* Swap bytes in 32 bit value. */
-#define __bswap_constant_32(x) \
-({ \
- unsigned long __x = (x); \
- ((unsigned long)( \
- (((unsigned long)(__x) & (unsigned long)0x000000fful) << 24) | \
- (((unsigned long)(__x) & (unsigned long)0x0000ff00ul) << 8) | \
- (((unsigned long)(__x) & (unsigned long)0x00ff0000ul) >> 8) | \
- (((unsigned long)(__x) & (unsigned long)0xff000000ul) >> 24) )); \
-})
-#if defined __GNUC__ && __GNUC__ >= 2
-# define __bswap_32(x) \
+#define __bswap_non_constant_32(x) \
__extension__ \
- ({ unsigned long __bswap_32_v; \
- if (__builtin_constant_p (x)) \
- __bswap_32_v = __bswap_constant_32 (x); \
- else \
- __asm__ ("swapwb %0" : "=r" (__bswap_32_v) : "0" (x)); \
+ ({ unsigned int __bswap_32_v; \
+ __asm__ ("swapwb %0" : "=r" (__bswap_32_v) : "0" (x)); \
__bswap_32_v; })
-#else
-# define __bswap_32(x) __bswap_constant_32 (x)
-#endif
-
-
-/* Swap bytes in 64 bit value. */
-# define __bswap_constant_64(x) \
- ((((x) & 0xff00000000000000ull) >> 56) \
- | (((x) & 0x00ff000000000000ull) >> 40) \
- | (((x) & 0x0000ff0000000000ull) >> 24) \
- | (((x) & 0x000000ff00000000ull) >> 8) \
- | (((x) & 0x00000000ff000000ull) << 8) \
- | (((x) & 0x0000000000ff0000ull) << 24) \
- | (((x) & 0x000000000000ff00ull) << 40) \
- | (((x) & 0x00000000000000ffull) << 56))
-#if defined __GNUC__ && __GNUC__ >= 2
-# define __bswap_64(x) \
- (__extension__ \
- ({ union { __extension__ unsigned long long int __ll; \
- unsigned int __l[2]; } __w, __r; \
- if (__builtin_constant_p (x)) \
- __r.__ll = __bswap_constant_64 (x); \
- else \
- { \
- __w.__ll = (x); \
- __r.__l[0] = __bswap_32 (__w.__l[1]); \
- __r.__l[1] = __bswap_32 (__w.__l[0]); \
- } \
- __r.__ll; }))
-#else
-# define __bswap_64(x) __bswap_constant_64 (x)
#endif
-#endif /* _BITS_BYTESWAP_H */
+#include <bits/byteswap-common.h>
diff --git a/libc/sysdeps/linux/cris/bits/fcntl.h b/libc/sysdeps/linux/cris/bits/fcntl.h
index 2637a6b63..b6a755be1 100644
--- a/libc/sysdeps/linux/cris/bits/fcntl.h
+++ b/libc/sysdeps/linux/cris/bits/fcntl.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FCNTL_H
# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
@@ -50,6 +49,8 @@
# define O_DIRECTORY 0200000 /* Must be a directory. */
# define O_NOFOLLOW 0400000 /* Do not follow links. */
# define O_NOATIME 01000000 /* Do not set atime. */
+# define O_CLOEXEC 02000000 /* set close_on_exec */
+# define O_PATH 010000000 /* Resolve pathname but do not open file. */
#endif
/* For now Linux has synchronisity options for data and read operations.
@@ -99,6 +100,8 @@
# define F_NOTIFY 1026 /* Request notfications on a directory. */
# define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with
close-on-exit set on new fd. */
+# define F_SETPIPE_SZ 1031 /* Set pipe page size array. */
+# define F_GETPIPE_SZ 1032 /* Get pipe page size array. */
#endif
/* For F_[GET|SET]FL. */
@@ -186,7 +189,7 @@ struct flock64
#endif
-#ifdef __USE_GNU
+#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
@@ -209,7 +212,7 @@ struct flock64
__BEGIN_DECLS
-#ifdef __USE_GNU
+#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)
diff --git a/libc/sysdeps/linux/cris/bits/kernel_stat.h b/libc/sysdeps/linux/cris/bits/kernel_stat.h
index 50202e542..619f35e9e 100644
--- a/libc/sysdeps/linux/cris/bits/kernel_stat.h
+++ b/libc/sysdeps/linux/cris/bits/kernel_stat.h
@@ -1,25 +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
-
-struct __old_kernel_stat {
- unsigned short st_dev;
- unsigned short st_ino;
- unsigned short st_mode;
- unsigned short st_nlink;
- unsigned short st_uid;
- unsigned short st_gid;
- unsigned short st_rdev;
- unsigned long st_size;
- unsigned long st_atime;
- unsigned long st_mtime;
- unsigned long st_ctime;
-};
+#ifndef _BITS_STAT_STRUCT_H
+#define _BITS_STAT_STRUCT_H
struct kernel_stat {
unsigned short st_dev;
@@ -34,12 +16,9 @@ struct kernel_stat {
unsigned long st_size;
unsigned long st_blksize;
unsigned long st_blocks;
- unsigned long st_atime;
- unsigned long __unused1;
- unsigned long st_mtime;
- unsigned long __unused2;
- unsigned long st_ctime;
- unsigned long __unused3;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
unsigned long __unused4;
unsigned long __unused5;
};
@@ -69,14 +48,9 @@ struct kernel_stat64 {
unsigned long st_blocks; /* Number 512-byte blocks allocated. */
unsigned long __pad4; /* future possible st_blocks high bits */
- unsigned long st_atime;
- unsigned long __pad5;
-
- unsigned long st_mtime;
- unsigned long __pad6;
-
- unsigned long st_ctime;
- unsigned long __pad7; /* will be high 32 bits of ctime someday */
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
unsigned long long st_ino;
};
diff --git a/libc/sysdeps/linux/cris/bits/kernel_types.h b/libc/sysdeps/linux/cris/bits/kernel_types.h
index f122c7f57..5d31f7b6a 100644
--- a/libc/sysdeps/linux/cris/bits/kernel_types.h
+++ b/libc/sysdeps/linux/cris/bits/kernel_types.h
@@ -28,6 +28,8 @@ typedef unsigned int __kernel_gid32_t;
typedef unsigned short __kernel_old_uid_t;
typedef unsigned short __kernel_old_gid_t;
typedef __kernel_dev_t __kernel_old_dev_t;
+typedef long __kernel_long_t;
+typedef unsigned long __kernel_ulong_t;
#ifdef __GNUC__
typedef long long __kernel_loff_t;
diff --git a/libc/sysdeps/linux/cris/bits/mathcalls.h b/libc/sysdeps/linux/cris/bits/mathcalls.h
deleted file mode 100644
index c1181f737..000000000
--- a/libc/sysdeps/linux/cris/bits/mathcalls.h
+++ /dev/null
@@ -1,333 +0,0 @@
-/* Prototype declarations for math functions; helper file for <math.h>.
- Copyright (C) 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. */
-
-/* NOTE: Because of the special way this file is used by <math.h>, this
- file must NOT be protected from multiple inclusion as header files
- usually are.
-
- This file provides prototype declarations for the math functions.
- Most functions are declared using the macro:
-
- __MATHCALL (NAME,[_r], (ARGS...));
-
- This means there is a function `NAME' returning `double' and a function
- `NAMEf' returning `float'. Each place `_Mdouble_' appears in the
- prototype, that is actually `double' in the prototype for `NAME' and
- `float' in the prototype for `NAMEf'. Reentrant variant functions are
- called `NAME_r' and `NAMEf_r'.
-
- Functions returning other types like `int' are declared using the macro:
-
- __MATHDECL (TYPE, NAME,[_r], (ARGS...));
-
- This is just like __MATHCALL but for a function returning `TYPE'
- instead of `_Mdouble_'. In all of these cases, there is still
- both a `NAME' and a `NAMEf' that takes `float' arguments.
-
- Note that there must be no whitespace before the argument passed for
- NAME, to make token pasting work with -traditional. */
-
-#ifndef _MATH_H
- #error "Never include <bits/mathcalls.h> directly; include <math.h> instead."
-#endif
-
-
-/* Trigonometric functions. */
-
-/* Arc cosine of X. */
-__MATHCALL (acos,, (_Mdouble_ __x));
-/* Arc sine of X. */
-__MATHCALL (asin,, (_Mdouble_ __x));
-/* Arc tangent of X. */
-__MATHCALL (atan,, (_Mdouble_ __x));
-/* Arc tangent of Y/X. */
-__MATHCALL (atan2,, (_Mdouble_ __y, _Mdouble_ __x));
-
-/* Cosine of X. */
-__MATHCALL (cos,, (_Mdouble_ __x));
-/* Sine of X. */
-__MATHCALL (sin,, (_Mdouble_ __x));
-/* Tangent of X. */
-__MATHCALL (tan,, (_Mdouble_ __x));
-
-#ifdef __USE_GNU
-/* Cosine and sine of X. */
-__MATHDECL (void,sincos,,
- (_Mdouble_ __x, _Mdouble_ *__sinx, _Mdouble_ *__cosx));
-#endif
-
-/* Hyperbolic functions. */
-
-/* Hyperbolic cosine of X. */
-__MATHCALL (cosh,, (_Mdouble_ __x));
-/* Hyperbolic sine of X. */
-__MATHCALL (sinh,, (_Mdouble_ __x));
-/* Hyperbolic tangent of X. */
-__MATHCALL (tanh,, (_Mdouble_ __x));
-
-#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
-/* Hyperbolic arc cosine of X. */
-__MATHCALL (acosh,, (_Mdouble_ __x));
-/* Hyperbolic arc sine of X. */
-__MATHCALL (asinh,, (_Mdouble_ __x));
-/* Hyperbolic arc tangent of X. */
-__MATHCALL (atanh,, (_Mdouble_ __x));
-#endif
-
-/* Exponential and logarithmic functions. */
-
-/* Exponential function of X. */
-__MATHCALL (exp,, (_Mdouble_ __x));
-
-#ifdef __USE_GNU
-/* A function missing in all standards: compute exponent to base ten. */
-__MATHCALL (exp10,, (_Mdouble_ __x));
-/* Another name occasionally used. */
-__MATHCALL (pow10,, (_Mdouble_ __x));
-#endif
-
-/* Break VALUE into a normalized fraction and an integral power of 2. */
-__MATHCALL (frexp,, (_Mdouble_ __x, int *__exponent));
-
-/* X times (two to the EXP power). */
-__MATHCALL (ldexp,, (_Mdouble_ __x, int __exponent));
-
-/* Natural logarithm of X. */
-__MATHCALL (log,, (_Mdouble_ __x));
-
-/* Base-ten logarithm of X. */
-__MATHCALL (log10,, (_Mdouble_ __x));
-
-/* Break VALUE into integral and fractional parts. */
-__MATHCALL (modf,, (_Mdouble_ __x, _Mdouble_ *__iptr));
-
-#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
-/* Return exp(X) - 1. */
-__MATHCALL (expm1,, (_Mdouble_ __x));
-
-/* Return log(1 + X). */
-__MATHCALL (log1p,, (_Mdouble_ __x));
-
-/* Return the base 2 signed integral exponent of X. */
-__MATHCALL (logb,, (_Mdouble_ __x));
-#endif
-
-#ifdef __USE_ISOC99
-/* Compute base-2 exponential of X. */
-__MATHCALL (exp2,, (_Mdouble_ __x));
-
-/* Compute base-2 logarithm of X. */
-__MATHCALL (log2,, (_Mdouble_ __x));
-#endif
-
-
-/* Power functions. */
-
-/* Return X to the Y power. */
-__MATHCALL (pow,, (_Mdouble_ __x, _Mdouble_ __y));
-
-/* Return the square root of X. */
-__MATHCALL (sqrt,, (_Mdouble_ __x));
-
-#if defined __USE_MISC || defined __USE_XOPEN || defined __USE_ISOC99
-/* Return `sqrt(X*X + Y*Y)'. */
-__MATHCALL (hypot,, (_Mdouble_ __x, _Mdouble_ __y));
-#endif
-
-#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
-/* Return the cube root of X. */
-__MATHCALL (cbrt,, (_Mdouble_ __x));
-#endif
-
-
-/* Nearest integer, absolute value, and remainder functions. */
-
-/* Smallest integral value not less than X. */
-__MATHCALL (ceil,, (_Mdouble_ __x));
-
-/* Absolute value of X. */
-__MATHCALLX (fabs,, (_Mdouble_ __x), (__const__));
-
-/* Largest integer not greater than X. */
-__MATHCALL (floor,, (_Mdouble_ __x));
-
-/* Floating-point modulo remainder of X/Y. */
-__MATHCALL (fmod,, (_Mdouble_ __x, _Mdouble_ __y));
-
-
-/* Return 0 if VALUE is finite or NaN, +1 if it
- is +Infinity, -1 if it is -Infinity. */
-__MATHDECL_1 (int,__isinf,, (_Mdouble_ __value)) __attribute__ ((__const__));
-
-/* Return nonzero if VALUE is finite and not NaN. */
-__MATHDECL_1 (int,__finite,, (_Mdouble_ __value)) __attribute__ ((__const__));
-
-#ifdef __USE_MISC
-/* Return 0 if VALUE is finite or NaN, +1 if it
- is +Infinity, -1 if it is -Infinity. */
-__MATHDECL_1 (int,isinf,, (_Mdouble_ __value)) __attribute__ ((__const__));
-
-/* Return nonzero if VALUE is finite and not NaN. */
-__MATHDECL_1 (int,finite,, (_Mdouble_ __value)) __attribute__ ((__const__));
-
-/* Return the remainder of X/Y. */
-__MATHCALL (drem,, (_Mdouble_ __x, _Mdouble_ __y));
-
-
-/* Return the fractional part of X after dividing out `ilogb (X)'. */
-__MATHCALL (significand,, (_Mdouble_ __x));
-#endif /* Use misc. */
-
-#if defined __USE_MISC || defined __USE_ISOC99
-/* Return X with its signed changed to Y's. */
-__MATHCALLX (copysign,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
-#endif
-
-#ifdef __USE_ISOC99
-/* Return representation of NaN for double type. */
-__MATHCALLX (nan,, (__const char *__tagb), (__const__));
-#endif
-
-
-/* Return nonzero if VALUE is not a number. */
-__MATHDECL_1 (int,__isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
-
-#if defined __USE_MISC || defined __USE_XOPEN
-/* Return nonzero if VALUE is not a number. */
-__MATHDECL_1 (int,isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
-
-/* Bessel functions. */
-__MATHCALL (j0,, (_Mdouble_));
-__MATHCALL (j1,, (_Mdouble_));
-__MATHCALL (jn,, (int, _Mdouble_));
-__MATHCALL (y0,, (_Mdouble_));
-__MATHCALL (y1,, (_Mdouble_));
-__MATHCALL (yn,, (int, _Mdouble_));
-#endif
-
-
-#if defined __USE_MISC || defined __USE_XOPEN || defined __USE_ISOC99
-/* Error and gamma functions. */
-__MATHCALL (erf,, (_Mdouble_));
-__MATHCALL (erfc,, (_Mdouble_));
-__MATHCALL (lgamma,, (_Mdouble_));
-#endif
-
-#ifdef __USE_ISOC99
-__MATHCALL (tgamma,, (_Mdouble_));
-#endif
-
-#if defined __USE_MISC || defined __USE_XOPEN
-/* Obsolete alias for `lgamma'. */
-__MATHCALL (gamma,, (_Mdouble_));
-#endif
-
-#ifdef __USE_MISC
-/* Reentrant version of lgamma. This function uses the global variable
- `signgam'. The reentrant version instead takes a pointer and stores
- the value through it. */
-__MATHCALL (lgamma,_r, (_Mdouble_, int *__signgamp));
-#endif
-
-
-#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
-/* Return the integer nearest X in the direction of the
- prevailing rounding mode. */
-__MATHCALL (rint,, (_Mdouble_ __x));
-
-/* Return X + epsilon if X < Y, X - epsilon if X > Y. */
-__MATHCALLX (nextafter,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
-# ifdef __USE_ISOC99
-__MATHCALLX (nexttoward,, (_Mdouble_ __x, long double __y), (__const__));
-# endif
-
-/* Return the remainder of integer divison X / Y with infinite precision. */
-__MATHCALL (remainder,, (_Mdouble_ __x, _Mdouble_ __y));
-
-# if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
-/* Return X times (2 to the Nth power). */
-__MATHCALL (scalb,, (_Mdouble_ __x, _Mdouble_ __n));
-# endif
-
-# if defined __USE_MISC || defined __USE_ISOC99
-/* Return X times (2 to the Nth power). */
-__MATHCALL (scalbn,, (_Mdouble_ __x, int __n));
-# endif
-
-/* Return the binary exponent of X, which must be nonzero. */
-__MATHDECL (int,ilogb,, (_Mdouble_ __x));
-#endif
-
-#ifdef __USE_ISOC99
-/* Return X times (2 to the Nth power). */
-__MATHCALL (scalbln,, (_Mdouble_ __x, long int __n));
-
-/* Round X to integral value in floating-point format using current
- rounding direction, but do not raise inexact exception. */
-__MATHCALL (nearbyint,, (_Mdouble_ __x));
-
-/* Round X to nearest integral value, rounding halfway cases away from
- zero. */
-__MATHCALL (round,, (_Mdouble_ __x));
-
-/* Round X to the integral value in floating-point format nearest but
- not larger in magnitude. */
-__MATHCALLX (trunc,, (_Mdouble_ __x), (__const__));
-
-/* Compute remainder of X and Y and put in *QUO a value with sign of x/y
- and magnitude congruent `mod 2^n' to the magnitude of the integral
- quotient x/y, with n >= 3. */
-__MATHCALL (remquo,, (_Mdouble_ __x, _Mdouble_ __y, int *__quo));
-
-
-/* Conversion functions. */
-
-/* Round X to nearest integral value according to current rounding
- direction. */
-__MATHDECL (long int,lrint,, (_Mdouble_ __x));
-__MATHDECL (long long int,llrint,, (_Mdouble_ __x));
-
-/* Round X to nearest integral value, rounding halfway cases away from
- zero. */
-__MATHDECL (long int,lround,, (_Mdouble_ __x));
-__MATHDECL (long long int,llround,, (_Mdouble_ __x));
-
-
-/* Return positive difference between X and Y. */
-__MATHCALL (fdim,, (_Mdouble_ __x, _Mdouble_ __y));
-
-/* Return maximum numeric value from X and Y. */
-__MATHCALL (fmax,, (_Mdouble_ __x, _Mdouble_ __y));
-
-/* Return minimum numeric value from X and Y. */
-__MATHCALL (fmin,, (_Mdouble_ __x, _Mdouble_ __y));
-
-
-/* Classify given number. */
-__MATHDECL_1 (int, __fpclassify,, (_Mdouble_ __value))
- __attribute__ ((__const__));
-
-/* Test for negative number. */
-__MATHDECL_1 (int, __signbit,, (_Mdouble_ __value))
- __attribute__ ((__const__));
-
-
-/* Multiply-add function computed as a ternary operation. */
-__MATHCALL (fma,, (_Mdouble_ __x, _Mdouble_ __y, _Mdouble_ __z));
-#endif /* Use ISO C99. */
diff --git a/libc/sysdeps/linux/cris/bits/mman.h b/libc/sysdeps/linux/cris/bits/mman.h
deleted file mode 100644
index ec9d2a558..000000000
--- a/libc/sysdeps/linux/cris/bits/mman.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* Definitions for POSIX memory map interface. Linux/CRIS version.
- Copyright (C) 1997, 2000, 2001, 2003 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_MMAN_H
-# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
-#endif
-
-/* The following definitions basically come from the kernel headers.
- But the kernel header is not namespace clean. */
-
-
-/* Protections are chosen from these bits, OR'd together. The
- implementation does not necessarily support PROT_EXEC or PROT_WRITE
- without PROT_READ. The only guarantees are that no writing will be
- allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
-
-#define PROT_READ 0x1 /* Page can be read. */
-#define PROT_WRITE 0x2 /* Page can be written. */
-#define PROT_EXEC 0x4 /* Page can be executed. */
-#define PROT_NONE 0x0 /* Page can not be accessed. */
-#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of
- growsdown vma (mprotect only). */
-#define PROT_GROWSUP 0x02000000 /* Extend change to start of
- growsup vma (mprotect only). */
-
-/* Sharing types (must choose one and only one of these). */
-#define MAP_SHARED 0x01 /* Share changes. */
-#define MAP_PRIVATE 0x02 /* Changes are private. */
-#ifdef __USE_MISC
-# define MAP_TYPE 0x0f /* Mask for type of mapping. */
-#endif
-
-/* Other flags. */
-#define MAP_FIXED 0x10 /* Interpret addr exactly. */
-#ifdef __USE_MISC
-# define MAP_FILE 0
-# define MAP_ANONYMOUS 0x20 /* Don't use a file. */
-# define MAP_ANON MAP_ANONYMOUS
-#endif
-
-/* These are Linux-specific. */
-#ifdef __USE_MISC
-# define MAP_GROWSDOWN 0x0100 /* Stack-like segment. */
-# define MAP_DENYWRITE 0x0800 /* ETXTBSY */
-# define MAP_EXECUTABLE 0x1000 /* Mark it as an executable. */
-# define MAP_LOCKED 0x2000 /* Lock the mapping. */
-# define MAP_NORESERVE 0x4000 /* Don't check for reservations. */
-#endif
-
-/* Flags to `msync'. */
-#define MS_ASYNC 1 /* Sync memory asynchronously. */
-#define MS_SYNC 4 /* Synchronous memory sync. */
-#define MS_INVALIDATE 2 /* Invalidate the caches. */
-
-/* Flags for `mlockall'. */
-#define MCL_CURRENT 1 /* Lock all currently mapped pages. */
-#define MCL_FUTURE 2 /* Lock all additions to address
- space. */
-
-/* Flags for `mremap'. */
-#ifdef __USE_GNU
-# define MREMAP_MAYMOVE 1
-# define MREMAP_FIXED 2
-#endif
-
-/* Advice to `madvise'. */
-#ifdef __USE_BSD
-# define MADV_NORMAL 0 /* No further special treatment. */
-# define MADV_RANDOM 1 /* Expect random page references. */
-# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
-# define MADV_WILLNEED 3 /* Will need these pages. */
-# define MADV_DONTNEED 4 /* Don't need these pages. */
-#endif
-
-/* The POSIX people had to invent similar names for the same things. */
-#ifdef __USE_XOPEN2K
-# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
-# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
-# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
-# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
-# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
-#endif
diff --git a/libc/sysdeps/linux/cris/bits/setjmp.h b/libc/sysdeps/linux/cris/bits/setjmp.h
index 2a29c8ca9..e9fcec184 100644
--- a/libc/sysdeps/linux/cris/bits/setjmp.h
+++ b/libc/sysdeps/linux/cris/bits/setjmp.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1998, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -12,11 +12,10 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
-/* Define the machine-dependent type `jmp_buf'. CRIS version. */
+/* Define the machine-dependent type `jmp_buf', CRIS version. */
#ifndef _BITS_SETJMP_H
#define _BITS_SETJMP_H 1
@@ -24,10 +23,8 @@
# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
#endif
-/*
- Note that we save and restore CCR to be able to
- correctly handle DI/EI. Note also that the "move x,ccr" does NOT affect
- the DMA enable bits (E and D).
+/* Note that saving and restoring CCR has no meaning in user mode, so we
+ don't actually do it; the slot is now reserved.
jmp_buf[0] - PC
jmp_buf[1] - SP (R14)
@@ -46,21 +43,8 @@
jmp_buf[14] - R1
jmp_buf[15] - R0
jmp_buf[16] - SRP
- jmp_buf[17] - CCR
- */
+ jmp_buf[17] - CCR */
-#define _JBLEN 18
-#if defined (__USE_MISC) || defined (_ASM)
-#define JB_SP 1
-#endif
-
-#ifndef _ASM
-typedef int __jmp_buf[_JBLEN];
-#endif
-
-/* Test if longjmp to JMPBUF would unwind the frame
- containing a local variable at ADDRESS. */
-#define _JMPBUF_UNWINDS(jmpbuf, address) \
- ((void *) (address) < (void *) (jmpbuf)[JB_SP])
+typedef int __jmp_buf[18];
#endif /* bits/setjmp.h */
diff --git a/libc/sysdeps/linux/cris/bits/stackinfo.h b/libc/sysdeps/linux/cris/bits/stackinfo.h
index 43c944834..6b36cafd6 100644
--- a/libc/sysdeps/linux/cris/bits/stackinfo.h
+++ b/libc/sysdeps/linux/cris/bits/stackinfo.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* This file contains a bit of information about the stack allocation
of the processor. */
diff --git a/libc/sysdeps/linux/cris/bits/syscalls.h b/libc/sysdeps/linux/cris/bits/syscalls.h
index 93e7cf2d9..cb2f41cf7 100644
--- a/libc/sysdeps/linux/cris/bits/syscalls.h
+++ b/libc/sysdeps/linux/cris/bits/syscalls.h
@@ -7,85 +7,22 @@
#ifndef __ASSEMBLER__
-#include <errno.h>
-
-#define SYS_ify(syscall_name) (__NR_##syscall_name)
-
-#undef _syscall0
-#define _syscall0(type,name) \
-type name(void) \
-{ \
-return (type) (INLINE_SYSCALL(name, 0)); \
-}
-
-#undef _syscall1
-#define _syscall1(type,name,type1,arg1) \
-type name(type1 arg1) \
-{ \
-return (type) (INLINE_SYSCALL(name, 1, arg1)); \
-}
-
-#undef _syscall2
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name(type1 arg1,type2 arg2) \
-{ \
-return (type) (INLINE_SYSCALL(name, 2, arg1, arg2)); \
-}
-
-#undef _syscall3
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name(type1 arg1,type2 arg2,type3 arg3) \
-{ \
-return (type) (INLINE_SYSCALL(name, 3, arg1, arg2, arg3)); \
-}
-
-#undef _syscall4
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
-{ \
-return (type) (INLINE_SYSCALL(name, 4, arg1, arg2, arg3, arg4)); \
-}
-
-#undef _syscall5
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
- type5,arg5) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
-{ \
-return (type) (INLINE_SYSCALL(name, 5, arg1, arg2, arg3, arg4, arg5)); \
-}
-
-#undef _syscall6
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
- type5,arg5,type6,arg6) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
-{ \
-return (type) (INLINE_SYSCALL(name, 6, arg1, arg2, arg3, arg4, arg5, arg6)); \
-}
-
-#undef INLINE_SYSCALL
-#define INLINE_SYSCALL(name, nr, args...) \
+#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+(__extension__ \
({ \
- unsigned long __sys_res; \
register unsigned long __res __asm__ ("r10"); \
- LOAD_ARGS_c_##nr (args) \
+ LOAD_ARGS_c_##nr(args) \
register unsigned long __callno __asm__ ("r9") \
- = SYS_ify (name); \
+ = name; \
__asm__ __volatile__ (LOAD_ARGS_asm_##nr (args) \
CHECK_ARGS_asm_##nr \
"break 13" \
: "=r" (__res) \
: ASM_ARGS_##nr (args) \
: ASM_CLOBBER_##nr); \
- __sys_res = __res; \
- \
- if (__sys_res >= (unsigned long) -4096) \
- { \
- __set_errno (- __sys_res); \
- __sys_res = (unsigned long) -1; \
- } \
- __sys_res; \
- })
-
+ __res; \
+ }) \
+)
#define LOAD_ARGS_c_0()
#define LOAD_ARGS_asm_0()
#define ASM_CLOBBER_0 "memory"
diff --git a/libc/sysdeps/linux/cris/bits/termios.h b/libc/sysdeps/linux/cris/bits/termios.h
index 63ca4ea93..22b59db3c 100644
--- a/libc/sysdeps/linux/cris/bits/termios.h
+++ b/libc/sysdeps/linux/cris/bits/termios.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _TERMIOS_H
# error "Never include <bits/termios.h> directly; use <termios.h> instead."
diff --git a/libc/sysdeps/linux/cris/bits/uClibc_arch_features.h b/libc/sysdeps/linux/cris/bits/uClibc_arch_features.h
index bdd338792..517f68cd6 100644
--- a/libc/sysdeps/linux/cris/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/cris/bits/uClibc_arch_features.h
@@ -12,31 +12,31 @@
/* can your target use syscall6() for mmap ? */
#undef __UCLIBC_MMAP_HAS_6_ARGS__
-/* does your target use syscall4() for truncate64 ? (32bit arches only) */
-#undef __UCLIBC_TRUNCATE64_HAS_4_ARGS__
+/* does your target align 64bit values in register pairs ? (32bit arches only) */
+#undef __UCLIBC_SYSCALL_ALIGN_64BIT__
/* does your target have a broken create_module() ? */
#define __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__
-/* lovely */
+/* only weird assemblers generally need this */
#define __UCLIBC_ASM_LINE_SEP__ @
#endif /* _BITS_UCLIBC_ARCH_FEATURES_H */
diff --git a/libc/sysdeps/linux/cris/bits/uClibc_page.h b/libc/sysdeps/linux/cris/bits/uClibc_page.h
index adfc3c9af..2818b333c 100644
--- a/libc/sysdeps/linux/cris/bits/uClibc_page.h
+++ b/libc/sysdeps/linux/cris/bits/uClibc_page.h
@@ -11,8 +11,8 @@
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * License along with this library; if not, see
+ * <http://www.gnu.org/licenses/>.
*/
/* Supply an architecture specific value for PAGE_SIZE and friends. */
diff --git a/libc/sysdeps/linux/cris/bits/wordsize.h b/libc/sysdeps/linux/cris/bits/wordsize.h
index d6a2fc685..0f7882f88 100644
--- a/libc/sysdeps/linux/cris/bits/wordsize.h
+++ b/libc/sysdeps/linux/cris/bits/wordsize.h
@@ -13,7 +13,6 @@
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. */
+ see <http://www.gnu.org/licenses/>. */
#define __WORDSIZE 32
diff --git a/libc/sysdeps/linux/cris/brk.c b/libc/sysdeps/linux/cris/brk.c
index ae99e109c..6c877bb9a 100644
--- a/libc/sysdeps/linux/cris/brk.c
+++ b/libc/sysdeps/linux/cris/brk.c
@@ -12,7 +12,6 @@
extern void * __curbrk attribute_hidden;
extern int __init_brk (void) attribute_hidden;
-libc_hidden_proto(brk)
int brk(void * end_data_seg)
{
if (__init_brk () == 0) {
diff --git a/libc/sysdeps/linux/cris/clone.S b/libc/sysdeps/linux/cris/clone.S
index 9e284fe0a..fabf69595 100644
--- a/libc/sysdeps/linux/cris/clone.S
+++ b/libc/sysdeps/linux/cris/clone.S
@@ -13,8 +13,7 @@
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. */
+ see <http://www.gnu.org/licenses/>. */
#include <features.h>
#include <sys/syscall.h>
diff --git a/libc/sysdeps/linux/cris/crti.S b/libc/sysdeps/linux/cris/crti.S
index 0740c765d..d9e1397da 100644
--- a/libc/sysdeps/linux/cris/crti.S
+++ b/libc/sysdeps/linux/cris/crti.S
@@ -10,8 +10,12 @@ _init:
move $srp,$r1
subq 4,$sp
move.d $r0,[$sp]
+#ifdef __arch_v32
+ lapc _GLOBAL_OFFSET_TABLE_,$r0
+#else
move.d $pc,$r0
sub.d .:GOTOFF,$r0
+#endif
.align 1
.section .fini
@@ -24,6 +28,10 @@ _fini:
move $srp,$r1
subq 4,$sp
move.d $r0,[$sp]
+#ifdef __arch_v32
+ lapc _GLOBAL_OFFSET_TABLE_,$r0
+#else
move.d $pc,$r0
sub.d .:GOTOFF,$r0
+#endif
.align 1
diff --git a/libc/sysdeps/linux/cris/crtn.S b/libc/sysdeps/linux/cris/crtn.S
index 951ae5449..7b2dce17c 100644
--- a/libc/sysdeps/linux/cris/crtn.S
+++ b/libc/sysdeps/linux/cris/crtn.S
@@ -9,7 +9,6 @@
move.d [$sp+],$r1
Ret
nop
- .size _init, .-_init
.section .fini
.align 1
@@ -20,4 +19,3 @@
move.d [$sp+],$r1
Ret
nop
- .size _fini, .-_fini
diff --git a/libc/sysdeps/linux/cris/fork.c b/libc/sysdeps/linux/cris/fork.c
deleted file mode 100644
index 20b546901..000000000
--- a/libc/sysdeps/linux/cris/fork.c
+++ /dev/null
@@ -1,19 +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.
- */
-
-#include "sysdep.h"
-
-#define __NR___libc_fork __NR_fork
-SYSCALL__ (__libc_fork, 0)
- /* R1 is now 0 for the parent and 1 for the child. Decrement it to
- make it -1 (all bits set) for the parent, and 0 (no bits set)
- for the child. Then AND it with R0, so the parent gets
- R0&-1==R0, and the child gets R0&0==0. */
- /* i dunno what the blurb above is useful for. we just return. */
-__asm__("ret\n\tnop");
-libc_hidden_proto(fork)
-weak_alias(__libc_fork,fork)
-libc_hidden_weak(fork)
diff --git a/libc/sysdeps/linux/cris/jmpbuf-offsets.h b/libc/sysdeps/linux/cris/jmpbuf-offsets.h
new file mode 100644
index 000000000..9a95acc1b
--- /dev/null
+++ b/libc/sysdeps/linux/cris/jmpbuf-offsets.h
@@ -0,0 +1,8 @@
+/* Private macros for accessing __jmp_buf contents. BFIN version. */
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define JB_SP 1
diff --git a/libc/sysdeps/linux/cris/jmpbuf-unwind.h b/libc/sysdeps/linux/cris/jmpbuf-unwind.h
new file mode 100644
index 000000000..8b75dce5c
--- /dev/null
+++ b/libc/sysdeps/linux/cris/jmpbuf-unwind.h
@@ -0,0 +1,12 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+#include <setjmp.h>
+#include <jmpbuf-offsets.h>
+
+/* Test if longjmp to JMPBUF would unwind the frame
+ containing a local variable at ADDRESS. */
+#define _JMPBUF_UNWINDS(jmpbuf, address) \
+ ((void *) (address) < (void *) (jmpbuf)[JB_SP])
diff --git a/libc/sysdeps/linux/cris/sbrk.c b/libc/sysdeps/linux/cris/sbrk.c
index 830d01dd6..fa04b20b0 100644
--- a/libc/sysdeps/linux/cris/sbrk.c
+++ b/libc/sysdeps/linux/cris/sbrk.c
@@ -13,7 +13,6 @@
extern void * __curbrk attribute_hidden;
extern int __init_brk (void) attribute_hidden;
-libc_hidden_proto(sbrk)
void *
sbrk(intptr_t increment)
{
diff --git a/libc/sysdeps/linux/cris/setjmp.S b/libc/sysdeps/linux/cris/setjmp.S
index e7bb6358a..69de07a1f 100644
--- a/libc/sysdeps/linux/cris/setjmp.S
+++ b/libc/sysdeps/linux/cris/setjmp.S
@@ -14,13 +14,9 @@
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. */
+ see <http://www.gnu.org/licenses/>. */
#include "sysdep.h"
-#define _SETJMP_H
-#define _ASM
-#include <bits/setjmp.h>
.syntax no_register_prefix
diff --git a/libc/sysdeps/linux/cris/sys/procfs.h b/libc/sysdeps/linux/cris/sys/procfs.h
index 072029bc8..65b57ba4e 100644
--- a/libc/sysdeps/linux/cris/sys/procfs.h
+++ b/libc/sysdeps/linux/cris/sys/procfs.h
@@ -13,8 +13,7 @@
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. */
+ see <http://www.gnu.org/licenses/>. */
#ifndef _SYS_PROCFS_H
#define _SYS_PROCFS_H 1
@@ -29,10 +28,14 @@
#include <sys/types.h>
#include <sys/ucontext.h>
#include <sys/user.h>
-#include <asm/elf.h>
__BEGIN_DECLS
+typedef unsigned long elf_greg_t;
+
+#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t))
+typedef elf_greg_t elf_gregset_t[ELF_NGREG];
+
struct elf_siginfo
{
int si_signo; /* Signal number. */
diff --git a/libc/sysdeps/linux/cris/sys/ucontext.h b/libc/sysdeps/linux/cris/sys/ucontext.h
index 5f875453f..2d99a95f9 100644
--- a/libc/sysdeps/linux/cris/sys/ucontext.h
+++ b/libc/sysdeps/linux/cris/sys/ucontext.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* System V/cris ABI compliant context switching support. */
diff --git a/libc/sysdeps/linux/cris/sys/user.h b/libc/sysdeps/linux/cris/sys/user.h
new file mode 100644
index 000000000..d629c30d7
--- /dev/null
+++ b/libc/sysdeps/linux/cris/sys/user.h
@@ -0,0 +1,81 @@
+#ifndef __ASM_CRIS_USER_H
+#define __ASM_CRIS_USER_H
+
+/* User-mode register used for core dumps. */
+
+struct user_fpregs {
+};
+
+struct user_regs_struct {
+ unsigned long r0; /* General registers. */
+ unsigned long r1;
+ unsigned long r2;
+ unsigned long r3;
+ unsigned long r4;
+ unsigned long r5;
+ unsigned long r6;
+ unsigned long r7;
+ unsigned long r8;
+ unsigned long r9;
+ unsigned long r10;
+ unsigned long r11;
+ unsigned long r12;
+ unsigned long r13;
+ unsigned long sp; /* R14, Stack pointer. */
+ unsigned long acr; /* R15, Address calculation register. */
+ unsigned long bz; /* P0, Constant zero (8-bits). */
+ unsigned long vr; /* P1, Version register (8-bits). */
+ unsigned long pid; /* P2, Process ID (8-bits). */
+ unsigned long srs; /* P3, Support register select (8-bits). */
+ unsigned long wz; /* P4, Constant zero (16-bits). */
+ unsigned long exs; /* P5, Exception status. */
+ unsigned long eda; /* P6, Exception data address. */
+ unsigned long mof; /* P7, Multiply overflow regiter. */
+ unsigned long dz; /* P8, Constant zero (32-bits). */
+ unsigned long ebp; /* P9, Exception base pointer. */
+ unsigned long erp; /* P10, Exception return pointer. */
+ unsigned long srp; /* P11, Subroutine return pointer. */
+ unsigned long nrp; /* P12, NMI return pointer. */
+ unsigned long ccs; /* P13, Condition code stack. */
+ unsigned long usp; /* P14, User mode stack pointer. */
+ unsigned long spc; /* P15, Single step PC. */
+};
+
+/*
+ * Core file format: The core file is written in such a way that gdb
+ * can understand it and provide useful information to the user (under
+ * linux we use the `trad-core' bfd). The file contents are as follows:
+ *
+ * upage: 1 page consisting of a user struct that tells gdb
+ * what is present in the file. Directly after this is a
+ * copy of the task_struct, which is currently not used by gdb,
+ * but it may come in handy at some point. All of the registers
+ * are stored as part of the upage. The upage should always be
+ * only one page long.
+ * data: The data segment follows next. We use current->end_text to
+ * current->brk to pick up all of the user variables, plus any memory
+ * that may have been sbrk'ed. No attempt is made to determine if a
+ * page is demand-zero or if a page is totally unused, we just cover
+ * the entire range. All of the addresses are rounded in such a way
+ * that an integral number of pages is written.
+ * stack: We need the stack information in order to get a meaningful
+ * backtrace. We need to write the data from usp to
+ * current->start_stack, so we round each of these in order to be able
+ * to write an integer number of pages.
+ */
+
+struct user {
+ struct user_regs_struct regs; /* entire machine state */
+ size_t u_tsize; /* text size (pages) */
+ size_t u_dsize; /* data size (pages) */
+ size_t u_ssize; /* stack size (pages) */
+ unsigned long start_code; /* text starting address */
+ unsigned long start_data; /* data starting address */
+ unsigned long start_stack; /* stack starting address */
+ long int signal; /* signal causing core dump */
+ unsigned long u_ar0; /* help gdb find registers */
+ unsigned long magic; /* identifies a core file */
+ char u_comm[32]; /* user command name */
+};
+
+#endif /* __ASM_CRIS_USER_H */
diff --git a/libc/sysdeps/linux/cris/syscall.S b/libc/sysdeps/linux/cris/syscall.S
index d4b052e8e..a81f31140 100644
--- a/libc/sysdeps/linux/cris/syscall.S
+++ b/libc/sysdeps/linux/cris/syscall.S
@@ -13,8 +13,7 @@
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. */
+ see <http://www.gnu.org/licenses/>. */
#include "sysdep.h"
diff --git a/libc/sysdeps/linux/cris/sysdep.S b/libc/sysdeps/linux/cris/sysdep.S
index 416751d65..a23bb260f 100644
--- a/libc/sysdeps/linux/cris/sysdep.S
+++ b/libc/sysdeps/linux/cris/sysdep.S
@@ -13,8 +13,7 @@
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. */
+ see <http://www.gnu.org/licenses/>. */
#include <features.h>
#include "sysdep.h"
@@ -36,7 +35,7 @@ ENTRY (__syscall_error)
/* Note that __syscall_error is only visible within this library,
and no-one passes it on as a pointer, so can assume that R0 (GOT
pointer) is correctly set up. */
- PLTCALL (HIDDEN_JUMPTARGET(__errno_location))
+ PLTCALL (__errno_location)
move [sp+],srp
move.d [sp+],r11
diff --git a/libc/sysdeps/linux/cris/sysdep.h b/libc/sysdeps/linux/cris/sysdep.h
index 593e7772e..cd21fc87d 100644
--- a/libc/sysdeps/linux/cris/sysdep.h
+++ b/libc/sysdeps/linux/cris/sysdep.h
@@ -14,12 +14,13 @@
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. */
+ see <http://www.gnu.org/licenses/>. */
#ifndef _SYSDEP_H_
#define _SYSDEP_H_
+#include <common/sysdep.h>
+
#ifndef C_LABEL
/* Define a macro we can use to construct the asm name for a C symbol. */
@@ -120,7 +121,15 @@
/* Define an entry point visible from C. */
#define ENTRY(name) \
.text @ \
- ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (name) @ \
+ .globl C_SYMBOL_NAME (name) @ \
+ ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME (name), function) @ \
+ .align ALIGNARG (2) @ \
+ C_LABEL(name)
+
+#define HIDDEN_ENTRY(name) \
+ .text @ \
+ .globl C_SYMBOL_NAME (name) @ \
+ .hidden C_SYMBOL_NAME (name) @ \
ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME (name), function) @ \
.align ALIGNARG (2) @ \
C_LABEL(name)
diff --git a/libc/sysdeps/linux/cris/vfork.S b/libc/sysdeps/linux/cris/vfork.S
new file mode 100644
index 000000000..964eca4c1
--- /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
+ */
+
+HIDDEN_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_def(vfork)
diff --git a/libc/sysdeps/linux/e1/Makefile b/libc/sysdeps/linux/e1/Makefile
deleted file mode 100644
index c69ccb9e2..000000000
--- a/libc/sysdeps/linux/e1/Makefile
+++ /dev/null
@@ -1,56 +0,0 @@
-# Makefile 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.
-
-TOPDIR=../../../../
-include $(TOPDIR)Rules.mak
-
-#FIXME -- this arch should include its own crti.S and crtn.S
-UCLIBC_CTOR_DTOR=n
-
-# If you're looking for vfork(), it is defined in include/unistd.h
-
-CRT_SRC := crt0.S
-CRT_OBJ := crt0.o
-CTOR_TARGETS := $(TOPDIR)lib/crti.o $(TOPDIR)lib/crtn.o
-
-# why is crt1.c listed in CSRC ?
-CSRC := crt1.c syscalls.c longjmp.c setjmp.c vfork.c
-OBJS := $(patsubst %.c,%.o, $(CSRC))
-
-OBJ_LIST := ../../../obj.sysdeps.$(TARGET_ARCH)
-
-all: $(OBJ_LIST) $(CTOR_TARGETS)
-
-$(OBJ_LIST): $(OBJS) $(CRT_OBJ)
- $(STRIPTOOL) -x -R .note -R .comment $^
- $(INSTALL) -d $(TOPDIR)lib/
- cp $(CRT_OBJ) $(TOPDIR)lib/
- echo $(patsubst %, sysdeps/linux/$(TARGET_ARCH)/%, $(OBJS)) > $@
-
-$(CRT_OBJ): %.o : %.S
- $(CC) $(ASFLAGS) -c $< -o $@
-
-$(OBJS): %.o : %.c
- $(CC) $(CFLAGS) -c $< -o $@
-
-ifeq ($(UCLIBC_CTOR_DTOR),y)
-$(TOPDIR)lib/crti.o: crti.S
- $(INSTALL) -d $(TOPDIR)lib/
- $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c $< -o $@
-
-$(TOPDIR)lib/crtn.o: crtn.S
- $(INSTALL) -d $(TOPDIR)lib/
- $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c $< -o $@
-else
-$(CTOR_TARGETS):
- $(INSTALL) -d $(TOPDIR)lib/
- $(AR) $(ARFLAGS) $@
-endif
-
-headers:
-
-clean:
- $(RM) *.o *~ core
diff --git a/libc/sysdeps/linux/e1/bits/endian.h b/libc/sysdeps/linux/e1/bits/endian.h
deleted file mode 100644
index 0d38c1caa..000000000
--- a/libc/sysdeps/linux/e1/bits/endian.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* e1 is big-endian. */
-
-#ifndef _ENDIAN_H
-# error "Never use <bits/endian.h> directly; include <endian.h> instead."
-#endif
-
-#define __BYTE_ORDER __BIG_ENDIAN
diff --git a/libc/sysdeps/linux/e1/bits/fenvinline.h b/libc/sysdeps/linux/e1/bits/fenvinline.h
deleted file mode 100644
index a16fc0fb2..000000000
--- a/libc/sysdeps/linux/e1/bits/fenvinline.h
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- Inline floating-point environment handling functions for Hyperstone e1-32X.
- Copyright (C) 2002-2003, George Thanos <george.thanos@gdt.gr>
- Yannis Mitsos <yannis.mitsos@gdt.gr>
-
- Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
-
- 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 __GNUC__ && !defined _SOFT_FLOAT && !defined __NO_MATH_INLINES
-
-/**********************************************************
- * --- A small description of the E1-16/32X FP unit. ---
- * FP exceptions can be enabled and disabled through
- * <feenableexcept>, <fedisableexcept>.
- *
- * - When an enabled exception takes place a SIGFPE signal
- * is sent to the process by the exception handler. User
- * can test for the exception that took place through
- * <fetestexcept>.
- * feraiseexcept works only for accrued exceptions.
- *
- * - When a disabld exception takes place it does not generate
- * a trap. The user can check if any exception took place after
- * an FP instruction by issuing an <fetestexcept> command.
- * User should first clear the G2 register by issuing an
- * <feclearexcept> function.
- * The following program is a typical example of how the user
- * should check for exceptions that did not generate a SIGFPE
- * signal :
- * {
- * double f;
- * int raised;
- * feclearexcept (FE_ALL_EXCEPT);
- * f = compute ();
- * raised = fetestexcept (FE_OVERFLOW | FE_INVALID);
- * if (raised & FE_OVERFLOW) { ... }
- * if (raised & FE_INVALID) { ... }
- * ...
- * }
- ***********************************************************/
-
-/* Get FPU rounding mode */
-#define fegetround() \
-({ \
- unsigned int tmp; \
- __asm__ __volatile__("mov %0, SR" \
- :"=l"(tmp) \
- :/*no input*/); \
- tmp &= (3<<13); \
- (tmp); \
-})
-
-/* Set FPU rounding mode */
-#define fesetround(round) \
-({ \
- unsigned int tmp = (3 << 13); \
- while(1) { \
- /* Clear SR.FRM field */ \
- __asm__ __volatile__("andn SR, %0" \
- :/*no output*/ \
- :"l"(tmp) ); \
- tmp &= round; \
- \
- if(tmp) { \
- tmp = -1; \
- break; \
- } \
- \
- __asm__ __volatile__("or SR, %0" \
- :/*no input*/ \
- :"l"(round) ); \
- tmp = 0; \
- break; \
- } \
- (tmp); \
-})
-
-/* The following functions test for accrued exceptions.
- * No trap is generated on an FP exception.
- */
-static __inline__ feclearexcept(int __excepts)
-{
- unsigned int enabled_excepts, disabled_excepts;
-
- /* Check that __excepts is correctly set */
- if( __excepts & (~0x1F00) )
- return -1;
-
- __asm__ __volatile__("mov %0, SR"
- :"=l"(enabled_excepts)
- :/*no input*/ );
-
- enabled_excepts &= 0x1F00;
- disabled_excepts = ~enabled_excepts;
- disabled_excepts &= 0x1F00;
-
- enabled_excepts &= __excepts;
- disabled_excepts &= __excepts;
-
- /* Clear accrued exceptions */
- __asm__ __volatile__("andn G2, %0\n\t"
- "andn G2, %1\n\t"
- :/*no output*/
- :"l"(enabled_excepts),
- "l"(disabled_excepts >> 8) );
- return 0;
-}
-
-/* fetestexcepts tests both for actual and accrued
- * excepts. You can test for an exception either after
- * an FP instruction or within a SIGFPE handler
- */
-inline int fetestexcept(int __excepts)
-{
- unsigned int G2, G2en, G2dis;
- unsigned int enabled_excepts, disabled_excepts;
-
- /* Check that __excepts is correctly set */
- if( __excepts & (~0x1F00) )
- return -1;
-
- __asm__ __volatile__("mov %0, SR"
- :"=l"(enabled_excepts)
- :/*no input*/ );
-
- enabled_excepts &= 0x1F00;
- disabled_excepts = ~enabled_excepts;
- disabled_excepts &= 0x1F00;
-
- __asm__ __volatile__("mov %0, G2"
- :"=l"(G2)
- :/*no input*/ );
-
- G2en = G2 & 0x1F00;
- G2dis = G2 & 0x1F;
- G2en &= enabled_excepts;
- G2dis &= (disabled_excepts >> 8);
- return ( G2en | (G2dis << 8) );
-}
-
-static __inline__ int feraiseexcept(int __excepts)
-{
- __asm__ __volatile__("or G2, %0"
- :/*no output*/
- :"l"( __excepts >> 8 ) );
- return 0;
-}
-
-/* The following functions enable/disable individual exceptions.
- * If enabling an exception trap is going to occur, in case of error.
- */
-#define feenableexcept(__excepts) \
-({ \
- int __retval, __pexcepts; \
- int __tmpexcepts = __excepts; \
- \
- while(1) { \
- __asm__ __volatile__("mov %0, SR" \
- :"=l"(__pexcepts) \
- :/*no input*/ ); \
- __pexcepts &= 0x1F00; \
- \
-/* Check if __except values are valid */ \
- if( __tmpexcepts & ~0x1F00 ) { \
- __retval = -1; \
- fprintf(stderr,"Non valid excepts\n");\
- break; \
- } \
- \
- __asm__ __volatile__("or SR, %0" \
- :/*no output*/ \
- :"l"(__tmpexcepts) ); \
- __retval = __pexcepts; \
- break; \
- } \
- (__retval); \
-})
-
-
-#define fedisableexcept(__excepts) \
-({ \
- int __retval, __pexcepts; \
- int __tmpexcepts = __excepts; \
- \
- while(1) { \
- __asm__ __volatile__("mov %0, SR" \
- :"=l"(__pexcepts) \
- :/*no input*/ ); \
- __pexcepts &= 0x1F00; \
- \
-/* Check if __except values are valid */ \
- if( __tmpexcepts & ~0x1F00 ) { \
- __retval = -1; \
- fprintf(stderr,"Non valid excepts\n");\
- break; \
- } \
- \
- __asm__ __volatile__("andn SR, %0" \
- :/*no output*/ \
- :"l"(__tmpexcepts) ); \
- __retval = __pexcepts; \
- break; \
- } \
- (__retval); \
-})
-
-static __inline__ int fegetexcept(int excepts)
-{
- unsigned int tmp;
- __asm__ __volatile__("mov %0, SR"
- :"=l"(tmp)
- :/*no input*/ );
- tmp &= 0x1F00;
- return tmp;
-}
-
-static __inline__ int fegetenv(fenv_t *envp)
-{
- __asm__ __volatile__("mov %0, SR\n\t
- mov %1, SR\n\t
- mov %2, G2\n\t
- mov %3, G2\n\t"
- :"=l"(envp->round_mode),
- "=l"(envp->trap_enabled),
- "=l"(envp->accrued_except),
- "=l"(envp->actual_except)
- :/*no input*/ );
- envp->round_mode &= (3<<13);
- envp->trap_enabled &= 0x1F00;
- envp->accrued_except &= 0x1F;
- envp->accrued_except <<= 8;
- envp->actual_except &= 0x1F00;
-}
-
-#define feholdexcept(envp) \
-( \
- fegetenv(envp); \
- fedisableexcept(FE_ALL_EXCEPT); \
- feclearexcept(FE_ALL_EXCEPT); \
- (0); \
-)
-
-#define fesetenv(envp) \
-({ \
- /* Clear FRM & FTE field of SR */ \
- unsigned long clearSR = ( 127<<8 ); \
- __asm__ __volatile__("andn SR, %0\n\t" \
- "or SR, %1\n\t" \
- "or SR, %2\n\t" \
- :/*no output*/ \
- :"l"(clearSR), \
- "l"(envp->round_mode), \
- "l"(envp->trap_enabled) ); \
- __asm__ __volatile__("andn G2, 0x1F1F\n\t" \
- "or G2, %0\n\t" \
- "or G2, %1\n\t" \
- :/*no output*/ \
- :"l"( envp->accrued_except >> 8),\
- :"l"( envp->actual_except ) ); \
- (0); /* return 0 */ \
-})
-
-#define feupdateenv(envp) \
-({ \
- /* Clear FRM & FTE field of SR */ \
- __asm__ __volatile__(/* We dont clear the prev SR*/ \
- "or SR, %1\n\t" \
- "or SR, %2\n\t" \
- :/*no output*/ \
- :"l"(clearSR), \
- "l"(envp->round_mode), \
- "l"(envp->accrued_except) ); \
- __asm__ __volatile__(/* We dont clear the prev SR*/ \
- "or G2, %0\n\t" \
- "or G2, %1\n\t" \
- :/*no output*/ \
- :"l"( envp->accrued_except >> 8),\
- :"l"( envp->actual_except ) ); \
- (0); /* return 0 */ \
-})
-
-
-#endif /* __GNUC__ && !_SOFT_FLOAT */
-
diff --git a/libc/sysdeps/linux/e1/bits/kernel_stat.h b/libc/sysdeps/linux/e1/bits/kernel_stat.h
deleted file mode 100644
index 9be9d115d..000000000
--- a/libc/sysdeps/linux/e1/bits/kernel_stat.h
+++ /dev/null
@@ -1,60 +0,0 @@
-#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... */
-
-struct kernel_stat {
- unsigned short st_dev;
- unsigned short __pad1;
- unsigned long st_ino;
- unsigned short st_mode;
- unsigned short st_nlink;
- unsigned short st_uid;
- unsigned short st_gid;
- unsigned short st_rdev;
- unsigned short __pad2;
- unsigned long st_size;
- unsigned long st_blksize;
- unsigned long st_blocks;
- unsigned long st_atime;
- unsigned long __unused1;
- unsigned long st_mtime;
- unsigned long __unused2;
- unsigned long st_ctime;
- unsigned long __unused3;
- unsigned long __unused4;
- unsigned long __unused5;
-};
-
-struct kernel_stat64 {
- unsigned short st_dev;
- unsigned char __pad0[10];
-#define _HAVE_STAT64___ST_INO
- unsigned long __st_ino;
- unsigned int st_mode;
- unsigned int st_nlink;
- unsigned long st_uid;
- unsigned long st_gid;
- unsigned short st_rdev;
- unsigned char __pad3[10];
- long long st_size;
- unsigned long st_blksize;
- unsigned long st_blocks; /* Number 512-byte blocks allocated. */
- unsigned long __pad4; /* future possible st_blocks high bits */
- unsigned long st_atime;
- unsigned long __pad5;
- unsigned long st_mtime;
- unsigned long __pad6;
- unsigned long st_ctime;
- unsigned long __pad7; /* will be high 32 bits of ctime someday */
- unsigned long long st_ino;
-};
-
-#endif /* _BITS_STAT_STRUCT_H */
-
diff --git a/libc/sysdeps/linux/e1/bits/mman.h b/libc/sysdeps/linux/e1/bits/mman.h
deleted file mode 100644
index 7f644b99b..000000000
--- a/libc/sysdeps/linux/e1/bits/mman.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* Definitions for POSIX memory map interface. Linux/m68k version.
- Copyright (C) 1997 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_MMAN_H
-# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
-#endif
-
-/* The following definitions basically come from the kernel headers.
- But the kernel header is not namespace clean. */
-
-
-/* Protections are chosen from these bits, OR'd together. The
- implementation does not necessarily support PROT_EXEC or PROT_WRITE
- without PROT_READ. The only guarantees are that no writing will be
- allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
-
-#define PROT_READ 0x1 /* Page can be read. */
-#define PROT_WRITE 0x2 /* Page can be written. */
-#define PROT_EXEC 0x4 /* Page can be executed. */
-#define PROT_NONE 0x0 /* Page can not be accessed. */
-
-/* Sharing types (must choose one and only one of these). */
-#define MAP_SHARED 0x01 /* Share changes. */
-#define MAP_PRIVATE 0x02 /* Changes are private. */
-#ifdef __USE_MISC
-# define MAP_TYPE 0x0f /* Mask for type of mapping. */
-#endif
-
-/* Other flags. */
-#define MAP_FIXED 0x10 /* Interpret addr exactly. */
-#ifdef __USE_MISC
-# define MAP_FILE 0
-# define MAP_ANONYMOUS 0x20 /* Don't use a file. */
-# define MAP_ANON MAP_ANONYMOUS
-#endif
-
-/* These are Linux-specific. */
-#ifdef __USE_MISC
-# define MAP_GROWSDOWN 0x0100 /* Stack-like segment. */
-# define MAP_DENYWRITE 0x0800 /* ETXTBSY */
-# define MAP_EXECUTABLE 0x1000 /* Mark it as an executable. */
-# define MAP_LOCKED 0x2000 /* Lock the mapping. */
-# define MAP_NORESERVE 0x4000 /* Don't check for reservations. */
-#endif
-
-/* Flags to `msync'. */
-#define MS_ASYNC 1 /* Sync memory asynchronously. */
-#define MS_SYNC 4 /* Synchronous memory sync. */
-#define MS_INVALIDATE 2 /* Invalidate the caches. */
-
-/* Flags for `mlockall'. */
-#define MCL_CURRENT 1 /* Lock all currently mapped pages. */
-#define MCL_FUTURE 2 /* Lock all additions to address
- space. */
-
-/* Flags for `mremap'. */
-#ifdef __USE_GNU
-# define MREMAP_MAYMOVE 1
-# define MREMAP_FIXED 2
-#endif
diff --git a/libc/sysdeps/linux/e1/bits/proto.h b/libc/sysdeps/linux/e1/bits/proto.h
deleted file mode 100644
index 7aa38ffe5..000000000
--- a/libc/sysdeps/linux/e1/bits/proto.h
+++ /dev/null
@@ -1,5 +0,0 @@
-#ifndef _E1_PROTO_H_
-#define _E1_PROTO_H_
-int kprintf( char *msg, int len);
-#define KPRINTF(msg) kprintf(msg, strlen(msg)+1)
-#endif
diff --git a/libc/sysdeps/linux/e1/bits/setjmp.h b/libc/sysdeps/linux/e1/bits/setjmp.h
deleted file mode 100644
index 88fa76fdf..000000000
--- a/libc/sysdeps/linux/e1/bits/setjmp.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/* This file is lisenced under LGPL.
- * Copyright (C) 2002-2003, George Thanos <george.thanos@gdt.gr>
- * Yannis Mitsos <yannis.mitsos@gdt.gr>
- */
-
-#ifndef _BITS_SETJMP_H
-#define _BITS_SETJMP_H 1
-
-#if !defined _SETJMP_H && !defined _PTHREAD_H
-# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
-#endif
-
-typedef struct {
- unsigned long G3;
- unsigned long G4;
- unsigned long SavedSP;
- unsigned long SavedPC;
- unsigned long SavedSR;
- unsigned long ReturnValue;
-} __jmp_buf[1];
-
-#endif /* bits/setjmp.h */
diff --git a/libc/sysdeps/linux/e1/bits/syscalls.h b/libc/sysdeps/linux/e1/bits/syscalls.h
deleted file mode 100644
index 8852a0f55..000000000
--- a/libc/sysdeps/linux/e1/bits/syscalls.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/* This file is licensed under LGPL.
- * Copyright (C) 2002-2003, George Thanos <george.thanos@gdt.gr>
- * Yannis Mitsos <yannis.mitsos@gdt.gr>
- */
-#ifndef _BITS_SYSCALLS_H
-#define _BITS_SYSCALLS_H
-#ifndef _SYSCALL_H
-# error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
-#endif
-
-#include <features.h>
-
-/* Include the library _syscallx macros */
-#include <bits/unistd.h>
-
-#endif /* _BITS_SYSCALLS_H */
-
diff --git a/libc/sysdeps/linux/e1/bits/unistd.h b/libc/sysdeps/linux/e1/bits/unistd.h
deleted file mode 100644
index f492b8b82..000000000
--- a/libc/sysdeps/linux/e1/bits/unistd.h
+++ /dev/null
@@ -1,464 +0,0 @@
- /* This file is lisenced under LGPL.
- * Copyright (C) 2002-2003, George Thanos <george.thanos@gdt.gr>
- * Yannis Mitsos <yannis.mitsos@gdt.gr>
- */
-#ifndef _BITS_UNISTD_H_
-#define _BITS_UNISTD_H_
-
-#include <bits/proto.h>
-#include <errno.h>
-
-#define __E1_COFF_GCC__
-
-/* The following macros have been provided by C.Baumhof
- * They can be inlined in contrast to the previous ones*/
-#define _syscall0(type, name) \
-type name(void) \
-{ \
- register int par1 __asm__("L15"); \
- register int par2 __asm__("L14"); \
- par1 = -1; \
- par2 = __NR_##name; \
- __asm__ __volatile__( \
- "trap 47" \
- :"=l"(par1) \
- :"0"(par1), "l"(par2) \
- :"memory","L14","L15"); \
- \
- if( par1 < 0 ) { \
- __set_errno( -par1 ); \
- return -1; \
- } else \
- return (type)(par1); \
-}
-
-#define _syscall1(type, name,atype, a) \
-type name(atype a) \
-{ \
- register int par1 __asm__("L15"); \
- register int par2 __asm__("L14"); \
- register int par3 __asm__("L13"); \
- par1 = -1; \
- par2 = __NR_##name; \
- par3 = (int)a; \
- __asm__ __volatile__( \
- "trap 47" \
- :"=l"(par1) \
- :"0"(par1), "l"(par2), "l"(par3) \
- :"memory","L13","L14","L15"); \
- \
- if( par1 < 0 ) { \
- __set_errno( -par1 ); \
- return -1; \
- } else \
- return (type)(par1); \
-}
-
-#define _syscall2(type, name,atype, a, btype, b) \
-type name(atype a, btype b) \
-{ \
- register int par1 __asm__("L15"); \
- register int par2 __asm__("L14"); \
- register int par3 __asm__("L13"); \
- register int par4 __asm__("L12"); \
- par1 = -1; \
- par2 = __NR_##name; \
- par3 = (int)a; \
- par4 = (int)b; \
- __asm__ __volatile__( \
- "trap 47" \
- :"=l"(par1) \
- :"0"(par1), "l"(par2), "l"(par3), "l"(par4) \
- :"memory","L12","L13","L14","L15"); \
- \
- if( par1 < 0 ) { \
- __set_errno( -par1 ); \
- return -1; \
- } else \
- return (type)(par1); \
-}
-
-#define _syscall3(type, name,atype, a, btype, b, ctype, c) \
-type name(atype a, btype b, ctype c) \
-{ \
- register int par1 __asm__("L15"); \
- register int par2 __asm__("L14"); \
- register int par3 __asm__("L13"); \
- register int par4 __asm__("L12"); \
- register int par5 __asm__("L11"); \
- par1 = -1; \
- par2 = __NR_##name; \
- par3 = (int)a; \
- par4 = (int)b; \
- par5 = (int)c; \
- __asm__ __volatile__( \
- "trap 47" \
- :"=l"(par1) \
- :"0"(par1), "l"(par2), "l"(par3), "l"(par4), "l"(par5) \
- :"memory","L11","L12","L13","L14","L15"); \
- \
- if( par1 < 0 ) { \
- __set_errno( -par1 ); \
- return -1; \
- } else \
- return (type)(par1); \
-}
-
-#define _syscall4(type, name,atype, a, btype, b, ctype, c, dtype, d) \
-type name(atype a, btype b, ctype c,dtype d) \
-{ \
- register int par1 __asm__("L15"); \
- register int par2 __asm__("L14"); \
- register int par3 __asm__("L13"); \
- register int par4 __asm__("L12"); \
- register int par5 __asm__("L11"); \
- register int par6 __asm__("L10"); \
- par1 = -1; \
- par2 = __NR_##name; \
- par3 = (int)a; \
- par4 = (int)b; \
- par5 = (int)c; \
- par6 = (int)d; \
- __asm__ __volatile__( \
- "trap 47" \
- :"=l"(par1) \
- :"0"(par1),"l"(par2),"l"(par3),"l"(par4),"l"(par5),"l"(par6) \
- :"memory","L10","L11","L12","L13","L14","L15"); \
- \
- if( par1 < 0 ) { \
- __set_errno( -par1 ); \
- return -1; \
- } else \
- return (type)(par1); \
-}
-
-#define _syscall5(type, name,atype, a, btype, b, ctype, c, dtype, d, etype, e) \
-type name(atype a, btype b, ctype c,dtype d, etype e) \
-{ \
- register int par1 __asm__("L15"); \
- register int par2 __asm__("L14"); \
- register int par3 __asm__("L13"); \
- register int par4 __asm__("L12"); \
- register int par5 __asm__("L11"); \
- register int par6 __asm__("L10"); \
- register int par7 __asm__("L9"); \
- par1 = -1; \
- par2 = __NR_##name; \
- par3 = (int)a; \
- par4 = (int)b; \
- par5 = (int)c; \
- par6 = (int)d; \
- par7 = (int)e; \
- __asm__ __volatile__( \
- "trap 47" \
- :"=l"(par1) \
- :"0"(par1),"l"(par2),"l"(par3),"l"(par4),"l"(par5),"l"(par6),"l"(par7) \
- :"memory","L9","L10","L11","L12","L13","L14","L15"); \
- \
- if( par1 < 0 ) { \
- __set_errno( -par1 ); \
- return -1; \
- } else \
- return (type)(par1); \
- return (type)(par1); \
-}
-
-#define _syscall6(type, name,atype, a, btype, b, ctype, c, dtype, d, etype, e, ftype, f) \
-type name(atype a, btype b, ctype c,dtype d, etype e, ftype f) \
-{ \
- register int par1 __asm__("L15"); \
- register int par2 __asm__("L14"); \
- register int par3 __asm__("L13"); \
- register int par4 __asm__("L12"); \
- register int par5 __asm__("L11"); \
- register int par6 __asm__("L10"); \
- register int par7 __asm__("L9"); \
- register int par8 __asm__("L8"); \
- int sys_retval; \
- par1 = -1; \
- par2 = __NR_##name; \
- par3 = (int)a; \
- par4 = (int)b; \
- par5 = (int)c; \
- par6 = (int)d; \
- par7 = (int)e; \
- par7 = (int)f; \
- __asm__ __volatile__( \
- "trap 47" \
- :"=l"(par1) \
- :"0"(par1),"l"(par2),"l"(par3),"l"(par4),"l"(par5),"l"(par6),"l"(par7),"l"(par8) \
- :"memory","L8","L9","L10","L11","L12","L13","L14","L15"); \
- \
- if( par1 < 0 ) { \
- __set_errno( -par1 ); \
- return -1; \
- } else \
- return (type)(par1); \
-}
-
-#define __syscall0(type, name) \
-type name(...) \
-{ \
- register int par1 __asm__("L15"); \
- register int par2 __asm__("L14"); \
- par1 = -1; \
- par2 = __NR_##name; \
- __asm__ __volatile__( \
- "trap 47" \
- :"=l"(par1) \
- :"0"(par1), "l"(par2)\
- :"memory","L14","L15"); \
- \
- if( par1 < 0 ) { \
- __set_errno( -par1 ); \
- return -1; \
- } else \
- return (type)(par1); \
-}
-
-#define __syscall1(type, name, atype, a) \
-type name(atype a, ...) \
-{ \
- register int par1 __asm__("L15"); \
- register int par2 __asm__("L14"); \
- register int par3 __asm__("L13"); \
- par1 = -1; \
- par2 = __NR_##name; \
- par3 = (int)a; \
- __asm__ __volatile__( \
- "trap 47" \
- :"=l"(par1) \
- :"0"(par1), "l"(par2), "l"(par3)\
- :"memory","L13","L14","L15"); \
- \
- if( par1 < 0 ) { \
- __set_errno( -par1 ); \
- return -1; \
- } else \
- return (type)(par1); \
-}
-
-#define __syscall2(type, name,atype, a, btype, b) \
-type name(atype a, btype b, ...) \
-{ \
- register int par1 __asm__("L15"); \
- register int par2 __asm__("L14"); \
- register int par3 __asm__("L13"); \
- register int par4 __asm__("L12"); \
- par1 = -1; \
- par2 = __NR_##name; \
- par3 = (int)a; \
- par4 = (int)b; \
- __asm__ __volatile__( \
- "trap 47" \
- :"=l"(par1) \
- :"0"(par1), "l"(par2), "l"(par3), "l"(par4)\
- :"memory","L12","L13","L14","L15"); \
- \
- if( par1 < 0 ) { \
- __set_errno( -par1 ); \
- return -1; \
- } else \
- return (type)(par1); \
-}
-
-#define __syscall3(type, name,atype, a, btype, b, ctype, c) \
-type name(atype a, btype b, ctype c, ...) \
-{ \
- register int par1 __asm__("L15"); \
- register int par2 __asm__("L14"); \
- register int par3 __asm__("L13"); \
- register int par4 __asm__("L12"); \
- register int par5 __asm__("L11"); \
- par1 = -1; \
- par2 = __NR_##name; \
- par3 = (int)a; \
- par4 = (int)b; \
- par5 = (int)c; \
- __asm__ __volatile__( \
- "trap 47" \
- :"=l"(par1) \
- :"0"(par1), "l"(par2), "l"(par3), "l"(par4), "l"(par5) \
- :"memory","L11","L12","L13","L14","L15"); \
- \
- if( par1 < 0 ) { \
- __set_errno( -par1 ); \
- return -1; \
- } else \
- return (type)(par1); \
-}
-
-#define __syscall4(type, name,atype, a, btype, b, ctype, c, dtype, d) \
-type name(atype a, btype b, ctype c,dtype d, ...) \
-{ \
- register int par1 __asm__("L15"); \
- register int par2 __asm__("L14"); \
- register int par3 __asm__("L13"); \
- register int par4 __asm__("L12"); \
- register int par5 __asm__("L11"); \
- register int par6 __asm__("L10"); \
- par1 = -1; \
- par2 = __NR_##name; \
- par3 = (int)a; \
- par4 = (int)b; \
- par5 = (int)c; \
- par6 = (int)d; \
- __asm__ __volatile__( \
- "trap 47" \
- :"=l"(par1) \
- :"0"(par1),"l"(par2),"l"(par3),"l"(par4),"l"(par5),"l"(par6) \
- :"memory","L10","L11","L12","L13","L14","L15"); \
- \
- if( par1 < 0 ) { \
- __set_errno( -par1 ); \
- return -1; \
- } else \
- return (type)(par1); \
-}
-
-#define __syscall5(type, name,atype, a, btype, b, ctype, c, dtype, d, etype, e) \
-type name(atype a, btype b, ctype c,dtype d, etype e, ...) \
-{ \
- register int par1 __asm__("L15"); \
- register int par2 __asm__("L14"); \
- register int par3 __asm__("L13"); \
- register int par4 __asm__("L12"); \
- register int par5 __asm__("L11"); \
- register int par6 __asm__("L10"); \
- register int par7 __asm__("L9"); \
- par1 = -1; \
- par2 = __NR_##name; \
- par3 = (int)a; \
- par4 = (int)b; \
- par5 = (int)c; \
- par6 = (int)d; \
- par7 = (int)e; \
- __asm__ __volatile__( \
- "trap 47" \
- :"=l"(par1) \
- :"0"(par1),"l"(par2),"l"(par3),"l"(par4),"l"(par5),"l"(par6),"l"(par7) \
- :"memory","L9","L10","L11","L12","L13","L14","L15"); \
- \
- if( par1 < 0 ) { \
- __set_errno( -par1 ); \
- return -1; \
- } else \
- return (type)(par1); \
-}
-
-#define __syscall6(type, name,atype, a, btype, b, ctype, c, dtype, d, etype, e, ftype, f) \
-type name(atype a, btype b, ctype c,dtype d, etype e, ftype f, ...) \
-{ \
- register int par1 __asm__("L15"); \
- register int par2 __asm__("L14"); \
- register int par3 __asm__("L13"); \
- register int par4 __asm__("L12"); \
- register int par5 __asm__("L11"); \
- register int par6 __asm__("L10"); \
- register int par7 __asm__("L9"); \
- register int par8 __asm__("L8"); \
- par1 = -1; \
- par2 = __NR_##name; \
- par3 = (int)a; \
- par4 = (int)b; \
- par5 = (int)c; \
- par6 = (int)d; \
- par7 = (int)e; \
- par7 = (int)f; \
- __asm__ __volatile__( \
- "trap 47" \
- :"=l"(par1) \
- :"0"(par1),"l"(par2),"l"(par3),"l"(par4),"l"(par5),"l"(par6),"l"(par7),"l"(par8) \
- :"memory","L8","L9","L10","L11","L12","L13","L14","L15"); \
- \
- if( par1 < 0 ) { \
- __set_errno( -par1 ); \
- return -1; \
- } else \
- return (type)(par1); \
-}
-
-#include <sys/types.h>
-/* Taken from <bits/errno.h> */
-#ifndef _LIBC
-/* We don't support pthreads for the moment*/
-#define __set_errno(val) ((errno) = (val))
-#endif
-
-#if 0
-#define _syscall3(type, name,atype, a , btype, b, ctype, c) \
-type name(atype a, btype b, ctype c,) \
-{ \
- __asm__ __volatile__( \
- "movi L9, -1\n\t" \
- "movi L8, %0\n\t" \
- "ldw.d G3, L7, 0\n\t" \
- "ldw.d G3, L6, 4\n\t" \
- "ldw.d G3, L5, 8\n\t" \
- :/* no output */ \
- :"i"(__NR_##name) \
- :"cc","memory","%L5","L6","L7","L8","L9");\
- __asm__ __volatile__( \
- "trap 47\n\t" \
- "mov L2, L9\n\t"); \
-}
-
-#define _syscall4(type, name,atype, a, btype, b, ctype, c, dtype, d) \
-type name(atype a, btype b, ctype c,dtype d) \
-{ \
- __asm__ __volatile__( \
- "movi L11, -1\n\t" \
- "movi L10, %0\n\t" \
- "ldw.d G3, L9, 0\n\t" \
- "ldw.d G3, L8, 4\n\t" \
- "ldw.d G3, L7, 8\n\t" \
- "ldw.d G3, L6, 12\n\t" \
- :/* no output */ \
- :"i"(__NR_##name) \
- :"cc","memory","L6","L7","L8","L9","L10","L11");\
- __asm__ __volatile__( \
- "trap 47\n\t" \
- "mov L2, L11\n\t"); \
-}
-
-#define _syscall5(type, name,atype, a, btype, b, ctype, c, dtype, d, etype, e) \
-type name(atype a, btype b, ctype c,dtype d, etype e) \
-{ \
- __asm__ __volatile__( \
- "movi L13, -1\n\t" \
- "movi L12, %0\n\t" \
- "ldw.d G3, L11, 0\n\t" \
- "ldw.d G3, L10, 4\n\t" \
- "ldw.d G3, L9, 8\n\t" \
- "ldw.d G3, L8, 12\n\t" \
- "ldw.d G3, L7, 16\n\t" \
- :/* no output */ \
- :"i"(__NR_##name) \
- :"cc","memory","L7","L8","L9","L10","L11","L12","L13");\
- __asm__ __volatile__( \
- "trap 47\n\t" \
- "mov L2, L13\n\t"); \
-}
-
-#define _syscall6(type, name,atype, a, btype, b, ctype, c, dtype, d, etype, e, ftype, f) \
-type name(atype a, btype b, ctype c,dtype d, etype e, ftype f) \
-{ \
- __asm__ __volatile__( \
- "movi L15, -1\n\t" \
- "movi L14, %0\n\t" \
- "ldw.d G3, L13, 0\n\t" \
- "ldw.d G3, L12, 4\n\t" \
- "ldw.d G3, L11, 8\n\t" \
- "ldw.d G3, L10, 12\n\t" \
- "ldw.d G3, L9, 16\n\t" \
- "ldw.d G3, L8, 20\n\t" \
- :/* no output */ \
- :"i"(__NR_##name) \
- :"cc","memory","L8","L9","L10","L11","L12","L13","L14","L15");\
- __asm__ __volatile__( \
- "trap 47\n\t" \
- "mov L2, L15\n\t"); \
-}
-#endif
-
-#endif /* !_HYPERSTONE_NOMMU_UNISTD_H_ */
diff --git a/libc/sysdeps/linux/e1/crt0.S b/libc/sysdeps/linux/e1/crt0.S
deleted file mode 100644
index 9d5e98d30..000000000
--- a/libc/sysdeps/linux/e1/crt0.S
+++ /dev/null
@@ -1,17 +0,0 @@
-/* This file is lisenced under LGPL
- * Copyright (C) 2002-2003, George Thanos <george.thanos@gdt.gr>
- * Yannis Mitsos <yannis.mitsos@gdt.gr>
- */
-
-.global __start
-__start:
- call L1, 0, __uClibc_start
-
-/* Define a symbol for the first piece of initialized data. */
- .data
- .globl __data_start
-__data_start:
- .long 0
- .weak data_start
- data_start = __data_start
-
diff --git a/libc/sysdeps/linux/e1/crt1.c b/libc/sysdeps/linux/e1/crt1.c
deleted file mode 100644
index 1e1c8be8e..000000000
--- a/libc/sysdeps/linux/e1/crt1.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/* uClibc/sysdeps/linux/m68k/crt0.S
- * Pull stuff off the stack and get uClibc moving.
- *
- * Copyright (C) 2002-2003, George Thanos <george.thanos@gdt.gr>
- * Yannis Mitsos <yannis.mitsos@gdt.gr>
- *
- * Copyright (C) 2000,2001 by Erik Andersen <andersen@uclibc.org>
- *
- * 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
- */
-
-/* Stick in a dummy reference to main(), so that if an application
- * is linking when the main() function is in a static library (.a)
- * we can be sure that main() actually gets linked in */
-extern void main(int argc,void *argv,void *envp);
-//void (*mainp)(int argc,void *argv,void *envp) = main;
-
-void __uClibc_main(int argc,void *argv,void *envp);
-
-void _uClibc_start(unsigned int first_arg)
-{
- unsigned int argc;
- char **argv, **envp;
- unsigned long *stack;
-
- stack = (unsigned long*) first_arg;
- argc = *(stack);
- argv = (char **)(stack + 1);
- envp = (char **)(stack + 1 + argc + 1);
-
- __uClibc_main(argc, argv, envp);
-}
-
-void __main() { }
-
diff --git a/libc/sysdeps/linux/e1/longjmp.c b/libc/sysdeps/linux/e1/longjmp.c
deleted file mode 100644
index 9f04e7b5c..000000000
--- a/libc/sysdeps/linux/e1/longjmp.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2002-2003, George Thanos <george.thanos@gdt.gr>
- * Yannis Mitsos <yannis.mitsos@gdt.gr>
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-#include <syscall.h>
-#include <setjmp.h>
-#include <stdio.h>
-#include <signal.h>
-
-#define __NR_e1newSP 224
-static __inline__ _syscall1(int, e1newSP, unsigned long, SavedSP )
-
-unsigned long jmpbuf_ptr;
-
-void longjmp(jmp_buf state, int value )
-{
- if(!value)
- state->__jmpbuf->ReturnValue = 1;
- else
- state->__jmpbuf->ReturnValue = value;
-
- jmpbuf_ptr = (unsigned long)state;
- e1newSP(state->__jmpbuf->SavedSP);
-
-#define _state_ ((struct __jmp_buf_tag*)jmpbuf_ptr)
- __asm__ __volatile__("mov L0, %0\n\t"
- "mov L1, %1\n\t"
- "mov L2, %2\n\t"
- "mov G3, %3\n\t"
- "mov G4, %4\n\t"
- "ret PC, L1\n\t"
- :/*no output*/
- :"l"(_state_->__jmpbuf->ReturnValue),
- "l"(_state_->__jmpbuf->SavedPC),
- "l"(_state_->__jmpbuf->SavedSR),
- "l"(_state_->__jmpbuf->G3),
- "l"(_state_->__jmpbuf->G4)
- :"%G3", "%G4", "%L0", "%L1" );
-#undef _state_
-}
-
-libc_hidden_proto(sigprocmask)
-
-void siglongjmp(sigjmp_buf state, int value )
-{
- if( state->__mask_was_saved )
- sigprocmask(SIG_SETMASK, &state->__saved_mask, NULL);
-
- if(!value)
- state->__jmpbuf->ReturnValue = 1;
- else
- state->__jmpbuf->ReturnValue = value;
-
- jmpbuf_ptr = (unsigned long)state;
- e1newSP(state->__jmpbuf->SavedSP);
-
-
-#define _state_ ((struct __jmp_buf_tag*)jmpbuf_ptr)
- __asm__ __volatile__("mov L0, %0\n\t"
- "mov L1, %1\n\t"
- "mov L2, %2\n\t"
- "mov G3, %3\n\t"
- "mov G4, %4\n\t"
- "ret PC, L1\n\t"
- :/*no output*/
- :"l"(_state_->__jmpbuf->ReturnValue),
- "l"(_state_->__jmpbuf->SavedPC),
- "l"(_state_->__jmpbuf->SavedSR),
- "l"(_state_->__jmpbuf->G3),
- "l"(_state_->__jmpbuf->G4)
- :"%G3", "%G4", "%L0", "%L1" );
-#undef _state_
-}
diff --git a/libc/sysdeps/linux/e1/setjmp.c b/libc/sysdeps/linux/e1/setjmp.c
deleted file mode 100644
index bda18b13a..000000000
--- a/libc/sysdeps/linux/e1/setjmp.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/* This file is lisenced under LGPL
- * Copyright (C) 2002-2003, George Thanos <george.thanos@gdt.gr>
- * Yannis Mitsos <yannis.mitsos@gdt.gr>
- */
-
-#include <setjmp.h>
-#include <stdio.h>
-#include <signal.h>
-
-libc_hidden_proto(sigprocmask)
-
-int setjmp( jmp_buf state)
-{
- __asm__ __volatile__( "mov %0, G3\n\t"
- "mov %1, G4\n\t"
- :"=l"(state->__jmpbuf->G3),
- "=l"(state->__jmpbuf->G4)
- :/*no input*/
- :"%G3", "%G4" );
-
- __asm__ __volatile__( "setadr %0\n\t"
- "mov %1, L1\n\t"
- "mov %2, L2\n\t"
- :"=l"(state->__jmpbuf->SavedSP),
- "=l"(state->__jmpbuf->SavedPC),
- "=l"(state->__jmpbuf->SavedSR)
- :/*no input*/);
- return 0;
-}
-
-int sigsetjmp( sigjmp_buf state , int savesigs)
-{
-
- if(savesigs) {
- state->__mask_was_saved = 1;
- /* how arg in <sigprocmask> is not significant */
- sigprocmask(SIG_SETMASK, NULL, &state->__saved_mask);
- } else
- state->__mask_was_saved = 0;
-
- __asm__ __volatile__( "mov %0, G3\n\t"
- "mov %1, G4\n\t"
- :"=l"(state->__jmpbuf->G3),
- "=l"(state->__jmpbuf->G4)
- :/*no input*/
- :"%G3", "%G4" );
-
- __asm__ __volatile__( "setadr %0\n\t"
- "mov %1, L2\n\t"
- "mov %2, L3\n\t"
- :"=l"(state->__jmpbuf->SavedSP),
- "=l"(state->__jmpbuf->SavedPC),
- "=l"(state->__jmpbuf->SavedSR)
- :/*no input*/);
- return 0;
-}
diff --git a/libc/sysdeps/linux/e1/sys/procfs.h b/libc/sysdeps/linux/e1/sys/procfs.h
deleted file mode 100644
index 8416b3b58..000000000
--- a/libc/sysdeps/linux/e1/sys/procfs.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* 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. */
-
-#endif /* sys/procfs.h */
diff --git a/libc/sysdeps/linux/e1/sys/ucontext.h b/libc/sysdeps/linux/e1/sys/ucontext.h
deleted file mode 100644
index 3c441dc5c..000000000
--- a/libc/sysdeps/linux/e1/sys/ucontext.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/* 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. */
-
-/* System V/m68k ABI compliant context switching support. */
-
-#ifndef _SYS_UCONTEXT_H
-#define _SYS_UCONTEXT_H 1
-
-#include <features.h>
-#include <signal.h>
-
-/* Type for general register. */
-typedef int greg_t;
-
-/* Number of general registers. */
-#define NGREG 18
-
-/* Container for all general registers. */
-typedef greg_t gregset_t[NGREG];
-
-/* Number of each register is the `gregset_t' array. */
-enum
-{
- R_D0 = 0,
-#define R_D0 R_D0
- R_D1 = 1,
-#define R_D1 R_D1
- R_D2 = 2,
-#define R_D2 R_D2
- R_D3 = 3,
-#define R_D3 R_D3
- R_D4 = 4,
-#define R_D4 R_D4
- R_D5 = 5,
-#define R_D5 R_D5
- R_D6 = 6,
-#define R_D6 R_D6
- R_D7 = 7,
-#define R_D7 R_D7
- R_A0 = 8,
-#define R_A0 R_A0
- R_A1 = 9,
-#define R_A1 R_A1
- R_A2 = 10,
-#define R_A2 R_A2
- R_A3 = 11,
-#define R_A3 R_A3
- R_A4 = 12,
-#define R_A4 R_A4
- R_A5 = 13,
-#define R_A5 R_A5
- R_A6 = 14,
-#define R_A6 R_A6
- R_A7 = 15,
-#define R_A7 R_A7
- R_SP = 15,
-#define R_SP R_SP
- R_PC = 16,
-#define R_PC R_PC
- R_PS = 17
-#define R_PS R_PS
-};
-
-/* Structure to describe FPU registers. */
-typedef struct fpregset
-{
- int f_fpregs[8][3];
- int f_pcr;
- int f_psr;
- int f_fpiaddr;
-} fpregset_t;
-
-/* Context to describe whole processor state. */
-typedef struct
-{
- int version;
- gregset_t gregs;
- fpregset_t fpregs;
-} mcontext_t;
-
-#define MCONTEXT_VERSION 2
-
-/* Userlevel context. */
-typedef struct ucontext
-{
- unsigned long int uc_flags;
- struct ucontext *uc_link;
- __sigset_t uc_sigmask;
- stack_t uc_stack;
- mcontext_t uc_mcontext;
- long int uc_filler[174];
-} ucontext_t;
-
-#endif /* sys/ucontext.h */
diff --git a/libc/sysdeps/linux/e1/syscalls.c b/libc/sysdeps/linux/e1/syscalls.c
deleted file mode 100644
index e58ad5f79..000000000
--- a/libc/sysdeps/linux/e1/syscalls.c
+++ /dev/null
@@ -1,11 +0,0 @@
-/* This file is lisenced under LGPL
- * Copyright (C) 2002-2003, George Thanos <george.thanos@gdt.gr>
- * Yannis Mitsos <yannis.mitsos@gdt.gr>
- */
-
-#include <syscall.h>
-
-/* We now need a declaration of the `errno' variable. */
-extern int errno;
-# define __set_errno(val) ((errno) = (val))
-_syscall2( int, kprintf, char *, msg, int, len)
diff --git a/libc/sysdeps/linux/e1/vfork.c b/libc/sysdeps/linux/e1/vfork.c
deleted file mode 100644
index 34ae5833c..000000000
--- a/libc/sysdeps/linux/e1/vfork.c
+++ /dev/null
@@ -1,15 +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.
- */
-
-#include <sys/types.h>
-#include <sys/syscall.h>
-#include <errno.h>
-
-#define __NR___vfork __NR_vfork
-attribute_hidden _syscall0(pid_t, __vfork);
-libc_hidden_proto(vfork)
-weak_alias(__vfork,vfork)
-libc_hidden_weak(vfork)
diff --git a/libc/sysdeps/linux/frv/Makefile b/libc/sysdeps/linux/frv/Makefile
index 554fdb0f4..3970f6263 100644
--- a/libc/sysdeps/linux/frv/Makefile
+++ b/libc/sysdeps/linux/frv/Makefile
@@ -1,58 +1,13 @@
# Makefile for uClibc
#
# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
-# ported to FR-V by Alexandre Oliva <aoliva@redhat.com>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
-TOPDIR=../../../../
-include $(TOPDIR)Rules.mak
-
-CRT_SRC := crt0.S
-CRT_OBJ := crt0.o crt1.o
-SCRT_OBJ := $(patsubst %,S%, $(CRT_OBJ))
-
-CTOR_TARGETS := crti.o crtn.o
-
-SSRC := __longjmp.S setjmp.S clone.S vfork.S
-SOBJ := $(patsubst %.S,%.o, $(SSRC))
-
-CSRC = mmap.c sysdep.c syscall.c brk.c sbrk.c __init_brk.c dl-iterate-phdr.c
-CSRC += xstatconv.c stat.c stat64.c fstat.c fstat64.c lstat.c lstat64.c
-COBJ := $(patsubst %.c,%.o, $(CSRC))
-
-OBJS := $(SOBJ) $(COBJ)
-
-OBJ_LIST := ../../../obj.sysdeps.$(TARGET_ARCH)
-
-all: $(OBJ_LIST)
-
-$(OBJ_LIST): $(OBJS) $(CRT_OBJ) $(SCRT_OBJ) $(CTOR_TARGETS)
- $(STRIPTOOL) -x -R .note -R .comment $^
- $(INSTALL) -d $(TOPDIR)lib/
- cp $(CRT_OBJ) $(SCRT_OBJ) $(CTOR_TARGETS) $(TOPDIR)lib/
- echo $(patsubst %, sysdeps/linux/$(TARGET_ARCH)/%, $(OBJS)) > $@
-
-$(CRT_OBJ): $(CRT_SRC) crtreloc.o
- $(CC) $(ASFLAGS) -DL_$* -r -nostdlib $^ -o $*.o
-
-crtreloc.o: crtreloc.c
- $(CC) $(CFLAGS) -c $< -o $@
-
-$(SCRT_OBJ): $(CRT_SRC) Scrtreloc.o
- $(CC) $(ASFLAGS) $(PIEFLAG) -DL_$* -r -nostdlib $^ -o $*.o
-
-Scrtreloc.o: crtreloc.c
- $(CC) $(CFLAGS) $(PIEFLAG) -c $< -o $@
-
-$(CTOR_TARGETS): %.o : %.S
- $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c $< -o $@
-
-$(SOBJ): %.o : %.S
- $(CC) $(ASFLAGS) -c $< -o $@
-
-$(COBJ): %.o : %.c
- $(CC) $(CFLAGS) -c $< -o $@
-
-clean:
- $(RM) *.o *~ core
+top_srcdir=../../../../
+top_builddir=../../../../
+all: objs
+include $(top_builddir)Rules.mak
+include Makefile.arch
+include $(top_srcdir)Makerules
diff --git a/libc/sysdeps/linux/frv/Makefile.arch b/libc/sysdeps/linux/frv/Makefile.arch
new file mode 100644
index 000000000..be48fd007
--- /dev/null
+++ b/libc/sysdeps/linux/frv/Makefile.arch
@@ -0,0 +1,11 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+# ported to FR-V by Alexandre Oliva <aoliva@redhat.com>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+CSRC-y := sysdep.c syscall.c brk.c sbrk.c __init_brk.c dl-iterate-phdr.c
+
+SSRC-y := __longjmp.S setjmp.S clone.S vfork.S
+
diff --git a/libc/sysdeps/linux/frv/__init_brk.c b/libc/sysdeps/linux/frv/__init_brk.c
index 07cf32022..7e4c8d13f 100644
--- a/libc/sysdeps/linux/frv/__init_brk.c
+++ b/libc/sysdeps/linux/frv/__init_brk.c
@@ -7,7 +7,7 @@
void * __curbrk attribute_hidden = 0;
#define __NR__brk __NR_brk
-attribute_hidden _syscall1(void *, _brk, void *, ptr);
+attribute_hidden _syscall1(void *, _brk, void *, ptr)
extern int __init_brk(void) attribute_hidden;
int
diff --git a/libc/sysdeps/linux/frv/__longjmp.S b/libc/sysdeps/linux/frv/__longjmp.S
index c3145c84f..d186ab18e 100644
--- a/libc/sysdeps/linux/frv/__longjmp.S
+++ b/libc/sysdeps/linux/frv/__longjmp.S
@@ -4,10 +4,6 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define _SETJMP_H
-#define _ASM
-#include <bits/setjmp.h>
-
# setjmp/longjmp for Frv. The jmpbuf looks like this:
#
# Register jmpbuf offset
diff --git a/libc/sysdeps/linux/frv/bits/elf-fdpic.h b/libc/sysdeps/linux/frv/bits/elf-fdpic.h
index 905648054..dddf82ccc 100644
--- a/libc/sysdeps/linux/frv/bits/elf-fdpic.h
+++ b/libc/sysdeps/linux/frv/bits/elf-fdpic.h
@@ -22,8 +22,7 @@ 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. */
+not, see <http://www.gnu.org/licenses/>. */
#ifndef _BITS_ELF_FDPIC_H
#define _BITS_ELF_FDPIC_H
@@ -64,7 +63,7 @@ struct elf32_fdpic_loadaddr {
/* Map a pointer's VMA to its corresponding address according to the
load map. */
-inline static void *
+static __always_inline void *
__reloc_pointer (void *p,
const struct elf32_fdpic_loadmap *map)
{
diff --git a/libc/sysdeps/linux/frv/bits/endian.h b/libc/sysdeps/linux/frv/bits/endian.h
index 0564c5921..3ce83c592 100644
--- a/libc/sysdeps/linux/frv/bits/endian.h
+++ b/libc/sysdeps/linux/frv/bits/endian.h
@@ -1,4 +1,4 @@
-/* frv is little-endian. */
+/* frv is big-endian. */
#ifndef _ENDIAN_H
# error "Never use <bits/endian.h> directly; include <endian.h> instead."
diff --git a/libc/sysdeps/linux/frv/bits/fcntl.h b/libc/sysdeps/linux/frv/bits/fcntl.h
index 49da6279d..0581f2bf3 100644
--- a/libc/sysdeps/linux/frv/bits/fcntl.h
+++ b/libc/sysdeps/linux/frv/bits/fcntl.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FCNTL_H
# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
@@ -23,6 +22,9 @@
#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 */
@@ -45,7 +47,9 @@
# define O_DIRECT 040000 /* Direct disk access. */
# define O_DIRECTORY 0200000 /* Must be a directory. */
# define O_NOFOLLOW 0400000 /* Do not follow links. */
-# define O_STREAMING 04000000/* streaming access */
+# define O_NOATIME 01000000 /* don't set atime */
+# define O_CLOEXEC 02000000 /* set close_on_exec */
+# define O_PATH 010000000 /* Resolve pathname but do not open file. */
#endif
/* For now Linux has synchronisity options for data and read operations.
@@ -95,6 +99,8 @@
# define F_NOTIFY 1026 /* Request notfications on a directory. */
# define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with
close-on-exit set on new fd. */
+# define F_SETPIPE_SZ 1031 /* Set pipe page size array. */
+# define F_GETPIPE_SZ 1032 /* Get pipe page size array. */
#endif
/* For F_[GET|SET]FL. */
@@ -164,7 +170,7 @@ struct flock64
#endif
-#ifdef __USE_GNU
+#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
@@ -187,7 +193,7 @@ struct flock64
__BEGIN_DECLS
-#ifdef __USE_GNU
+#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)
diff --git a/libc/sysdeps/linux/frv/bits/kernel_stat.h b/libc/sysdeps/linux/frv/bits/kernel_stat.h
index 8b80a2608..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... */
@@ -38,14 +34,9 @@ struct kernel_stat {
unsigned long __pad10; /* future possible st_blocks high bits */
unsigned long st_blocks; /* Number 512-byte blocks allocated. */
- unsigned long __unused1;
- unsigned long st_atime;
-
- unsigned long __unused2;
- unsigned long st_mtime;
-
- unsigned long __unused3;
- unsigned long st_ctime;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
unsigned long long __unused4;
};
@@ -73,14 +64,9 @@ struct kernel_stat64 {
unsigned long __pad4; /* future possible st_blocks high bits */
unsigned long st_blocks; /* Number 512-byte blocks allocated. */
- unsigned long __unused1;
- unsigned long st_atime;
-
- unsigned long __unused2;
- unsigned long st_mtime;
-
- unsigned long __unused3; /* will be high 32 bits of ctime someday */
- unsigned long st_ctime;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
unsigned long long __unused4;
};
diff --git a/libc/sysdeps/linux/frv/bits/kernel_types.h b/libc/sysdeps/linux/frv/bits/kernel_types.h
index 8403fd3e8..be4fe224f 100644
--- a/libc/sysdeps/linux/frv/bits/kernel_types.h
+++ b/libc/sysdeps/linux/frv/bits/kernel_types.h
@@ -31,6 +31,9 @@ typedef unsigned int __kernel_gid32_t;
typedef unsigned short __kernel_old_uid_t;
typedef unsigned short __kernel_old_gid_t;
typedef long long __kernel_loff_t;
+typedef __kernel_dev_t __kernel_old_dev_t;
+typedef long __kernel_long_t;
+typedef unsigned long __kernel_ulong_t;
typedef struct {
#ifdef __USE_ALL
diff --git a/libc/sysdeps/linux/frv/bits/mman.h b/libc/sysdeps/linux/frv/bits/mman.h
deleted file mode 100644
index 0802005f4..000000000
--- a/libc/sysdeps/linux/frv/bits/mman.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* Definitions for POSIX memory map interface. Linux/frv version.
- Copyright (C) 1997 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_MMAN_H
-# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
-#endif
-
-/* The following definitions basically come from the kernel headers.
- But the kernel header is not namespace clean. */
-
-
-/* Protections are chosen from these bits, OR'd together. The
- implementation does not necessarily support PROT_EXEC or PROT_WRITE
- without PROT_READ. The only guarantees are that no writing will be
- allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
-
-#define PROT_READ 0x1 /* Page can be read. */
-#define PROT_WRITE 0x2 /* Page can be written. */
-#define PROT_EXEC 0x4 /* Page can be executed. */
-#define PROT_NONE 0x0 /* Page can not be accessed. */
-
-/* Sharing types (must choose one and only one of these). */
-#define MAP_SHARED 0x01 /* Share changes. */
-#define MAP_PRIVATE 0x02 /* Changes are private. */
-#ifdef __USE_MISC
-# define MAP_TYPE 0x0f /* Mask for type of mapping. */
-#endif
-
-/* Other flags. */
-#define MAP_FIXED 0x10 /* Interpret addr exactly. */
-#ifdef __USE_MISC
-# define MAP_FILE 0
-# define MAP_ANONYMOUS 0x20 /* Don't use a file. */
-# define MAP_ANON MAP_ANONYMOUS
-#endif
-
-/* These are Linux-specific. */
-#ifdef __USE_MISC
-# define MAP_GROWSDOWN 0x0100 /* Stack-like segment. */
-# define MAP_DENYWRITE 0x0800 /* ETXTBSY */
-# define MAP_EXECUTABLE 0x1000 /* Mark it as an executable. */
-# define MAP_LOCKED 0x2000 /* Lock the mapping. */
-# define MAP_NORESERVE 0x4000 /* Don't check for reservations. */
-#endif
-
-/* Flags to `msync'. */
-#define MS_ASYNC 1 /* Sync memory asynchronously. */
-#define MS_SYNC 4 /* Synchronous memory sync. */
-#define MS_INVALIDATE 2 /* Invalidate the caches. */
-
-/* Flags for `mlockall'. */
-#define MCL_CURRENT 1 /* Lock all currently mapped pages. */
-#define MCL_FUTURE 2 /* Lock all additions to address
- space. */
-
-/* Flags for `mremap'. */
-#ifdef __USE_GNU
-# define MREMAP_MAYMOVE 1
-# define MREMAP_FIXED 2
-#endif
diff --git a/libc/sysdeps/linux/frv/bits/setjmp.h b/libc/sysdeps/linux/frv/bits/setjmp.h
index d49ad7b71..76800ff43 100644
--- a/libc/sysdeps/linux/frv/bits/setjmp.h
+++ b/libc/sysdeps/linux/frv/bits/setjmp.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* Define the machine-dependent type `jmp_buf'. FRV version. */
@@ -35,7 +34,6 @@
#define __SETJMP_FP (__SETJMP_SP+1)
-#ifndef _ASM
typedef struct
/* Demand 64-bit alignment such that we can use std/ldd in
setjmp/longjmp. */
@@ -48,11 +46,5 @@ __attribute__((__aligned__(8)))
unsigned long __sp; /* stack pointer */
unsigned long __fp; /* frame pointer */
} __jmp_buf[1];
-#endif
-
-/* Test if longjmp to JMPBUF would unwind the frame
- containing a local variable at ADDRESS. */
-#define _JMPBUF_UNWINDS(jmpbuf, address) \
- ((void *) (address) < (void *) (jmpbuf)->__sp)
#endif /* bits/setjmp.h */
diff --git a/libc/sysdeps/linux/frv/bits/stackinfo.h b/libc/sysdeps/linux/frv/bits/stackinfo.h
index 03412e009..6ebdf9f1f 100644
--- a/libc/sysdeps/linux/frv/bits/stackinfo.h
+++ b/libc/sysdeps/linux/frv/bits/stackinfo.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* This file contains a bit of information about the stack allocation
of the processor. */
diff --git a/libc/sysdeps/linux/frv/bits/stat.h b/libc/sysdeps/linux/frv/bits/stat.h
index ae5f059f7..e6a1944bb 100644
--- a/libc/sysdeps/linux/frv/bits/stat.h
+++ b/libc/sysdeps/linux/frv/bits/stat.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_STAT_H
# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
@@ -71,6 +70,20 @@ struct stat
__blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
#endif
+#ifdef __USE_MISC
+ /* Nanosecond resolution timestamps are stored in a format
+ equivalent to 'struct timespec'. This is the type used
+ whenever possible but the Unix namespace rules do not allow the
+ identifier 'timespec' to appear in the <sys/stat.h> header.
+ Therefore we have to handle the use of this header in strictly
+ standard-compliant sources special. */
+ struct timespec st_atim; /* Time of last access. */
+ struct timespec st_mtim; /* Time of last modification. */
+ struct timespec st_ctim; /* Time of last status change. */
+# define st_atime st_atim.tv_sec /* Backward compatibility. */
+# define st_mtime st_mtim.tv_sec
+# define st_ctime st_ctim.tv_sec
+#else
unsigned long int __unused1;
__time_t st_atime; /* Time of last access. */
@@ -79,7 +92,7 @@ struct stat
unsigned long int __unused3;
__time_t st_ctime; /* Time of last status change. */
-
+#endif
unsigned long long __unused4;
};
@@ -104,7 +117,20 @@ struct stat64
__blksize_t st_blksize; /* Optimal block size for I/O. */
__blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
-
+#ifdef __USE_MISC
+ /* Nanosecond resolution timestamps are stored in a format
+ equivalent to 'struct timespec'. This is the type used
+ whenever possible but the Unix namespace rules do not allow the
+ identifier 'timespec' to appear in the <sys/stat.h> header.
+ Therefore we have to handle the use of this header in strictly
+ standard-compliant sources special. */
+ struct timespec st_atim; /* Time of last access. */
+ struct timespec st_mtim; /* Time of last modification. */
+ struct timespec st_ctim; /* Time of last status change. */
+# define st_atime st_atim.tv_sec /* Backward compatibility. */
+# define st_mtime st_mtim.tv_sec
+# define st_ctime st_ctim.tv_sec
+#else
unsigned long int __unused1;
__time_t st_atime; /* Time of last access. */
@@ -113,7 +139,7 @@ struct stat64
unsigned long int __unused3;
__time_t st_ctime; /* Time of last status change. */
-
+#endif
unsigned long long __unused4;
};
#endif
@@ -151,4 +177,9 @@ struct stat64
#define __S_IWRITE 0200 /* Write by owner. */
#define __S_IEXEC 0100 /* Execute by owner. */
+#ifdef __USE_ATFILE
+# define UTIME_NOW ((1l << 30) - 1l)
+# define UTIME_OMIT ((1l << 30) - 2l)
+#endif
+
#endif /* _BITS_STAT_H */
diff --git a/libc/sysdeps/linux/frv/bits/syscalls.h b/libc/sysdeps/linux/frv/bits/syscalls.h
index eea3050ba..b03e8dbe0 100644
--- a/libc/sysdeps/linux/frv/bits/syscalls.h
+++ b/libc/sysdeps/linux/frv/bits/syscalls.h
@@ -10,130 +10,71 @@
#define SYS_ify(syscall_name) (__NR_##syscall_name)
-/* user-visible error numbers are in the range -1 - -4095: see <asm-frv/errno.h> */
-#if defined _LIBC && !defined __set_errno
-# define __syscall_return(type, res) \
-do { \
- unsigned long __sr2 = (res); \
- if (__builtin_expect ((unsigned long)(__sr2) \
- >= (unsigned long)(-4095), 0)) { \
- extern int __syscall_error (int); \
- return (type) __syscall_error (__sr2); \
- } \
- return (type) (__sr2); \
-} while (0)
-#else
-# define __syscall_return(type, res) \
-do { \
- unsigned long __sr2 = (res); \
- if (__builtin_expect ((unsigned long)(__sr2) \
- >= (unsigned long)(-4095), 0)) { \
- __set_errno (-__sr2); \
- __sr2 = -1; \
- } \
- return (type) (__sr2); \
-} while (0)
-#endif
-
-#ifndef __set_errno
-# define __set_errno(val) ((*__errno_location ()) = (val))
-#endif
-
-/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
-
-#define _syscall0(type,name) \
-type name(void) \
-{ \
-register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
-register unsigned long __sc0 __asm__ ("gr8"); \
-__asm__ __volatile__ ("tra gr0,gr0" \
- : "=r" (__sc0) \
- : "r" (__scnum)); \
-__syscall_return(type,__sc0); \
-}
-
-#define _syscall1(type,name,type1,arg1) \
-type name(type1 arg1) \
-{ \
-register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
-register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \
-__asm__ __volatile__ ("tra gr0,gr0" \
- : "+r" (__sc0) \
- : "r" (__scnum)); \
-__syscall_return(type,__sc0); \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name(type1 arg1,type2 arg2) \
-{ \
-register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
-register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \
-register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2; \
-__asm__ __volatile__ ("tra gr0,gr0" \
- : "+r" (__sc0) \
- : "r" (__scnum), "r" (__sc1)); \
-__syscall_return(type,__sc0); \
-}
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name(type1 arg1,type2 arg2,type3 arg3) \
-{ \
-register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
-register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \
-register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2; \
-register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3; \
-__asm__ __volatile__ ("tra gr0,gr0" \
- : "+r" (__sc0) \
- : "r" (__scnum), "r" (__sc1), "r" (__sc2)); \
-__syscall_return(type,__sc0); \
-}
+#define INLINE_SYSCALL_NCS(name, nr, args...) \
+(__extension__ \
+ ({ \
+ unsigned int _inline_sys_result = INTERNAL_SYSCALL_NCS (name, , nr, args);\
+ if (unlikely (INTERNAL_SYSCALL_ERROR_P (_inline_sys_result, ))) \
+ { \
+ __set_errno (INTERNAL_SYSCALL_ERRNO (_inline_sys_result, )); \
+ _inline_sys_result = (unsigned int) -1; \
+ } \
+ (int) _inline_sys_result; \
+ }) \
+)
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
-{ \
-register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
-register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \
-register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2; \
-register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3; \
-register unsigned long __sc3 __asm__ ("gr11") = (unsigned long) arg4; \
-__asm__ __volatile__ ("tra gr0,gr0" \
- : "+r" (__sc0) \
- : "r" (__scnum), "r" (__sc1), "r" (__sc2), "r" (__sc3)); \
-__syscall_return(type,__sc0); \
-}
+#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+(__extension__ \
+ ({unsigned int __internal_sys_result; \
+ { \
+ register int __a1 __asm__ ("gr8"); \
+ register int _nr __asm__ ("gr7"); \
+ LOAD_ARGS_##nr (args) \
+ _nr = (name); \
+ __asm__ __volatile__ ("tra gr0,gr0" \
+ : "=r" (__a1) \
+ : "r" (_nr) ASM_ARGS_##nr \
+ : "memory"); \
+ __internal_sys_result = __a1; \
+ } \
+ (int) __internal_sys_result; }) \
+)
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
-{ \
-register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
-register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \
-register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2; \
-register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3; \
-register unsigned long __sc3 __asm__ ("gr11") = (unsigned long) arg4; \
-register unsigned long __sc4 __asm__ ("gr12") = (unsigned long) arg5; \
-__asm__ __volatile__ ("tra gr0,gr0" \
- : "+r" (__sc0) \
- : "r" (__scnum), "r" (__sc1), "r" (__sc2), \
- "r" (__sc3), "r" (__sc4)); \
-__syscall_return(type,__sc0); \
-}
+#define INTERNAL_SYSCALL_ERROR_P(val, err) \
+ ((unsigned int) (val) >= 0xfffff001u)
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5, type6, arg6) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
-{ \
-register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
-register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \
-register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2; \
-register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3; \
-register unsigned long __sc3 __asm__ ("gr11") = (unsigned long) arg4; \
-register unsigned long __sc4 __asm__ ("gr12") = (unsigned long) arg5; \
-register unsigned long __sc5 __asm__ ("gr13") = (unsigned long) arg6; \
-__asm__ __volatile__ ("tra gr0,gr0" \
- : "+r" (__sc0) \
- : "r" (__scnum), "r" (__sc1), "r" (__sc2), \
- "r" (__sc3), "r" (__sc4), "r" (__sc5)); \
-__syscall_return(type,__sc0); \
-}
+#define LOAD_ARGS_0()
+#define ASM_ARGS_0
+#define LOAD_ARGS_1(a1) \
+ int __a1tmp = (int) (a1); \
+ LOAD_ARGS_0 () \
+ __a1 = __a1tmp;
+#define ASM_ARGS_1 ASM_ARGS_0, "r" (__a1)
+#define LOAD_ARGS_2(a1, a2) \
+ int __a2tmp = (int) (a2); \
+ LOAD_ARGS_1 (a1) \
+ register int __a2 __asm__ ("gr8") = __a2tmp;
+#define ASM_ARGS_2 ASM_ARGS_1, "r" (__a2)
+#define LOAD_ARGS_3(a1, a2, a3) \
+ int __a3tmp = (int) (a3); \
+ LOAD_ARGS_2 (a1, a2) \
+ register int __a3 __asm__ ("gr9") = __a3tmp;
+#define ASM_ARGS_3 ASM_ARGS_2, "r" (__a3)
+#define LOAD_ARGS_4(a1, a2, a3, a4) \
+ int __a4tmp = (int) (a4); \
+ LOAD_ARGS_3 (a1, a2, a3) \
+ register int __a4 __asm__ ("gr10") = __a4tmp;
+#define ASM_ARGS_4 ASM_ARGS_3, "r" (__a4)
+#define LOAD_ARGS_5(a1, a2, a3, a4, a5) \
+ int __v1tmp = (int) (a5); \
+ LOAD_ARGS_4 (a1, a2, a3, a4) \
+ register int __v1 __asm__ ("gr11") = __v1tmp;
+#define ASM_ARGS_5 ASM_ARGS_4, "r" (__v1)
+#define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6) \
+ int __v2tmp = (int) (a6); \
+ LOAD_ARGS_5 (a1, a2, a3, a4, a5) \
+ register int __v2 __asm__ ("gr12") = __v2tmp;
+#define ASM_ARGS_6 ASM_ARGS_5, "r" (__v2)
#endif /* __ASSEMBLER__ */
#endif /* _BITS_SYSCALLS_H */
diff --git a/libc/sysdeps/linux/frv/bits/uClibc_arch_features.h b/libc/sysdeps/linux/frv/bits/uClibc_arch_features.h
index f4adaf5ad..f660fd223 100644
--- a/libc/sysdeps/linux/frv/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/frv/bits/uClibc_arch_features.h
@@ -12,28 +12,31 @@
/* can your target use syscall6() for mmap ? */
#undef __UCLIBC_MMAP_HAS_6_ARGS__
-/* does your target use syscall4() for truncate64 ? (32bit arches only) */
-#undef __UCLIBC_TRUNCATE64_HAS_4_ARGS__
+/* does your target align 64bit values in register pairs ? (32bit arches only) */
+#undef __UCLIBC_SYSCALL_ALIGN_64BIT__
/* 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/frv/bits/uClibc_page.h b/libc/sysdeps/linux/frv/bits/uClibc_page.h
index 51a6e15d3..02f619cdc 100644
--- a/libc/sysdeps/linux/frv/bits/uClibc_page.h
+++ b/libc/sysdeps/linux/frv/bits/uClibc_page.h
@@ -11,8 +11,8 @@
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * License along with this library; if not, see
+ * <http://www.gnu.org/licenses/>.
*/
/* Supply an architecture specific value for PAGE_SIZE and friends. */
diff --git a/libc/sysdeps/linux/frv/bits/wordsize.h b/libc/sysdeps/linux/frv/bits/wordsize.h
index ba643b60a..ca82fd7d4 100644
--- a/libc/sysdeps/linux/frv/bits/wordsize.h
+++ b/libc/sysdeps/linux/frv/bits/wordsize.h
@@ -12,8 +12,7 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#define __WORDSIZE 32
diff --git a/libc/sysdeps/linux/frv/brk.c b/libc/sysdeps/linux/frv/brk.c
index c69c97ad6..a98cd5446 100644
--- a/libc/sysdeps/linux/frv/brk.c
+++ b/libc/sysdeps/linux/frv/brk.c
@@ -13,7 +13,6 @@ extern void * __curbrk attribute_hidden;
extern int __init_brk (void) attribute_hidden;
extern void *_brk(void *ptr) attribute_hidden;
-libc_hidden_proto(brk)
int brk(void * end_data_seg)
{
if (__init_brk () == 0)
diff --git a/libc/sysdeps/linux/frv/clone.S b/libc/sysdeps/linux/frv/clone.S
index 145615734..9b7074394 100644
--- a/libc/sysdeps/linux/frv/clone.S
+++ b/libc/sysdeps/linux/frv/clone.S
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* clone() is even more special than fork() as it mucks with stacks
and invokes a function in the right context after its all over. */
diff --git a/libc/sysdeps/linux/frv/crt0.S b/libc/sysdeps/linux/frv/crt1.S
index a1d07bb69..0827feae7 100644
--- a/libc/sysdeps/linux/frv/crt0.S
+++ b/libc/sysdeps/linux/frv/crt1.S
@@ -22,8 +22,7 @@ into another program.)
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. */
+not, see <http://www.gnu.org/licenses/>. */
/* Based on ../i386/crt0.S and newlib's libgloss/frv/crt0.S */
@@ -45,13 +44,10 @@ Cambridge, MA 02139, USA. */
.text
.global _start
.type _start,%function
-#if defined L_crt0 || defined L_Scrt0 || ! defined __UCLIBC_CTOR_DTOR__
- .type __uClibc_main,%function
-#else
.weak _init
.weak _fini
- .type __uClibc_start_main,%function
-#endif
+ .type __uClibc_main,%function
+
_start:
/* Make sure the stack pointer is properly aligned. Save the
original value in gr21 such that we can get to arguments and
@@ -105,7 +101,7 @@ _start:
ld.p @(gr11, gr17), gr11
mov gr17, gr15
ld.p @(gr12, gr17), gr12
- call __uClibc_start_main
+ call __uClibc_main
#else
mov.p gr17, gr15
call __uClibc_main
diff --git a/libc/sysdeps/linux/frv/crti.S b/libc/sysdeps/linux/frv/crti.S
index 178852467..094044366 100644
--- a/libc/sysdeps/linux/frv/crti.S
+++ b/libc/sysdeps/linux/frv/crti.S
@@ -22,8 +22,7 @@ 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. */
+not, see <http://www.gnu.org/licenses/>. */
.section .init,"x"
.p2align 2
diff --git a/libc/sysdeps/linux/frv/crtn.S b/libc/sysdeps/linux/frv/crtn.S
index 1d58c0207..10f93e4f0 100644
--- a/libc/sysdeps/linux/frv/crtn.S
+++ b/libc/sysdeps/linux/frv/crtn.S
@@ -22,8 +22,7 @@ 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. */
+not, see <http://www.gnu.org/licenses/>. */
.section .init,"x"
.globl _init
@@ -32,7 +31,6 @@ Cambridge, MA 02139, USA. */
ld @(sp,gr0), fp
addi sp,#16,sp
jmpl @(gr5,gr0)
- .size _init, .-_init
.section .fini,"x"
.globl _fini
@@ -41,4 +39,3 @@ Cambridge, MA 02139, USA. */
ld @(sp,gr0), fp
addi sp,#16,sp
jmpl @(gr5,gr0)
- .size _fini, .-_fini
diff --git a/libc/sysdeps/linux/frv/crtreloc.c b/libc/sysdeps/linux/frv/crtreloc.c
index e025b619f..b1d542395 100644
--- a/libc/sysdeps/linux/frv/crtreloc.c
+++ b/libc/sysdeps/linux/frv/crtreloc.c
@@ -23,8 +23,9 @@ 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. */
+not, see <http://www.gnu.org/licenses/>. */
+
+#ifdef __FRV_FDPIC__
#include <sys/types.h>
#include <link.h>
@@ -34,7 +35,7 @@ Cambridge, MA 02139, USA. */
/* Compute the runtime address of pointer in the range [p,e), and then
map the pointer pointed by it. */
-inline static void ***
+static __always_inline void ***
reloc_range_indirect (void ***p, void ***e,
const struct elf32_fdpic_loadmap *map)
{
@@ -62,7 +63,7 @@ reloc_range_indirect (void ***p, void ***e,
/* Call __reloc_range_indirect for the given range except for the last
entry, whose contents are only relocated. It's expected to hold
the GOT value. */
-void* attribute_hidden
+attribute_hidden void*
__self_reloc (const struct elf32_fdpic_loadmap *map,
void ***p, void ***e)
{
@@ -73,48 +74,4 @@ __self_reloc (const struct elf32_fdpic_loadmap *map,
return __reloc_pointer (*p, map);
}
-
-#if 0
-/* These are other functions that might be useful, but that we don't
- need. */
-
-/* Remap pointers in [p,e). */
-inline static void**
-reloc_range (void **p, void **e,
- const struct elf32_fdpic_loadmap *map)
-{
- while (p < e)
- {
- *p = __reloc_pointer (*p, map);
- p++;
- }
- return p;
-}
-
-/* Remap p, adjust e by the same offset, then map the pointers in the
- range determined by them. */
-void attribute_hidden
-__reloc_range (const struct elf32_fdpic_loadmap *map,
- void **p, void **e)
-{
- void **old = p;
-
- p = __reloc_pointer (p, map);
- e += p - old;
- reloc_range (p, e, map);
-}
-
-/* Remap p, adjust e by the same offset, then map pointers referenced
- by the (unadjusted) pointers in the range. Return the relocated
- value of the last pointer in the range. */
-void* attribute_hidden
-__reloc_range_indirect (const struct elf32_fdpic_loadmap *map,
- void ***p, void ***e)
-{
- void ***old = p;
-
- p = __reloc_pointer (p, map);
- e += p - old;
- return reloc_range_indirect (p, e, map);
-}
-#endif
+#endif /* __FRV_FDPIC__ */
diff --git a/libc/sysdeps/linux/frv/dl-iterate-phdr.c b/libc/sysdeps/linux/frv/dl-iterate-phdr.c
index 144e4c145..59051e513 100644
--- a/libc/sysdeps/linux/frv/dl-iterate-phdr.c
+++ b/libc/sysdeps/linux/frv/dl-iterate-phdr.c
@@ -13,8 +13,7 @@ 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. */
+not, see <http://www.gnu.org/licenses/>. */
#include <link.h>
diff --git a/libc/sysdeps/linux/frv/fstat.c b/libc/sysdeps/linux/frv/fstat.c
index fc8a25af5..45d2746b3 100644
--- a/libc/sysdeps/linux/frv/fstat.c
+++ b/libc/sysdeps/linux/frv/fstat.c
@@ -13,6 +13,5 @@
#include <unistd.h>
#include <sys/stat.h>
-libc_hidden_proto(fstat)
-_syscall2(int, fstat, int, fd, struct stat *, buf);
+_syscall2(int, fstat, int, fd, struct stat *, buf)
libc_hidden_def(fstat)
diff --git a/libc/sysdeps/linux/frv/fstat64.c b/libc/sysdeps/linux/frv/fstat64.c
index dcb9b922c..75383b272 100644
--- a/libc/sysdeps/linux/frv/fstat64.c
+++ b/libc/sysdeps/linux/frv/fstat64.c
@@ -9,12 +9,9 @@
* Adapted to FR-V by Alexandre Oliva <aoliva@redhat.com>
*/
+#include <_lfs_64.h>
#include <sys/syscall.h>
-#include <unistd.h>
#include <sys/stat.h>
-#ifdef __UCLIBC_HAS_LFS__
-libc_hidden_proto(fstat64)
-_syscall2(int, fstat64, int, fd, struct stat64 *, buf);
+_syscall2(int, fstat64, int, fd, struct stat64 *, buf)
libc_hidden_def(fstat64)
-#endif
diff --git a/libc/sysdeps/linux/frv/jmpbuf-unwind.h b/libc/sysdeps/linux/frv/jmpbuf-unwind.h
new file mode 100644
index 000000000..c22ab2409
--- /dev/null
+++ b/libc/sysdeps/linux/frv/jmpbuf-unwind.h
@@ -0,0 +1,12 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <setjmp.h>
+
+/* Test if longjmp to JMPBUF would unwind the frame
+ containing a local variable at ADDRESS. */
+#define _JMPBUF_UNWINDS(jmpbuf, address) \
+ ((void *) (address) < (void *) (jmpbuf)->__sp)
diff --git a/libc/sysdeps/linux/frv/lstat.c b/libc/sysdeps/linux/frv/lstat.c
index 7a0297bfa..94f722f42 100644
--- a/libc/sysdeps/linux/frv/lstat.c
+++ b/libc/sysdeps/linux/frv/lstat.c
@@ -13,6 +13,5 @@
#include <unistd.h>
#include <sys/stat.h>
-libc_hidden_proto(lstat)
-_syscall2(int, lstat, const char *, file_name, struct stat *, buf);
+_syscall2(int, lstat, const char *, file_name, struct stat *, buf)
libc_hidden_def(lstat)
diff --git a/libc/sysdeps/linux/frv/lstat64.c b/libc/sysdeps/linux/frv/lstat64.c
index e95653ed5..e84581c1e 100644
--- a/libc/sysdeps/linux/frv/lstat64.c
+++ b/libc/sysdeps/linux/frv/lstat64.c
@@ -9,12 +9,9 @@
* Adapted to FR-V by Alexandre Oliva <aoliva@redhat.com>
*/
+#include <_lfs_64.h>
#include <sys/syscall.h>
-#include <unistd.h>
#include <sys/stat.h>
-#ifdef __UCLIBC_HAS_LFS__
-libc_hidden_proto(lstat64)
-_syscall2(int, lstat64, const char *, file_name, struct stat64 *, buf);
+_syscall2(int, lstat64, const char *, file_name, struct stat64 *, buf)
libc_hidden_def(lstat64)
-#endif
diff --git a/libc/sysdeps/linux/frv/mmap.c b/libc/sysdeps/linux/frv/mmap.c
deleted file mode 100644
index f251babbb..000000000
--- a/libc/sysdeps/linux/frv/mmap.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/* Copyright (C) 1997, 1998, 1999, 2002, 2003 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Daniel Jacobowitz <dan@debian.org>, 1999.
-
- 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. */
-
-/* Massivly hacked up for uClibc by Erik Andersen */
-
-/* Extracted from ../common/mmap64.c by Alexandre Oliva <aoliva@redhat.com>
-
- We don't want to use the old mmap interface. */
-
-#include <features.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/syscall.h>
-#include <sys/mman.h>
-
-libc_hidden_proto(mmap)
-
-#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);
-
-/* This is always 12, even on architectures where PAGE_SHIFT != 12. */
-# ifndef MMAP2_PAGE_SHIFT
-# define MMAP2_PAGE_SHIFT 12
-# endif
-
-__ptr_t mmap(__ptr_t addr, size_t len, int prot, int flags, int fd, __off_t offset)
-{
- if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1)) {
- __set_errno (EINVAL);
- return MAP_FAILED;
- }
- return(__syscall_mmap2(addr, len, prot, flags, fd, (off_t) (offset >> MMAP2_PAGE_SHIFT)));
-}
-libc_hidden_def(mmap)
diff --git a/libc/sysdeps/linux/frv/sbrk.c b/libc/sysdeps/linux/frv/sbrk.c
index a1ff2a148..2dc719a16 100644
--- a/libc/sysdeps/linux/frv/sbrk.c
+++ b/libc/sysdeps/linux/frv/sbrk.c
@@ -8,7 +8,6 @@ extern void * __curbrk attribute_hidden;
extern int __init_brk (void) attribute_hidden;
extern void *_brk(void *ptr) attribute_hidden;
-libc_hidden_proto(sbrk)
void *
sbrk(intptr_t increment)
{
diff --git a/libc/sysdeps/linux/frv/stat.c b/libc/sysdeps/linux/frv/stat.c
index 6c3f0b962..74e310071 100644
--- a/libc/sysdeps/linux/frv/stat.c
+++ b/libc/sysdeps/linux/frv/stat.c
@@ -13,6 +13,5 @@
#include <unistd.h>
#include <sys/stat.h>
-libc_hidden_proto(stat)
-_syscall2(int, stat, const char *, file_name, struct stat *, buf);
+_syscall2(int, stat, const char *, file_name, struct stat *, buf)
libc_hidden_def(stat)
diff --git a/libc/sysdeps/linux/frv/stat64.c b/libc/sysdeps/linux/frv/stat64.c
index 659ad8ae2..a13d1c35d 100644
--- a/libc/sysdeps/linux/frv/stat64.c
+++ b/libc/sysdeps/linux/frv/stat64.c
@@ -9,12 +9,9 @@
* Adapted to FR-V by Alexandre Oliva <aoliva@redhat.com>
*/
+#include <_lfs_64.h>
#include <sys/syscall.h>
-#include <unistd.h>
#include <sys/stat.h>
-#ifdef __UCLIBC_HAS_LFS__
-libc_hidden_proto(stat64)
-_syscall2(int, stat64, const char *, file_name, struct stat64 *, buf);
+_syscall2(int, stat64, const char *, file_name, struct stat64 *, buf)
libc_hidden_def(stat64)
-#endif
diff --git a/libc/sysdeps/linux/frv/sys/procfs.h b/libc/sysdeps/linux/frv/sys/procfs.h
index f07523342..025637695 100644
--- a/libc/sysdeps/linux/frv/sys/procfs.h
+++ b/libc/sysdeps/linux/frv/sys/procfs.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_PROCFS_H
#define _SYS_PROCFS_H 1
diff --git a/libc/sysdeps/linux/frv/sys/ptrace.h b/libc/sysdeps/linux/frv/sys/ptrace.h
index 6b0eca7b0..d80b047f6 100644
--- a/libc/sysdeps/linux/frv/sys/ptrace.h
+++ b/libc/sysdeps/linux/frv/sys/ptrace.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_PTRACE_H
#define _SYS_PTRACE_H 1
diff --git a/libc/sysdeps/linux/frv/sys/ucontext.h b/libc/sysdeps/linux/frv/sys/ucontext.h
index 487c9ee02..6a01fc26b 100644
--- a/libc/sysdeps/linux/frv/sys/ucontext.h
+++ b/libc/sysdeps/linux/frv/sys/ucontext.h
@@ -13,8 +13,7 @@
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. */
+ see <http://www.gnu.org/licenses/>. */
#ifndef _SYS_UCONTEXT_H
#define _SYS_UCONTEXT_H 1
diff --git a/libc/sysdeps/linux/frv/syscall.c b/libc/sysdeps/linux/frv/syscall.c
index 7b416e87d..a98cf3832 100644
--- a/libc/sysdeps/linux/frv/syscall.c
+++ b/libc/sysdeps/linux/frv/syscall.c
@@ -13,8 +13,8 @@
* 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
+ * along with this program; see the file COPYING.LIB. If not, see
+ * <http://www.gnu.org/licenses/>.
*/
#include <features.h>
@@ -37,5 +37,5 @@ long syscall(long sysnum, long arg1, long arg2, long arg3,
: "+r" (__sc0)
: "r" (__scnum), "r" (__sc1), "r" (__sc2),
"r" (__sc3), "r" (__sc4), "r" (__sc5));
- __syscall_return(long,__sc0);
+ return (long) __sc0;
}
diff --git a/libc/sysdeps/linux/frv/sysdep.c b/libc/sysdeps/linux/frv/sysdep.c
index 7387d1162..bfae12100 100644
--- a/libc/sysdeps/linux/frv/sysdep.c
+++ b/libc/sysdeps/linux/frv/sysdep.c
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <errno.h>
diff --git a/libc/sysdeps/linux/frv/vfork.S b/libc/sysdeps/linux/frv/vfork.S
index 8935a12f8..02ee7a739 100644
--- a/libc/sysdeps/linux/frv/vfork.S
+++ b/libc/sysdeps/linux/frv/vfork.S
@@ -13,15 +13,10 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
-#include <features.h>
-
-#include <asm/unistd.h>
-#define _ERRNO_H 1
-#include <bits/errno.h>
+#include <sys/syscall.h>
.text
.globl __vfork
@@ -44,4 +39,4 @@ __vfork:
.size __vfork,.-__vfork
weak_alias(__vfork,vfork)
-libc_hidden_weak(vfork)
+libc_hidden_def(vfork)
diff --git a/libc/sysdeps/linux/h8300/Makefile b/libc/sysdeps/linux/h8300/Makefile
index 2ab4ee6f0..552462392 100644
--- a/libc/sysdeps/linux/h8300/Makefile
+++ b/libc/sysdeps/linux/h8300/Makefile
@@ -1,65 +1,13 @@
# Makefile for uClibc
#
-# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2015 Yoshinori Sato
+#
+# Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
#
-# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-
-TOPDIR=../../../../
-include $(TOPDIR)Rules.mak
-ifeq ($(DOPIC),y)
-# is this not provided by gcc ?
-ASFLAGS+=-D__PIC__
-endif
-
-#FIXME -- this arch should include its own crti.S and crtn.S
-UCLIBC_CTOR_DTOR=n
-
-CRT_SRC := crt0.S
-CRT_OBJ := crt0.o crt1.o
-CTOR_TARGETS := $(TOPDIR)lib/crti.o $(TOPDIR)lib/crtn.o
-
-SSRC := __longjmp.S bsd-_setjmp.S bsd-setjmp.S clone.S setjmp.S vfork.S
-SOBJ := $(patsubst %.S,%.o, $(SSRC))
-
-CSRC := ptrace.c brk.c
-COBJ := $(patsubst %.c,%.o, $(CSRC))
-
-OBJS := $(SOBJ) $(COBJ)
-
-OBJ_LIST := ../../../obj.sysdeps.$(TARGET_ARCH)
-
-all: $(OBJ_LIST) $(CTOR_TARGETS)
-
-$(OBJ_LIST): $(OBJS) $(CRT_OBJ)
- $(STRIPTOOL) -x -R .note -R .comment $^
- $(INSTALL) -d $(TOPDIR)lib/
- cp $(CRT_OBJ) $(TOPDIR)lib/
- echo $(patsubst %, sysdeps/linux/$(TARGET_ARCH)/%, $(OBJS)) > $@
-
-$(CRT_OBJ): $(CRT_SRC)
- $(CC) $(ASFLAGS) -DL_$* $< -c -o $*.o
-
-$(SOBJ): %.o : %.S
- $(CC) $(ASFLAGS) -c $< -o $@
-
-$(COBJ): %.o : %.c
- $(CC) $(CFLAGS) -c $< -o $@
-
-ifeq ($(UCLIBC_CTOR_DTOR),y)
-$(TOPDIR)lib/crti.o: crti.S
- $(INSTALL) -d $(TOPDIR)lib/
- $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c $< -o $@
-
-$(TOPDIR)lib/crtn.o: crtn.S
- $(INSTALL) -d $(TOPDIR)lib/
- $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c $< -o $@
-else
-$(CTOR_TARGETS):
- $(INSTALL) -d $(TOPDIR)lib/
- $(AR) $(ARFLAGS) $@
-endif
-
-headers:
-clean:
- $(RM) *.o *~ core
+top_srcdir=../../../../
+top_builddir=../../../../
+all: objs
+include $(top_builddir)Rules.mak
+include Makefile.arch
+include $(top_srcdir)Makerules
diff --git a/libc/sysdeps/linux/h8300/Makefile.arch b/libc/sysdeps/linux/h8300/Makefile.arch
new file mode 100644
index 000000000..371d3dd49
--- /dev/null
+++ b/libc/sysdeps/linux/h8300/Makefile.arch
@@ -0,0 +1,10 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2015 Yoshinori Sato
+#
+# Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+#
+
+CSRC-y := brk.c ptrace.c
+
+SSRC-y := __longjmp.S bsd-_setjmp.S bsd-setjmp.S clone.S setjmp.S vfork.S
diff --git a/libc/sysdeps/linux/h8300/__longjmp.S b/libc/sysdeps/linux/h8300/__longjmp.S
index 5cffa3e5f..bcb098510 100644
--- a/libc/sysdeps/linux/h8300/__longjmp.S
+++ b/libc/sysdeps/linux/h8300/__longjmp.S
@@ -4,10 +4,10 @@
.h8300h
#endif
.text
-
-.global ___longjmp
-___longjmp:
+.global __longjmp
+
+__longjmp:
mov.l er1,er1
bne 1f
sub.l er1,er1
@@ -20,3 +20,5 @@ ___longjmp:
mov.l @er0+,er3 ; return PC
adds #4,sp ; adjust return stack
jmp @er3
+
+libc_hidden_def(__longjmp)
diff --git a/libc/sysdeps/linux/h8300/bits/byteswap.h b/libc/sysdeps/linux/h8300/bits/byteswap.h
index dc56467f2..08ca99f83 100644
--- a/libc/sysdeps/linux/h8300/bits/byteswap.h
+++ b/libc/sysdeps/linux/h8300/bits/byteswap.h
@@ -14,54 +14,13 @@
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. */
+ see <http://www.gnu.org/licenses/>. */
-#if !defined _BYTESWAP_H && !defined _NETINET_IN_H
-# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
-#endif
-
-/* Swap bytes in 16 bit value. We don't provide an assembler version
- because GCC is smart enough to generate optimal assembler output, and
- this allows for better cse. */
-#define __bswap_16(x) \
- ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))
+#ifndef _ASM_BITS_BYTESWAP_H
+#define _ASM_BITS_BYTESWAP_H 1
-/* Swap bytes in 32 bit value. */
-#define __bswap_constant_32(x) \
- ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
- (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
+#define __bswap_non_constant_32(x) __builtin_bswap32(x)
-#if defined __GNUC__ && __GNUC__ >= 2
-# define __bswap_32(x) \
- __extension__ \
- ({ unsigned int __v; \
- if (__builtin_constant_p (x)) \
- __v = __bswap_constant_32 (x); \
- else \
- __asm__ __volatile__ ("mov.l %0,er0\n\t" \
- "mov.b r0l,r1h\n\t" \
- "mov.b r0h,r1l\n\t" \
- "mov.w r1,e1\n\t" \
- "mov.w e0,r0\n\t" \
- "mov.b r0l,r1h\n\t" \
- "mov.b r0h,r1l\n\t" \
- "mov.l er1,%0" \
- : "=d" (__v) \
- : "0" (x): "er0","er1"); \
- __v; })
-#else
-# define __bswap_32(x) __bswap_constant_32 (x)
#endif
-#if defined __GNUC__ && __GNUC__ >= 2
-/* Swap bytes in 64 bit value. */
-# define __bswap_64(x) \
- __extension__ \
- ({ union { unsigned long long int __ll; \
- unsigned long int __l[2]; } __v, __r; \
- __v.__ll = (x); \
- __r.__l[0] = __bswap_32 (__v.__l[1]); \
- __r.__l[1] = __bswap_32 (__v.__l[0]); \
- __r.__ll; })
-#endif
+#include <bits/byteswap-common.h>
diff --git a/libc/sysdeps/linux/h8300/bits/fcntl.h b/libc/sysdeps/linux/h8300/bits/fcntl.h
index 87d193923..c167ee23c 100644
--- a/libc/sysdeps/linux/h8300/bits/fcntl.h
+++ b/libc/sysdeps/linux/h8300/bits/fcntl.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FCNTL_H
# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
@@ -23,6 +22,9 @@
#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 */
@@ -42,10 +44,12 @@
#define O_ASYNC 020000
#ifdef __USE_GNU
-# define O_DIRECTORY 040000 /* Must be a directory. */
-# define O_NOFOLLOW 0100000 /* Do not follow links. */
-# define O_DIRECT 0200000 /* Direct disk access. */
-# define O_STREAMING 04000000/* streaming access */
+# define O_DIRECT 040000 /* Direct disk access. */
+# define O_DIRECTORY 0200000 /* Must be a directory. */
+# define O_NOFOLLOW 0400000 /* Do not follow links. */
+# define O_NOATIME 01000000 /* Do not set atime. */
+# define O_CLOEXEC 02000000 /* Set close_on_exec. */
+# define O_PATH 010000000 /* Resolve pathname but do not open file. */
#endif
/* For now Linux has synchronisity options for data and read operations.
@@ -95,6 +99,8 @@
# define F_NOTIFY 1026 /* Request notfications on a directory. */
# define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with
close-on-exit set on new fd. */
+# define F_SETPIPE_SZ 1031 /* Set pipe page size array. */
+# define F_GETPIPE_SZ 1032 /* Get pipe page size array. */
#endif
/* For F_[GET|SET]FL. */
@@ -182,7 +188,7 @@ struct flock64
#endif
-#ifdef __USE_GNU
+#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
@@ -205,7 +211,7 @@ struct flock64
__BEGIN_DECLS
-#ifdef __USE_GNU
+#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)
diff --git a/libc/sysdeps/linux/h8300/bits/kernel_stat.h b/libc/sysdeps/linux/h8300/bits/kernel_stat.h
deleted file mode 100644
index 9468292e5..000000000
--- a/libc/sysdeps/linux/h8300/bits/kernel_stat.h
+++ /dev/null
@@ -1,61 +0,0 @@
-#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... */
-
-struct kernel_stat {
- unsigned short st_dev;
- unsigned short __pad1;
- unsigned long st_ino;
- unsigned short st_mode;
- unsigned short st_nlink;
- unsigned short st_uid;
- unsigned short st_gid;
- unsigned short st_rdev;
- unsigned short __pad2;
- unsigned long st_size;
- unsigned long st_blksize;
- unsigned long st_blocks;
- unsigned long st_atime;
- unsigned long __unused1;
- unsigned long st_mtime;
- unsigned long __unused2;
- unsigned long st_ctime;
- unsigned long __unused3;
- unsigned long __unused4;
- unsigned long __unused5;
-};
-
-struct kernel_stat64 {
- unsigned char __pad0[6];
- unsigned short st_dev;
- unsigned char __pad1[2];
-#define _HAVE_STAT64___ST_INO
- unsigned long __st_ino;
- unsigned int st_mode;
- unsigned int st_nlink;
- unsigned long st_uid;
- unsigned long st_gid;
- unsigned short st_rdev;
- unsigned char __pad3[10];
- long long st_size;
- unsigned long st_blksize;
- unsigned long st_blocks; /* Number 512-byte blocks allocated. */
- unsigned long __pad4; /* future possible st_blocks high bits */
- unsigned long st_atime;
- unsigned long __pad5;
- unsigned long st_mtime;
- unsigned long __pad6;
- unsigned long st_ctime;
- unsigned long __pad7; /* will be high 32 bits of ctime someday */
- unsigned long long st_ino;
-};
-
-#endif /* _BITS_STAT_STRUCT_H */
-
diff --git a/libc/sysdeps/linux/h8300/bits/kernel_types.h b/libc/sysdeps/linux/h8300/bits/kernel_types.h
index 057067560..312cf2955 100644
--- a/libc/sysdeps/linux/h8300/bits/kernel_types.h
+++ b/libc/sysdeps/linux/h8300/bits/kernel_types.h
@@ -1,5 +1,5 @@
-#ifndef _BITS_KERNEL_TYPES_H
-#define _BITS_KERNEL_TYPES_H
+#ifndef __ASM_GENERIC_POSIX_TYPES_H
+#define __ASM_GENERIC_POSIX_TYPES_H
/* Sigh. We need to carefully wrap this one... No guarantees
* that the asm/posix_types.h kernel header is working. Many
@@ -16,9 +16,9 @@ typedef int __kernel_pid_t;
typedef unsigned short __kernel_ipc_pid_t;
typedef unsigned short __kernel_uid_t;
typedef unsigned short __kernel_gid_t;
-typedef unsigned int __kernel_size_t;
-typedef int __kernel_ssize_t;
-typedef int __kernel_ptrdiff_t;
+typedef unsigned long __kernel_size_t;
+typedef long __kernel_ssize_t;
+typedef long __kernel_ptrdiff_t;
typedef long __kernel_time_t;
typedef long __kernel_suseconds_t;
typedef long __kernel_clock_t;
@@ -32,6 +32,20 @@ typedef unsigned short __kernel_old_uid_t;
typedef unsigned short __kernel_old_gid_t;
typedef long long __kernel_loff_t;
typedef __kernel_dev_t __kernel_old_dev_t;
+typedef long __kernel_long_t;
+typedef unsigned long __kernel_ulong_t;
+
+#define __kernel_long_t __kernel_long_t
+#define __kernel_ino_t __kernel_ino_t
+#define __kernel_mode_t __kernel_mode_t
+#define __kernel_pid_t __kernel_pid_t
+#define __kernel_ipc_pid_t __kernel_ipc_pid_t
+#define __kernel_uid_t __kernel_uid_t
+#define __kernel_susecond_t __kernel_susecond_t
+#define __kernel_daddr_t __kernel_daddr_t
+#define __kernel_uid32_t __kernel_uid32_t
+#define __kernel_old_uid_t __kernel_old_uid_t
+#define __kernel_old_dev_t __kernel_old_dev_t
typedef struct {
#ifdef __USE_ALL
@@ -40,5 +54,6 @@ typedef struct {
int __val[2];
#endif
} __kernel_fsid_t;
+#define __kernel_fsid_t __kernel_fsid_t
-#endif /* _BITS_KERNEL_TYPES_H */
+#endif /* __ASM_GENERIC_POSIX_TYPES_H */
diff --git a/libc/sysdeps/linux/h8300/bits/mman.h b/libc/sysdeps/linux/h8300/bits/mman.h
deleted file mode 100644
index 7f644b99b..000000000
--- a/libc/sysdeps/linux/h8300/bits/mman.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* Definitions for POSIX memory map interface. Linux/m68k version.
- Copyright (C) 1997 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_MMAN_H
-# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
-#endif
-
-/* The following definitions basically come from the kernel headers.
- But the kernel header is not namespace clean. */
-
-
-/* Protections are chosen from these bits, OR'd together. The
- implementation does not necessarily support PROT_EXEC or PROT_WRITE
- without PROT_READ. The only guarantees are that no writing will be
- allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
-
-#define PROT_READ 0x1 /* Page can be read. */
-#define PROT_WRITE 0x2 /* Page can be written. */
-#define PROT_EXEC 0x4 /* Page can be executed. */
-#define PROT_NONE 0x0 /* Page can not be accessed. */
-
-/* Sharing types (must choose one and only one of these). */
-#define MAP_SHARED 0x01 /* Share changes. */
-#define MAP_PRIVATE 0x02 /* Changes are private. */
-#ifdef __USE_MISC
-# define MAP_TYPE 0x0f /* Mask for type of mapping. */
-#endif
-
-/* Other flags. */
-#define MAP_FIXED 0x10 /* Interpret addr exactly. */
-#ifdef __USE_MISC
-# define MAP_FILE 0
-# define MAP_ANONYMOUS 0x20 /* Don't use a file. */
-# define MAP_ANON MAP_ANONYMOUS
-#endif
-
-/* These are Linux-specific. */
-#ifdef __USE_MISC
-# define MAP_GROWSDOWN 0x0100 /* Stack-like segment. */
-# define MAP_DENYWRITE 0x0800 /* ETXTBSY */
-# define MAP_EXECUTABLE 0x1000 /* Mark it as an executable. */
-# define MAP_LOCKED 0x2000 /* Lock the mapping. */
-# define MAP_NORESERVE 0x4000 /* Don't check for reservations. */
-#endif
-
-/* Flags to `msync'. */
-#define MS_ASYNC 1 /* Sync memory asynchronously. */
-#define MS_SYNC 4 /* Synchronous memory sync. */
-#define MS_INVALIDATE 2 /* Invalidate the caches. */
-
-/* Flags for `mlockall'. */
-#define MCL_CURRENT 1 /* Lock all currently mapped pages. */
-#define MCL_FUTURE 2 /* Lock all additions to address
- space. */
-
-/* Flags for `mremap'. */
-#ifdef __USE_GNU
-# define MREMAP_MAYMOVE 1
-# define MREMAP_FIXED 2
-#endif
diff --git a/libc/sysdeps/linux/h8300/bits/setjmp.h b/libc/sysdeps/linux/h8300/bits/setjmp.h
index 15f8d8445..67e1bc89d 100644
--- a/libc/sysdeps/linux/h8300/bits/setjmp.h
+++ b/libc/sysdeps/linux/h8300/bits/setjmp.h
@@ -9,24 +9,10 @@
# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
#endif
-#ifndef _ASM
-
typedef struct
{
unsigned long __regs[4]; /* save er4 - er7(sp) */
unsigned long __pc; /* the return address */
} __jmp_buf[1];
-#endif /* _ASM */
-
-#define JB_REGS 0
-#define JB_PC 16
-#define JB_SIZE 20
-
-
-/* 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[3])
-
#endif /* bits/setjmp.h */
diff --git a/libc/sysdeps/linux/h8300/bits/sigcontextinfo.h b/libc/sysdeps/linux/h8300/bits/sigcontextinfo.h
index b7e08cfc9..851c21d04 100644
--- a/libc/sysdeps/linux/h8300/bits/sigcontextinfo.h
+++ b/libc/sysdeps/linux/h8300/bits/sigcontextinfo.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#define SIGCONTEXT int _code, struct sigcontext *
#define SIGCONTEXT_EXTRA_ARGS _code,
diff --git a/libc/sysdeps/linux/h8300/bits/stackinfo.h b/libc/sysdeps/linux/h8300/bits/stackinfo.h
index 89a77d932..689011b10 100644
--- a/libc/sysdeps/linux/h8300/bits/stackinfo.h
+++ b/libc/sysdeps/linux/h8300/bits/stackinfo.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* This file contains a bit of information about the stack allocation
of the processor. */
diff --git a/libc/sysdeps/linux/h8300/bits/syscalls.h b/libc/sysdeps/linux/h8300/bits/syscalls.h
index 5867ed608..b43795f2e 100644
--- a/libc/sysdeps/linux/h8300/bits/syscalls.h
+++ b/libc/sysdeps/linux/h8300/bits/syscalls.h
@@ -1,151 +1,85 @@
-/* Unlike the asm/unistd.h kernel header file (which this is partly based on),
- * this file must be able to cope with PIC and non-PIC code. For some arches
- * there is no difference. For x86 (which has far too few registers) there is
- * a difference. Regardless, including asm/unistd.h is hereby officially
- * forbidden. Don't do it. It is bad for you.
- */
+#ifndef _BITS_SYSCALLS_H
+#define _BITS_SYSCALLS_H
#ifndef _SYSCALL_H
# error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
#endif
-#define __syscall_return(type, res) \
-do { \
- if ((unsigned long)(res) >= (unsigned long)(-125)) { \
- /* avoid using res which is declared to be in register d0; \
- errno might expand to a function call and clobber it. */ \
- int __err = -(res); \
- errno = __err; \
- res = -1; \
- } \
- return (type) (res); \
-} while (0)
+#ifndef __ASSEMBLER__
-#define _syscall0(type, name) \
-type name(void) \
-{ \
- register long __res __asm__("er0"); \
- __asm__ __volatile__ ("mov.l %1,er0\n\t" \
- "trapa #0\n\t" \
- : "=r" (__res) \
- : "ir" (__NR_##name) \
- : "cc"); \
- if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
- errno = -__res; \
- __res = -1; \
- } \
- return (type)__res; \
-}
+#include <errno.h>
-#define _syscall1(type, name, atype, a) \
-type name(atype a) \
-{ \
- register long __res __asm__("er0"); \
- __asm__ __volatile__ ("mov.l %2, er1\n\t" \
- "mov.l %1, er0\n\t" \
- "trapa #0\n\t" \
- : "=r" (__res) \
- : "ir" (__NR_##name), \
- "g" ((long)a) \
- : "cc", "er1"); \
- if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
- errno = -__res; \
- __res = -1; \
- } \
- return (type)__res; \
-}
+#define ASMFMT_0
+#define ASMFMT_1 , "g"(er1)
+#define ASMFMT_2 , "g"(er1), "g"(er2)
+#define ASMFMT_3 , "g"(er1), "g"(er2), "g"(er3)
+#define ASMFMT_4 , "g"(er1), "g"(er2), "g"(er3), "g"(er4)
+#define ASMFMT_5 , "g"(er1), "g"(er2), "g"(er3), "g"(er4), "g"(er5)
+#define ASMFMT_6 , "g"(er1), "g"(er2), "g"(er3), "g"(er4), "m"(er5), "m"(er6)
-#define _syscall2(type, name, atype, a, btype, b) \
-type name(atype a, btype b) \
-{ \
- register long __res __asm__("er0"); \
- __asm__ __volatile__ ("mov.l %3, er2\n\t" \
- "mov.l %2, er1\n\t" \
- "mov.l %1, er0\n\t" \
- "trapa #0\n\t" \
- : "=r" (__res) \
- : "ir" (__NR_##name), \
- "g" ((long)a), \
- "g" ((long)b) \
- : "cc", "er1", "er2"); \
- if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
- errno = -__res; \
- __res = -1; \
- } \
- return (type)__res; \
-}
+#define SUBSTITUTE_ARGS_0() do {} while(0);
+#define SUBSTITUTE_ARGS_1(arg1) \
+ register long int er1 __asm__("er1") = (long int)arg1;
+#define SUBSTITUTE_ARGS_2(arg1, arg2) \
+ register long int er1 __asm__("er1") = (long int)arg1; \
+ register long int er2 __asm__("er2") = (long int)arg2;
+#define SUBSTITUTE_ARGS_3(arg1, arg2, arg3) \
+ register long int er1 __asm__("er1") = (long int)arg1; \
+ register long int er2 __asm__("er2") = (long int)arg2; \
+ register long int er3 __asm__("er3") = (long int)arg3;
+#define SUBSTITUTE_ARGS_4(arg1, arg2, arg3, arg4) \
+ register long int er1 __asm__("er1") = (long int)arg1; \
+ register long int er2 __asm__("er2") = (long int)arg2; \
+ register long int er3 __asm__("er3") = (long int)arg3; \
+ register long int er4 __asm__("er4") = (long int)arg4;
+#define SUBSTITUTE_ARGS_5(arg1, arg2, arg3, arg4, arg5) \
+ register long int er1 __asm__("er1") = (long int)arg1; \
+ register long int er2 __asm__("er2") = (long int)arg2; \
+ register long int er3 __asm__("er3") = (long int)arg3; \
+ register long int er4 __asm__("er4") = (long int)arg4; \
+ register long int er5 __asm__("er5") = (long int)arg5;
+#define SUBSTITUTE_ARGS_6(arg1, arg2, arg3, arg4, arg5, arg6) \
+ register long int er1 __asm__("er1") = (long int)arg1; \
+ register long int er2 __asm__("er2") = (long int)arg2; \
+ register long int er3 __asm__("er3") = (long int)arg3; \
+ register long int er4 __asm__("er4") = (long int)arg4; \
+ long int er5 = (long int)arg5; \
+ long int er6 = (long int)arg6;
-#define _syscall3(type, name, atype, a, btype, b, ctype, c) \
-type name(atype a, btype b, ctype c) \
-{ \
- register long __res __asm__("er0"); \
- __asm__ __volatile__ ("mov.l %4, er3\n\t" \
- "mov.l %3, er2\n\t" \
- "mov.l %2, er1\n\t" \
- "mov.l %1, er0\n\t" \
- "trapa #0\n\t" \
- : "=r" (__res) \
- : "ir" (__NR_##name), \
- "g" ((long)a), \
- "g" ((long)b), \
- "g" ((long)c) \
- : "cc", "er1", "er2", "er3"); \
- if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
- errno = -__res; \
- __res = -1; \
- } \
- return (type)__res; \
-}
+#define LOAD_ARGS_0
+#define LOAD_ARGS_1
+#define LOAD_ARGS_2
+#define LOAD_ARGS_3
+#define LOAD_ARGS_4
+#define LOAD_ARGS_5
+#define LOAD_ARGS_6 "mov.l er5,@-sp\n\tmov.l %6,er5\n\t" \
+ "mov.l er6,@-sp\n\tmov.l %7,er6\n\t"
-#define _syscall4(type, name, atype, a, btype, b, ctype, c, dtype, d) \
-type name(atype a, btype b, ctype c, dtype d) \
-{ \
- register long __res __asm__("er0"); \
- __asm__ __volatile__ ("mov.l %5, er4\n\t" \
- "mov.l %4, er3\n\t" \
- "mov.l %3, er2\n\t" \
- "mov.l %2, er1\n\t" \
- "mov.l %1, er0\n\t" \
- "trapa #0\n\t" \
- : "=r" (__res) \
- : "ir" (__NR_##name), \
- "g" ((long)a), \
- "g" ((long)b), \
- "g" ((long)c), \
- "g" ((long)d) \
- : "cc", "er1", "er2", "er3", "er4"); \
- if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
- errno = -__res; \
- __res = -1; \
- } \
- return (type)__res; \
-}
+#define RESTORE_ARGS_0
+#define RESTORE_ARGS_1
+#define RESTORE_ARGS_2
+#define RESTORE_ARGS_3
+#define RESTORE_ARGS_4
+#define RESTORE_ARGS_5
+#define RESTORE_ARGS_6 "mov.l @sp+,er6\n\tmov.l @sp+,er5"
-#define _syscall5(type, name, atype, a, btype, b, ctype, c, dtype, d, etype, e) \
-type name(atype a, btype b, ctype c, dtype d, etype e) \
-{ \
- register long __res __asm__("er0"); \
- __asm__ __volatile__ ( \
- "mov.l er5,@-sp\n\t" \
- "mov.l %5, er4\n\t" \
- "mov.l %4, er3\n\t" \
- "mov.l %3, er2\n\t" \
- "mov.l %2, er1\n\t" \
- "mov.l %1, er0\n\t" \
- "mov.l %6, er5\n\t" \
- "trapa #0\n\t" \
- "mov.l @sp+,er5\n\t" \
- : "=r" (__res) \
- : "ir" (__NR_##name), \
- "g" ((long)a), \
- "g" ((long)b), \
- "g" ((long)c), \
- "g" ((long)d), \
- "m" ((long)e) \
- : "cc", "er1", "er2", "er3", "er4"); \
- if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
- errno = -__res; \
- __res = -1; \
- } \
- return (type)__res; \
-}
+/* The _NCS variant allows non-constant syscall numbers. */
+#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+(__extension__ \
+ ({ \
+ register long int er0 __asm__ ("er0"); \
+ SUBSTITUTE_ARGS_##nr(args) \
+ __asm__ __volatile__ ( \
+ LOAD_ARGS_##nr \
+ "mov.l %1,er0\n\t" \
+ "trapa #0\n\t" \
+ RESTORE_ARGS_##nr \
+ : "=r" (er0) \
+ : "ir" (name) ASMFMT_##nr \
+ : "memory" \
+ ); \
+ (int) er0; \
+ }) \
+)
+#endif /* __ASSEMBLER__ */
+#endif /* _BITS_SYSCALLS_H */
diff --git a/libc/sysdeps/linux/h8300/bits/uClibc_arch_features.h b/libc/sysdeps/linux/h8300/bits/uClibc_arch_features.h
index b0d032d30..6047d1482 100644
--- a/libc/sysdeps/linux/h8300/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/h8300/bits/uClibc_arch_features.h
@@ -12,28 +12,31 @@
/* 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_MMAP_HAS_6_ARGS__
+/* does your target align 64bit values in register pairs ? (32bit arches only) */
+#undef __UCLIBC_SYSCALL_ALIGN_64BIT__
/* 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/h8300/brk.c b/libc/sysdeps/linux/h8300/brk.c
index 9eab66060..b33781374 100644
--- a/libc/sysdeps/linux/h8300/brk.c
+++ b/libc/sysdeps/linux/h8300/brk.c
@@ -12,7 +12,6 @@
/* This must be initialized data because commons can't have aliases. */
void *__curbrk attribute_hidden = 0;
-libc_hidden_proto(brk)
int brk (void *addr)
{
void *newbrk;
diff --git a/libc/sysdeps/linux/h8300/bsd-_setjmp.S b/libc/sysdeps/linux/h8300/bsd-_setjmp.S
index e315058a7..766d9cc91 100644
--- a/libc/sysdeps/linux/h8300/bsd-_setjmp.S
+++ b/libc/sysdeps/linux/h8300/bsd-_setjmp.S
@@ -1,8 +1,6 @@
-/* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'. H8/300 version. */
+/* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'. H8/300 version. */
-#define _ASM
-#define _SETJMP_H
-#include <bits/setjmp.h>
+#include <jmpbuf-offsets.h>
#ifdef __H8300S__
.h8300s
@@ -10,10 +8,10 @@
.h8300h
#endif
.text
-
-.global __setjmp
-__setjmp:
+.global _setjmp
+
+_setjmp:
add.l #JB_SIZE,er0
mov.l @sp,er1 ; return PC
mov.l er1,@-er0
@@ -25,3 +23,5 @@ __setjmp:
sub.l er0,er0
mov.l er0,@(JB_SIZE:16,er1)
rts
+
+ .end
diff --git a/libc/sysdeps/linux/h8300/bsd-setjmp.S b/libc/sysdeps/linux/h8300/bsd-setjmp.S
index 9c3535503..77c810fe0 100644
--- a/libc/sysdeps/linux/h8300/bsd-setjmp.S
+++ b/libc/sysdeps/linux/h8300/bsd-setjmp.S
@@ -1,8 +1,6 @@
-/* BSD `_setjmp' entry point to `sigsetjmp (..., 1)'. H8/300 version. */
+/* BSD `_setjmp' entry point to `sigsetjmp (..., 1)'. H8/300 version. */
-#define _ASM
-#define _SETJMP_H
-#include <bits/setjmp.h>
+#include <jmpbuf-offsets.h>
#ifdef __H8300S__
.h8300s
@@ -10,10 +8,10 @@
.h8300h
#endif
.text
-
-.global _setjmp
-_setjmp:
+.global setjmp
+
+setjmp:
add.l #JB_SIZE,er0
mov.l @sp,er1 ; return PC
mov.l er1,@-er0
@@ -23,8 +21,9 @@ _setjmp:
mov.l er4,@-er0
sub.l er0,er0
#if !defined(__PIC__)
- jmp @___sigjmp_save
+ jmp @__sigjmp_save
#else
- mov.l @(___sigjmp_save@GOTOFF,er5),er1
+ mov.l @(__sigjmp_save@GOTOFF,er5),er1
jmp @er3
#endif
+ .end
diff --git a/libc/sysdeps/linux/h8300/clone.S b/libc/sysdeps/linux/h8300/clone.S
index 554a29703..a00eba4cb 100644
--- a/libc/sysdeps/linux/h8300/clone.S
+++ b/libc/sysdeps/linux/h8300/clone.S
@@ -1,5 +1,4 @@
-/* Adapted from glibc */
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc. */
+/* Copyright 2015 Yoshinori Sato <ysato@users.sourceforge.jp> */
/* clone is even more special than fork as it mucks with stacks
and invokes a function in the right context after its all over. */
@@ -8,7 +7,8 @@
#include <bits/errno.h>
#include <sys/syscall.h>
-/* int _clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */
+/* int _clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg
+ void *parent_tidptr, void *tls, void *child_tidptr) */
#ifdef __H8300H__
.h8300h
@@ -18,8 +18,8 @@
#endif
.text
-.globl _clone
-_clone:
+.globl clone
+clone:
/* Sanity check arguments. */
mov.l #-EINVAL,er3
mov.l er0,er0 /* no NULL function pointers */
@@ -31,13 +31,25 @@ _clone:
mov.l @(4:16,sp),er3
mov.l er3,@-er1
- /* Do the system call */
+ /* setup argument */
mov.l er0,er3 /* er3 = child entry */
- mov.l er1,er0
- mov.l er2,er1 /* er1 = flags */
- mov.l er0,er2 /* er2 = child sp */
- mov.l #__NR_clone,r0
+ sub.l #20,sp
+ mov.l er2,@sp /* flags */
+ mov.l er1,@(4,sp) /* new sp */
+ mov.l sp,er1
+ mov.l @(20+8,sp),er0
+ mov.l er0,@er1 /* parent tid */
+ adds #4,er1
+ mov.l @(20+16,sp),er0
+ mov.l er0,@er1 /* child tid */
+ adds #4,er1
+ mov.l @(20+12,sp),er0
+ mov.l er0,@er1 /* tls */
+ /* do the system call */
+ mov.l sp,er1
+ mov.l #__NR_clone,er0
trapa #0
+ add.l #20,sp
mov.l er0,er0
bmi __syscall_error
beq thread_start
@@ -62,7 +74,9 @@ __syscall_error:
thread_start:
mov.l @sp+,er0 /* restore args */
- jsr @er3
+ jsr @er3
mov.l er0,er1
mov.l #__NR_exit,er0
trapa #0
+
+ .end
diff --git a/libc/sysdeps/linux/h8300/crt0.S b/libc/sysdeps/linux/h8300/crt1.S
index ebdca18e5..847872ad7 100644
--- a/libc/sysdeps/linux/h8300/crt0.S
+++ b/libc/sysdeps/linux/h8300/crt1.S
@@ -14,8 +14,7 @@ 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., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
+not, see <http://www.gnu.org/licenses/>. */
#include <features.h>
@@ -29,17 +28,39 @@ Cambridge, MA 02139, USA. */
#else
.h8300h
#endif
+/*
+void __uClibc_main(int (*main)(int, char **, char **), int argc,
+ char **argv, void (*app_init)(void), void (*app_fini)(void),
+ void (*rtld_fini)(void),void *stack_end attribute_unused)
+*/
.text
_start: /* put here so that references to _start work with elf-PIC */
- mov.l @(0,sp),er0 /* argc */
- mov.l @(4,sp),er1 /* argv */
- mov.l @(8,sp),er2 /* envp */
+ mov.l @sp+,er1 /* argc */
+ mov.l @sp+,er2 /* argv */
+ add.l #4,sp
+
#if !defined(__PIC__)
- jsr @___uClibc_main
+ mov.l sp, @-sp
+ sub.l er0,er0
+ mov.l er0,@-sp
+ mov.l #_fini,er0
+ mov.l er0,@-sp
+ mov.l #_init,er0
+ mov.l er0,@-sp
+ mov.l #main,er0
+ jsr @__uClibc_main
#else
- mov.l @(___uClibc_main@GOTOFF,er5),er3
+ mov.l sp, @-sp
+ sub.l er0,er0
+ mov.l er0,@-sp
+ mov.l @(_fini@GOTOFF,er5),er0
+ mov.l er0,@-sp
+ mov.l @(_init@GOTOFF,er5),er0
+ mov.l er0,@-sp
+ mov.l @(main@GOTOFF,er5),er0
+ mov.l @(__uClibc_main@GOTOFF,er5),er3
jsr @er3
#endif
@@ -62,9 +83,9 @@ empty_func:
/* Define a symbol for the first piece of initialized data. */
.data
- .globl __data_start
-__data_start:
+ .globl _data_start
+_data_start:
.long 0
.weak data_start
- data_start = __data_start
+ data_start = _data_start
diff --git a/libc/sysdeps/linux/h8300/crti.S b/libc/sysdeps/linux/h8300/crti.S
index 270df276e..cc6afe902 100644
--- a/libc/sysdeps/linux/h8300/crti.S
+++ b/libc/sysdeps/linux/h8300/crti.S
@@ -10,8 +10,8 @@
.section .init
; #NO_APP
.align 1
- .global __init
-__init:
+ .global _init
+_init:
mov.l er6,@-er7
mov.l er7,er6
; #APP
@@ -20,8 +20,8 @@ __init:
.section .fini
; #NO_APP
.align 1
- .global __fini
-__fini:
+ .global _fini
+_fini:
mov.l er6,@-er7
mov.l er7,er6
; #APP
diff --git a/libc/sysdeps/linux/h8300/crtn.S b/libc/sysdeps/linux/h8300/crtn.S
index 89e321868..a390704a6 100644
--- a/libc/sysdeps/linux/h8300/crtn.S
+++ b/libc/sysdeps/linux/h8300/crtn.S
@@ -10,21 +10,19 @@
.section .init
; #NO_APP
.align 1
- .global __init
+ .global _init
; #NO_APP
mov.l @er7+,er6
rts
- .size __init, .-__init
; #APP
.section .fini
; #NO_APP
.align 1
- .global __fini
+ .global _fini
; #NO_APP
mov.l @er7+,er6
rts
- .size __fini, .-__fini
; #APP
.end
diff --git a/libc/sysdeps/linux/h8300/jmpbuf-offsets.h b/libc/sysdeps/linux/h8300/jmpbuf-offsets.h
new file mode 100644
index 000000000..8351f599e
--- /dev/null
+++ b/libc/sysdeps/linux/h8300/jmpbuf-offsets.h
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define JB_REGS 0
+#define JB_PC 16
+#define JB_SIZE 20
diff --git a/libc/sysdeps/linux/h8300/jmpbuf-unwind.h b/libc/sysdeps/linux/h8300/jmpbuf-unwind.h
new file mode 100644
index 000000000..fe3f758a2
--- /dev/null
+++ b/libc/sysdeps/linux/h8300/jmpbuf-unwind.h
@@ -0,0 +1,12 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <setjmp.h>
+
+/* 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[3])
diff --git a/libc/sysdeps/linux/h8300/setjmp.S b/libc/sysdeps/linux/h8300/setjmp.S
index 5e487674b..0b8f052ce 100644
--- a/libc/sysdeps/linux/h8300/setjmp.S
+++ b/libc/sysdeps/linux/h8300/setjmp.S
@@ -1,6 +1,4 @@
-#define _ASM
-#define _SETJMP_H
-#include <bits/setjmp.h>
+#include <jmpbuf-offsets.h>
#ifdef __H8300S__
.h8300s
@@ -9,9 +7,9 @@
#endif
.text
-.global ___sigsetjmp
+.global __sigsetjmp
-___sigsetjmp:
+__sigsetjmp:
add.l #JB_SIZE,er0
mov.l @sp,er1 ; return PC
mov.l er1,@-er0
diff --git a/libc/sysdeps/linux/h8300/sys/procfs.h b/libc/sysdeps/linux/h8300/sys/procfs.h
index 27abf8ef5..1722bf0f2 100644
--- a/libc/sysdeps/linux/h8300/sys/procfs.h
+++ b/libc/sysdeps/linux/h8300/sys/procfs.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_PROCFS_H
#define _SYS_PROCFS_H 1
diff --git a/libc/sysdeps/linux/h8300/sys/ucontext.h b/libc/sysdeps/linux/h8300/sys/ucontext.h
index ffc9ea024..4ee82850f 100644
--- a/libc/sysdeps/linux/h8300/sys/ucontext.h
+++ b/libc/sysdeps/linux/h8300/sys/ucontext.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* H8/300 compliant context switching support. */
diff --git a/libc/sysdeps/linux/h8300/vfork.S b/libc/sysdeps/linux/h8300/vfork.S
index 35c04e559..24370df3a 100644
--- a/libc/sysdeps/linux/h8300/vfork.S
+++ b/libc/sysdeps/linux/h8300/vfork.S
@@ -1,9 +1,6 @@
+/* Copyright 2002, 2015 Yoshinori Sato <ysato@users.sourceforge.jp> */
-#include <asm/unistd.h>
-
-#ifndef __NR_vfork
-#define __NR_vfork __NR_fork /* uClinux-2.0 only has fork which is vfork */
-#endif
+#include <sys/syscall.h>
#ifdef __H8300S__
.h8300s
@@ -12,30 +9,60 @@
#endif
.text
.align 2
- .globl _errno
- .globl ___vfork
- .hidden ___vfork
- .type ___vfork,@function
-___vfork:
+ .globl __vfork
+ .hidden __vfork
+ .type __vfork,@function
+__vfork:
+#ifdef __NR_vfork
mov.l @sp+, er1
sub.l er0,er0
mov.b #__NR_vfork,r0l
trapa #0
+
mov.l #-4096, er2
cmp.l er0,er2
bcs fix_errno
- jmp @er1 /* don't return, just jmp directly */
+ jmp @er1 /* don't return, just jmp directly */
fix_errno:
neg.l er0
-#if !defined(__PIC__)
+# if !defined(__PIC__)
mov.l er0,@_errno
-#else
+# else
mov.l @(_errno@GOTOFF,er5),er2
mov.l er0,@er2
-#endif
+# endif
sub.l er0,er0
dec.l #1,er0
- jmp @er1 /* don't return, just jmp directly */
+ jmp @er1 /* don't return, just jmp directly */
+#else
+ mov.l @sp+,er2 /* er2 = return address */
+ mov.l #vfork_args,er1
+ sub.l er0,er0
+ mov.b #__NR_clone,r0l
+ trapa #0
+ mov.l #-4096,er1
+ cmp.l er0,er1
+ bcc done
+ neg.l er0
+# if !defined(__PIC__)
+ mov.l er0,@errno
+# else
+ mov.l @(errno@GOTOFF,er5),er1
+ mov.l er0,@er1
+# endif
+ sub.l er0,er0
+ dec.l #1,er0
+done:
+ jmp @er2
+
+vfork_args:
+ .long 0x00004111 /* CLONE_VFORK | CLONE_VM | SIGCHLD */
+ .long 0
+ .long 0
+ .long 0
+ .long 0
+#endif
weak_alias(__vfork,vfork)
-libc_hidden_weak(vfork)
+libc_hidden_def(vfork)
+ .end
diff --git a/libc/sysdeps/linux/hppa/Makefile.arch b/libc/sysdeps/linux/hppa/Makefile.arch
index 9739e74d7..621a5b314 100644
--- a/libc/sysdeps/linux/hppa/Makefile.arch
+++ b/libc/sysdeps/linux/hppa/Makefile.arch
@@ -5,9 +5,7 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-CSRC := __syscall_error.c brk.c mmap.c syscall.c
+CSRC-y := __syscall_error.c brk.c syscall.c
-SSRC := __longjmp.S bsd-_setjmp.S bsd-setjmp.S clone.S setjmp.S \
+SSRC-y := __longjmp.S bsd-_setjmp.S bsd-setjmp.S clone.S setjmp.S \
add_n.s lshift.s rshift.s sub_n.s udiv_qrnnd.s
-
-include $(top_srcdir)libc/sysdeps/linux/Makefile.commonarch
diff --git a/libc/sysdeps/linux/hppa/__longjmp.S b/libc/sysdeps/linux/hppa/__longjmp.S
index 750863e95..ccc7afce5 100644
--- a/libc/sysdeps/linux/hppa/__longjmp.S
+++ b/libc/sysdeps/linux/hppa/__longjmp.S
@@ -13,14 +13,8 @@
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 <features.h>
-#define _SETJMP_H
-#define _ASM
-#include <bits/setjmp.h>
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* __longjmp(jmpbuf, val) */
diff --git a/libc/sysdeps/linux/hppa/add_n.s b/libc/sysdeps/linux/hppa/add_n.s
index a396b3471..faf7afe06 100644
--- a/libc/sysdeps/linux/hppa/add_n.s
+++ b/libc/sysdeps/linux/hppa/add_n.s
@@ -16,9 +16,8 @@
;! License for more details.
;! You should have received a copy of the GNU Lesser General Public License
-;! along with the GNU MP 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.
+;! along with the GNU MP Library; see the file COPYING.LIB. If not, see
+;! <http://www.gnu.org/licenses/>.
;! INPUT PARAMETERS
diff --git a/libc/sysdeps/linux/hppa/bits/atomic.h b/libc/sysdeps/linux/hppa/bits/atomic.h
new file mode 100644
index 000000000..9890af2f0
--- /dev/null
+++ b/libc/sysdeps/linux/hppa/bits/atomic.h
@@ -0,0 +1,98 @@
+/* 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <stdint.h>
+#include <errno.h>
+#include <bits/kernel-features.h>
+
+#define ABORT_INSTRUCTION __asm__("iitlbp %r0,(%sr0, %r0)")
+
+/* 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"
+
+/* 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); \
+ })
+
+#endif
+/* _BITS_ATOMIC_H */
diff --git a/libc/sysdeps/linux/hppa/bits/eventfd.h b/libc/sysdeps/linux/hppa/bits/eventfd.h
new file mode 100644
index 000000000..6182c0736
--- /dev/null
+++ b/libc/sysdeps/linux/hppa/bits/eventfd.h
@@ -0,0 +1,32 @@
+/* Copyright (C) 2007-2013 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_EVENTFD_H
+# error "Never use <bits/eventfd.h> directly; include <sys/eventfd.h> instead."
+#endif
+
+/* Flags for signalfd. */
+enum
+ {
+ EFD_SEMAPHORE = 000000001,
+#define EFD_SEMAPHORE EFD_SEMAPHORE
+ EFD_CLOEXEC = 010000000,
+#define EFD_CLOEXEC EFD_CLOEXEC
+/* the below value looks suspicious, should be 000200004 for consistency */
+ EFD_NONBLOCK = 00200004 /* HPUX has separate NDELAY & NONBLOCK */
+#define EFD_NONBLOCK EFD_NONBLOCK
+ };
diff --git a/libc/sysdeps/linux/hppa/bits/fcntl.h b/libc/sysdeps/linux/hppa/bits/fcntl.h
index c6aaa3afb..ed2f7e538 100644
--- a/libc/sysdeps/linux/hppa/bits/fcntl.h
+++ b/libc/sysdeps/linux/hppa/bits/fcntl.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FCNTL_H
# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
@@ -50,6 +49,8 @@
# define O_DIRECTORY 00010000 /* Must be a directory. */
# define O_NOFOLLOW 00000200 /* Do not follow links. */
# define O_NOATIME 04000000 /* Do not set atime. */
+# define O_CLOEXEC 010000000 /* set close_on_exec */
+# define O_PATH 020000000 /* Resolve pathname but do not open file. */
#endif
#ifdef __USE_LARGEFILE64
@@ -96,6 +97,8 @@
# define F_NOTIFY 1026 /* Request notfications on a directory. */
# define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with
close-on-exit set on new fd. */
+# define F_SETPIPE_SZ 1031 /* Set pipe page size array. */
+# define F_GETPIPE_SZ 1032 /* Get pipe page size array. */
#endif
/* for F_[GET|SET]FL */
@@ -176,7 +179,7 @@ struct flock64
#endif
-#ifdef __USE_GNU
+#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
@@ -199,7 +202,7 @@ struct flock64
__BEGIN_DECLS
-#ifdef __USE_GNU
+#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)
diff --git a/libc/sysdeps/linux/hppa/bits/fenv.h b/libc/sysdeps/linux/hppa/bits/fenv.h
index c5f8c4345..f59a32400 100644
--- a/libc/sysdeps/linux/hppa/bits/fenv.h
+++ b/libc/sysdeps/linux/hppa/bits/fenv.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FENV_H
# error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
diff --git a/libc/sysdeps/linux/hppa/bits/ipc.h b/libc/sysdeps/linux/hppa/bits/ipc.h
index d80cf0699..e634a74b3 100644
--- a/libc/sysdeps/linux/hppa/bits/ipc.h
+++ b/libc/sysdeps/linux/hppa/bits/ipc.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_IPC_H
# error "Never use <bits/ipc.h> directly; include <sys/ipc.h> instead."
diff --git a/libc/sysdeps/linux/hppa/bits/kernel_sigaction.h b/libc/sysdeps/linux/hppa/bits/kernel_sigaction.h
index 4ae53fd3c..5834bf37a 100644
--- a/libc/sysdeps/linux/hppa/bits/kernel_sigaction.h
+++ b/libc/sysdeps/linux/hppa/bits/kernel_sigaction.h
@@ -12,15 +12,4 @@ struct old_kernel_sigaction {
unsigned long sa_flags;
};
-/* This is the sigaction structure from the Linux 2.1.68 kernel. */
-
-struct kernel_sigaction {
- __sighandler_t k_sa_handler;
- unsigned long sa_flags;
- sigset_t sa_mask;
-};
-
-extern int __syscall_rt_sigaction (int, const struct kernel_sigaction *__unbounded,
- struct kernel_sigaction *__unbounded, size_t) attribute_hidden;
-
#endif
diff --git a/libc/sysdeps/linux/hppa/bits/kernel_stat.h b/libc/sysdeps/linux/hppa/bits/kernel_stat.h
index e4d784e91..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 */
@@ -17,12 +13,9 @@ struct kernel_stat {
unsigned short st_reserved2; /* old st_gid */
unsigned int st_rdev;
off_t st_size;
- time_t st_atime;
- unsigned int st_atime_nsec;
- time_t st_mtime;
- unsigned int st_mtime_nsec;
- time_t st_ctime;
- unsigned int st_ctime_nsec;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
int st_blksize;
int st_blocks;
unsigned int __unused1; /* ACL stuff */
@@ -39,8 +32,6 @@ struct kernel_stat {
unsigned int st_spare4[3];
};
-#define STAT_HAVE_NSEC 1
-
/* This is the struct that 32-bit userspace applications are expecting.
* How 64-bit apps are going to be compiled, I have no idea. But at least
* this way, we don't have a wrapper in the kernel.
@@ -60,12 +51,9 @@ struct kernel_stat64 {
signed int st_blksize;
signed long long st_blocks;
- signed int st_atime;
- unsigned int st_atime_nsec;
- signed int st_mtime;
- unsigned int st_mtime_nsec;
- signed int st_ctime;
- unsigned int st_ctime_nsec;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
unsigned long long st_ino;
};
diff --git a/libc/sysdeps/linux/hppa/bits/kernel_types.h b/libc/sysdeps/linux/hppa/bits/kernel_types.h
index 4441f9b29..6b2e79476 100644
--- a/libc/sysdeps/linux/hppa/bits/kernel_types.h
+++ b/libc/sysdeps/linux/hppa/bits/kernel_types.h
@@ -45,6 +45,8 @@ typedef long long __kernel_off64_t;
typedef unsigned long long __kernel_ino64_t;
typedef unsigned int __kernel_old_dev_t;
+typedef long __kernel_long_t;
+typedef unsigned long __kernel_ulong_t;
typedef struct {
#ifdef __USE_ALL
diff --git a/libc/sysdeps/linux/hppa/bits/mman.h b/libc/sysdeps/linux/hppa/bits/mman.h
index 54531ecf2..cbde4b8d4 100644
--- a/libc/sysdeps/linux/hppa/bits/mman.h
+++ b/libc/sysdeps/linux/hppa/bits/mman.h
@@ -1,5 +1,5 @@
/* Definitions for POSIX memory map interface. Linux/HPPA version.
- Copyright (C) 1997, 1998, 2000, 2003 Free Software Foundation, Inc.
+ Copyright (C) 1997-2015 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
@@ -13,20 +13,19 @@
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. */
+ License along with the GNU C Library. If not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_MMAN_H
# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
#endif
-/* these are basically taken from the kernel definitions */
+/* These are taken from the kernel definitions. */
-#define PROT_READ 0x1 /* page can be read */
-#define PROT_WRITE 0x2 /* page can be written */
-#define PROT_EXEC 0x4 /* page can be executed */
-#define PROT_NONE 0x0 /* page can not be accessed */
+#define PROT_READ 0x1 /* Page can be read */
+#define PROT_WRITE 0x2 /* Page can be written */
+#define PROT_EXEC 0x4 /* Page can be executed */
+#define PROT_NONE 0x0 /* Page can not be accessed */
#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of
growsdown vma (mprotect only). */
#define PROT_GROWSUP 0x02000000 /* Extend change to start of
@@ -34,59 +33,83 @@
#define MAP_SHARED 0x01 /* Share changes */
#define MAP_PRIVATE 0x02 /* Changes are private */
-#define MAP_TYPE 0x03 /* Mask for type of mapping */
+#ifdef __USE_MISC
+# define MAP_TYPE 0x03 /* Mask for type of mapping */
+#endif
+
+/* Other flags. */
#define MAP_FIXED 0x04 /* Interpret addr exactly */
-#define MAP_ANONYMOUS 0x10 /* don't use a file */
+#ifdef __USE_MISC
+# define MAP_FILE 0x0
+# define MAP_ANONYMOUS 0x10 /* Don't use a file */
+# define MAP_ANON MAP_ANONYMOUS
+# define MAP_VARIABLE 0
+/* When MAP_HUGETLB is set bits [26:31] encode the log2 of the huge page size. */
+# define MAP_HUGE_SHIFT 26
+# define MAP_HUGE_MASK 0x3f
+#endif
+
+/* These are Linux-specific. */
+#ifdef __USE_MISC
+# define MAP_DENYWRITE 0x0800 /* ETXTBSY */
+# define MAP_EXECUTABLE 0x1000 /* Mark it as an executable */
+# define MAP_LOCKED 0x2000 /* Pages are locked */
+# define MAP_NORESERVE 0x4000 /* Don't check for reservations */
+# define MAP_GROWSDOWN 0x8000 /* Stack-like segment */
+# define MAP_POPULATE 0x10000 /* Populate (prefault) pagetables */
+# define MAP_NONBLOCK 0x20000 /* Do not block on IO */
+#endif
-#define MAP_DENYWRITE 0x0800 /* ETXTBSY */
-#define MAP_EXECUTABLE 0x1000 /* mark it as an executable */
-#define MAP_LOCKED 0x2000 /* pages are locked */
-#define MAP_NORESERVE 0x4000 /* don't check for reservations */
-#define MAP_GROWSDOWN 0x8000 /* stack-like segment */
-#define MAP_POPULATE 0x10000 /* populate (prefault) pagetables */
-#define MAP_NONBLOCK 0x20000 /* do not block on IO */
+/* Flags to "msync" */
+#define MS_SYNC 1 /* Synchronous memory sync */
+#define MS_ASYNC 2 /* Sync memory asynchronously */
+#define MS_INVALIDATE 4 /* Invalidate the caches */
-#define MS_SYNC 1 /* synchronous memory sync */
-#define MS_ASYNC 2 /* sync memory asynchronously */
-#define MS_INVALIDATE 4 /* invalidate the caches */
+/* Flags to "mlockall" */
+#define MCL_CURRENT 1 /* Lock all current mappings */
+#define MCL_FUTURE 2 /* Lock all future mappings */
-#define MCL_CURRENT 1 /* lock all current mappings */
-#define MCL_FUTURE 2 /* lock all future mappings */
+/* Flags for `mremap'. */
+#ifdef __USE_GNU
+# define MREMAP_MAYMOVE 1
+# define MREMAP_FIXED 2
+#endif
-/* Advice to "madvise" */
-#ifdef __USE_BSD
-# define MADV_NORMAL 0 /* no further special treatment */
-# define MADV_RANDOM 1 /* expect random page references */
-# define MADV_SEQUENTIAL 2 /* expect sequential page references */
-# define MADV_WILLNEED 3 /* will need these pages */
-# define MADV_DONTNEED 4 /* dont need these pages */
-# define MADV_SPACEAVAIL 5 /* insure that resources are reserved */
+/* Advice to "madvise" */
+#ifdef __USE_MISC
+# define MADV_NORMAL 0 /* No further special treatment */
+# define MADV_RANDOM 1 /* Expect random page references */
+# define MADV_SEQUENTIAL 2 /* Expect sequential page references */
+# define MADV_WILLNEED 3 /* Will need these pages */
+# define MADV_DONTNEED 4 /* Dont need these pages */
+# define MADV_SPACEAVAIL 5 /* Insure that resources are reserved */
# define MADV_VPS_PURGE 6 /* Purge pages from VM page cache */
# define MADV_VPS_INHERIT 7 /* Inherit parents page size */
# define MADV_REMOVE 9 /* Remove these pages and resources. */
# define MADV_DONTFORK 10 /* Do not inherit across fork. */
# define MADV_DOFORK 11 /* Do inherit across fork. */
+# define MADV_MERGEABLE 65 /* KSM may merge identical pages */
+# define MADV_UNMERGEABLE 66 /* KSM may not merge identical pages */
#endif
/* The range 12-64 is reserved for page size specification. */
-#define MADV_4K_PAGES 12 /* Use 4K pages */
-#define MADV_16K_PAGES 14 /* Use 16K pages */
-#define MADV_64K_PAGES 16 /* Use 64K pages */
-#define MADV_256K_PAGES 18 /* Use 256K pages */
-#define MADV_1M_PAGES 20 /* Use 1 Megabyte pages */
-#define MADV_4M_PAGES 22 /* Use 4 Megabyte pages */
-#define MADV_16M_PAGES 24 /* Use 16 Megabyte pages */
-#define MADV_64M_PAGES 26 /* Use 64 Megabyte pages */
-
-/* compatibility flags */
-#define MAP_ANON MAP_ANONYMOUS
-#define MAP_FILE 0
-#define MAP_VARIABLE 0
-
-/* Flags for `mremap'. */
-#ifdef __USE_GNU
-# define MREMAP_MAYMOVE 1
-# define MREMAP_FIXED 2
+/* These are Linux-specific. */
+#ifdef __USE_MISC
+# define MADV_4K_PAGES 12 /* Use 4K pages. */
+# define MADV_16K_PAGES 14 /* Use 16K pages. */
+# define MADV_64K_PAGES 16 /* Use 64K pages. */
+# define MADV_256K_PAGES 18 /* Use 256K pages. */
+# define MADV_1M_PAGES 20 /* Use 1 Megabyte pages. */
+# define MADV_4M_PAGES 22 /* Use 4 Megabyte pages. */
+# define MADV_16M_PAGES 24 /* Use 16 Megabyte pages. */
+# define MADV_64M_PAGES 26 /* Use 64 Megabyte pages. */
#endif
-
+/* The POSIX people had to invent similar names for the same things. */
+#ifdef __USE_XOPEN2K
+# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
+# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
+# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
+# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
+# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
+#endif
diff --git a/libc/sysdeps/linux/hppa/bits/setjmp.h b/libc/sysdeps/linux/hppa/bits/setjmp.h
index 4395b8f56..3a0a3b6ad 100644
--- a/libc/sysdeps/linux/hppa/bits/setjmp.h
+++ b/libc/sysdeps/linux/hppa/bits/setjmp.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2005, 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
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* Define the machine-dependent type `jmp_buf'. HPPA version. */
#ifndef _BITS_SETJMP_H
@@ -29,17 +28,6 @@
easier, and to ensure proper alignment. Naturally, user code should
not depend on either representation. */
-#if defined __USE_MISC || defined _ASM
-#define JB_SP (76/4)
-#endif
-
-#ifndef _ASM
typedef double __jmp_buf[21];
-#endif
-
-/* Test if longjmp to JMPBUF would unwind the frame containing a local
- variable at ADDRESS. */
-#define _JMPBUF_UNWINDS(_jmpbuf, _address) \
- ((void *)(_address) > (void *)(((unsigned long *) _jmpbuf)[JB_SP]))
#endif /* bits/setjmp.h */
diff --git a/libc/sysdeps/linux/hppa/bits/sigaction.h b/libc/sysdeps/linux/hppa/bits/sigaction.h
index 33f2b237b..a221ac9c1 100644
--- a/libc/sysdeps/linux/hppa/bits/sigaction.h
+++ b/libc/sysdeps/linux/hppa/bits/sigaction.h
@@ -13,39 +13,29 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SIGNAL_H
# error "Never include <bits/sigaction.h> directly; use <signal.h> instead."
#endif
/* Structure describing the action to be taken when a signal arrives. */
-struct sigaction
- {
- /* Signal handler. */
+struct sigaction {
#ifdef __USE_POSIX199309
- union
- {
- /* Used if SA_SIGINFO is not set. */
- __sighandler_t sa_handler;
- /* Used if SA_SIGINFO is set. */
- void (*sa_sigaction) (int, siginfo_t *, void *);
- }
- __sigaction_handler;
-# define sa_handler __sigaction_handler.sa_handler
-# define sa_sigaction __sigaction_handler.sa_sigaction
+ union {
+ __sighandler_t sa_handler;
+ void (*sa_sigaction)(int, siginfo_t *, void *);
+ } __sigaction_handler;
+# define sa_handler __sigaction_handler.sa_handler
+# define sa_sigaction __sigaction_handler.sa_sigaction
#else
- __sighandler_t sa_handler;
+ __sighandler_t sa_handler;
#endif
-
- /* Special flags. */
- unsigned long int sa_flags;
-
- /* Additional set of signals to be blocked. */
- __sigset_t sa_mask;
- };
+ unsigned long sa_flags;
+ sigset_t sa_mask;
+ /* HPPA has no sa_restorer field. */
+};
/* Bits in `sa_flags'. */
diff --git a/libc/sysdeps/linux/hppa/bits/signum.h b/libc/sysdeps/linux/hppa/bits/signum.h
index bf46006c8..243eefdc8 100644
--- a/libc/sysdeps/linux/hppa/bits/signum.h
+++ b/libc/sysdeps/linux/hppa/bits/signum.h
@@ -13,23 +13,11 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifdef _SIGNAL_H
-/* Fake signal functions. */
-#define SIG_ERR ((__sighandler_t) -1) /* Error return. */
-#define SIG_DFL ((__sighandler_t) 0) /* Default action. */
-#define SIG_IGN ((__sighandler_t) 1) /* Ignore signal. */
-
-#ifdef __USE_UNIX98
-# define SIG_HOLD ((__sighandler_t) 2) /* Add signal to hold mask. */
-#endif
-
-
-/* Signals. */
#define SIGHUP 1 /* Hangup (POSIX). */
#define SIGINT 2 /* Interrupt (ANSI). */
#define SIGQUIT 3 /* Quit (POSIX). */
@@ -68,15 +56,6 @@
#define SIGXFSZ 34 /* File size limit exceeded (4.2 BSD). */
#define SIGSTKFLT 36 /* Stack fault. */
-#define _NSIG 65 /* Biggest signal number + 1
- (including real-time signals). */
-
-#define SIGRTMIN (__libc_current_sigrtmin ())
-#define SIGRTMAX (__libc_current_sigrtmax ())
-
-/* These are the hard limits of the kernel. These values should not be
- used directly at user level. */
#define __SIGRTMIN 37
-#define __SIGRTMAX (_NSIG - 1)
#endif /* <signal.h> included. */
diff --git a/libc/sysdeps/linux/hppa/bits/socket_type.h b/libc/sysdeps/linux/hppa/bits/socket_type.h
new file mode 100644
index 000000000..c6df6c3e5
--- /dev/null
+++ b/libc/sysdeps/linux/hppa/bits/socket_type.h
@@ -0,0 +1,54 @@
+/* Define enum __socket_type for Linux/HP-PARISC.
+ Copyright (C) 2012 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_SOCKET_H
+# error "Never include <bits/socket_type.h> directly; use <sys/socket.h> instead."
+#endif
+
+/* Types of sockets. */
+enum __socket_type
+{
+ SOCK_STREAM = 1, /* Sequenced, reliable, connection-based
+ byte streams. */
+#define SOCK_STREAM SOCK_STREAM
+ SOCK_DGRAM = 2, /* Connectionless, unreliable datagrams
+ of fixed maximum length. */
+#define SOCK_DGRAM SOCK_DGRAM
+ SOCK_RAW = 3, /* Raw protocol interface. */
+#define SOCK_RAW SOCK_RAW
+ SOCK_RDM = 4, /* Reliably-delivered messages. */
+#define SOCK_RDM SOCK_RDM
+ SOCK_SEQPACKET = 5, /* Sequenced, reliable, connection-based,
+ datagrams of fixed maximum length. */
+#define SOCK_SEQPACKET SOCK_SEQPACKET
+ SOCK_DCCP = 6, /* Datagram Congestion Control Protocol. */
+#define SOCK_DCCP SOCK_DCCP
+ SOCK_PACKET = 10, /* Linux specific way of getting packets
+ at the dev level. For writing rarp and
+ other similar things on the user level. */
+#define SOCK_PACKET SOCK_PACKET
+
+ /* Flags to be ORed into the type parameter of socket and socketpair. */
+
+ SOCK_CLOEXEC = 010000000, /* Atomically set close-on-exec flag for the
+ new descriptor(s). */
+#define SOCK_CLOEXEC SOCK_CLOEXEC
+ SOCK_NONBLOCK = 0x40000000 /* Atomically mark descriptor(s) as
+ non-blocking. */
+#define SOCK_NONBLOCK SOCK_NONBLOCK
+};
diff --git a/libc/sysdeps/linux/hppa/bits/stackinfo.h b/libc/sysdeps/linux/hppa/bits/stackinfo.h
index 318de7143..8574e7d8d 100644
--- a/libc/sysdeps/linux/hppa/bits/stackinfo.h
+++ b/libc/sysdeps/linux/hppa/bits/stackinfo.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* This file contains a bit of information about the stack allocation
of the processor. */
diff --git a/libc/sysdeps/linux/hppa/bits/syscalls.h b/libc/sysdeps/linux/hppa/bits/syscalls.h
index 9035cd5aa..fddad622d 100644
--- a/libc/sysdeps/linux/hppa/bits/syscalls.h
+++ b/libc/sysdeps/linux/hppa/bits/syscalls.h
@@ -6,10 +6,6 @@
#ifndef __ASSEMBLER__
-#include <errno.h>
-
-#define SYS_ify(syscall_name) __NR_##syscall_name
-
/* Assume all syscalls are done from PIC code just to be
* safe. The worst case scenario is that you lose a register
* and save/restore r19 across the syscall. */
@@ -42,33 +38,26 @@
across the syscall. */
#define K_CALL_CLOB_REGS "%r1", "%r2", K_USING_GR4 \
- "%r20", "%r29", "%r31"
-
-#undef K_INLINE_SYSCALL
-#define K_INLINE_SYSCALL(name, nr, args...) ({ \
- long __sys_res; \
- { \
- register unsigned long __res __asm__("r28"); \
- K_LOAD_ARGS_##nr(args) \
- /* FIXME: HACK stw/ldw r19 around syscall */ \
- __asm__ __volatile__( \
- K_STW_ASM_PIC \
- " ble 0x100(%%sr2, %%r0)\n" \
- " ldi %1, %%r20\n" \
- K_LDW_ASM_PIC \
- : "=r" (__res) \
- : "i" (SYS_ify(name)) K_ASM_ARGS_##nr \
- : "memory", K_CALL_CLOB_REGS K_CLOB_ARGS_##nr \
- ); \
- __sys_res = (long)__res; \
- } \
- if ( (unsigned long)__sys_res >= (unsigned long)-4095 ){ \
- errno = -__sys_res; \
- __sys_res = -1; \
- } \
- __sys_res; \
-})
-
+ "%r20", "%r29", "%r31"
+
+#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+(__extension__ \
+ ({ \
+ register unsigned long __res __asm__("r28"); \
+ K_LOAD_ARGS_##nr(args) \
+ /* FIXME: HACK stw/ldw r19 around syscall */ \
+ __asm__ __volatile__( \
+ K_STW_ASM_PIC \
+ " ble 0x100(%%sr2, %%r0)\n" \
+ " ldi %1, %%r20\n" \
+ K_LDW_ASM_PIC \
+ : "=r" (__res) \
+ : "i" (name) K_ASM_ARGS_##nr \
+ : "memory", K_CALL_CLOB_REGS K_CLOB_ARGS_##nr \
+ ); \
+ __res; \
+ }) \
+)
#define K_LOAD_ARGS_0()
#define K_LOAD_ARGS_1(r26) \
register unsigned long __r26 __asm__("r26") = (unsigned long)(r26); \
@@ -107,49 +96,5 @@
#define K_CLOB_ARGS_1 K_CLOB_ARGS_2, "%r25"
#define K_CLOB_ARGS_0 K_CLOB_ARGS_1, "%r26"
-#define _syscall0(type,name) \
-type name(void) \
-{ \
- return (type) K_INLINE_SYSCALL(name, 0); \
-}
-
-#define _syscall1(type,name,type1,arg1) \
-type name(type1 arg1) \
-{ \
- return (type) K_INLINE_SYSCALL(name, 1, arg1); \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name(type1 arg1, type2 arg2) \
-{ \
- return (type) K_INLINE_SYSCALL(name, 2, arg1, arg2); \
-}
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name(type1 arg1, type2 arg2, type3 arg3) \
-{ \
- return (type) K_INLINE_SYSCALL(name, 3, arg1, arg2, arg3); \
-}
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
-{ \
- return (type) K_INLINE_SYSCALL(name, 4, arg1, arg2, arg3, arg4); \
-}
-
-/* select takes 5 arguments */
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
-{ \
- return (type) K_INLINE_SYSCALL(name, 5, arg1, arg2, arg3, arg4, arg5); \
-}
-
-/* mmap & mmap2 take 6 arguments */
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
-{ \
- return (type) K_INLINE_SYSCALL(name, 6, arg1, arg2, arg3, arg4, arg5, arg6); \
-}
-
#endif /* __ASSEMBLER__ */
#endif /* _BITS_SYSCALLS_H */
diff --git a/libc/sysdeps/linux/hppa/bits/uClibc_arch_features.h b/libc/sysdeps/linux/hppa/bits/uClibc_arch_features.h
index 2c04f1b77..19fa05109 100644
--- a/libc/sysdeps/linux/hppa/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/hppa/bits/uClibc_arch_features.h
@@ -9,28 +9,28 @@
#define __UCLIBC_ABORT_INSTRUCTION__ "iitlbp %r0,(%sr0,%r0)"
/* can your target use syscall6() for mmap ? */
-#undef __UCLIBC_MMAP_HAS_6_ARGS__
+#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 align 64bit values in register pairs ? (32bit arches only) */
+#undef __UCLIBC_SYSCALL_ALIGN_64BIT__
/* 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__
diff --git a/libc/sysdeps/linux/hppa/brk.c b/libc/sysdeps/linux/hppa/brk.c
index dab2d57ca..0a8590d02 100644
--- a/libc/sysdeps/linux/hppa/brk.c
+++ b/libc/sysdeps/linux/hppa/brk.c
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <errno.h>
#include <sys/syscall.h>
@@ -24,13 +23,12 @@
/* This must be initialized data because commons can't have aliases. */
void *__curbrk attribute_hidden = 0;
-libc_hidden_proto(brk)
int
brk (void *addr)
{
void *newbrk;
- __curbrk = newbrk = (void *) K_INLINE_SYSCALL (brk, 1, addr);
+ __curbrk = newbrk = (void *) INLINE_SYSCALL (brk, 1, addr);
if (newbrk < addr)
{
diff --git a/libc/sysdeps/linux/hppa/bsd-_setjmp.S b/libc/sysdeps/linux/hppa/bsd-_setjmp.S
index 30e53f562..5ecaf4cd7 100644
--- a/libc/sysdeps/linux/hppa/bsd-_setjmp.S
+++ b/libc/sysdeps/linux/hppa/bsd-_setjmp.S
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* This just does a tail-call to `__sigsetjmp (ARG, 1)'.
We cannot do it in C because it must be a tail-call, so frame-unwinding
diff --git a/libc/sysdeps/linux/hppa/bsd-setjmp.S b/libc/sysdeps/linux/hppa/bsd-setjmp.S
index 04ddba465..24053f3ab 100644
--- a/libc/sysdeps/linux/hppa/bsd-setjmp.S
+++ b/libc/sysdeps/linux/hppa/bsd-setjmp.S
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* This just does a tail-call to `__sigsetjmp (ARG, 1)'.
We cannot do it in C because it must be a tail-call, so frame-unwinding
diff --git a/libc/sysdeps/linux/hppa/clone.S b/libc/sysdeps/linux/hppa/clone.S
index b8e354cda..f6c153b01 100644
--- a/libc/sysdeps/linux/hppa/clone.S
+++ b/libc/sysdeps/linux/hppa/clone.S
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* clone() is even more special than fork() as it mucks with stacks
and invokes a function in the right context after its all over. */
diff --git a/libc/sysdeps/linux/hppa/crt1.S b/libc/sysdeps/linux/hppa/crt1.S
index 8b42dacde..87080b137 100644
--- a/libc/sysdeps/linux/hppa/crt1.S
+++ b/libc/sysdeps/linux/hppa/crt1.S
@@ -30,9 +30,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
.import main, code
.import $global$, data
diff --git a/libc/sysdeps/linux/hppa/jmpbuf-offsets.h b/libc/sysdeps/linux/hppa/jmpbuf-offsets.h
new file mode 100644
index 000000000..c579e83bb
--- /dev/null
+++ b/libc/sysdeps/linux/hppa/jmpbuf-offsets.h
@@ -0,0 +1,19 @@
+/* Private macros for accessing __jmp_buf contents. HPPA version.
+ Copyright (C) 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#define JB_SP (76/4)
diff --git a/libc/sysdeps/linux/hppa/jmpbuf-unwind.h b/libc/sysdeps/linux/hppa/jmpbuf-unwind.h
new file mode 100644
index 000000000..0590754f8
--- /dev/null
+++ b/libc/sysdeps/linux/hppa/jmpbuf-unwind.h
@@ -0,0 +1,12 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+#include <setjmp.h>
+#include <jmpbuf-offsets.h>
+
+/* Test if longjmp to JMPBUF would unwind the frame containing a local
+ variable at ADDRESS. */
+#define _JMPBUF_UNWINDS(_jmpbuf, _address) \
+ ((void *)(_address) > (void *)(((unsigned long *) _jmpbuf)[JB_SP]))
diff --git a/libc/sysdeps/linux/hppa/lshift.s b/libc/sysdeps/linux/hppa/lshift.s
index 151b283e5..d86bb6a30 100644
--- a/libc/sysdeps/linux/hppa/lshift.s
+++ b/libc/sysdeps/linux/hppa/lshift.s
@@ -15,9 +15,8 @@
;! License for more details.
;! You should have received a copy of the GNU Lesser General Public License
-;! along with the GNU MP 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.
+;! along with the GNU MP Library; see the file COPYING.LIB. If not, see
+;! <http://www.gnu.org/licenses/>.
;! INPUT PARAMETERS
diff --git a/libc/sysdeps/linux/hppa/mmap.c b/libc/sysdeps/linux/hppa/mmap.c
deleted file mode 100644
index baaee6847..000000000
--- a/libc/sysdeps/linux/hppa/mmap.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * mmap() for uClibc/x86_64
- *
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- * Copyright (C) 2005 by Mike Frysinger <vapier@gentoo.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-#include <errno.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <sys/syscall.h>
-
-libc_hidden_proto(mmap)
-
-_syscall6(void *, mmap, void *, start, size_t, length, int, prot,
- int, flags, int, fd, off_t, offset);
-libc_hidden_def(mmap)
diff --git a/libc/sysdeps/linux/hppa/rshift.s b/libc/sysdeps/linux/hppa/rshift.s
index dff189dc4..5517825c1 100644
--- a/libc/sysdeps/linux/hppa/rshift.s
+++ b/libc/sysdeps/linux/hppa/rshift.s
@@ -15,9 +15,8 @@
;! License for more details.
;! You should have received a copy of the GNU Lesser General Public License
-;! along with the GNU MP 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.
+;! along with the GNU MP Library; see the file COPYING.LIB. If not, see
+;! <http://www.gnu.org/licenses/>.
;! INPUT PARAMETERS
diff --git a/libc/sysdeps/linux/hppa/setjmp.S b/libc/sysdeps/linux/hppa/setjmp.S
index fdc4c424b..fa5bb8eca 100644
--- a/libc/sysdeps/linux/hppa/setjmp.S
+++ b/libc/sysdeps/linux/hppa/setjmp.S
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
.text
.align 4
diff --git a/libc/sysdeps/linux/hppa/sub_n.s b/libc/sysdeps/linux/hppa/sub_n.s
index 7764961a2..768b670a0 100644
--- a/libc/sysdeps/linux/hppa/sub_n.s
+++ b/libc/sysdeps/linux/hppa/sub_n.s
@@ -16,9 +16,8 @@
;! License for more details.
;! You should have received a copy of the GNU Lesser General Public License
-;! along with the GNU MP 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.
+;! along with the GNU MP Library; see the file COPYING.LIB. If not, see
+;! <http://www.gnu.org/licenses/>.
;! INPUT PARAMETERS
diff --git a/libc/sysdeps/linux/hppa/sys/procfs.h b/libc/sysdeps/linux/hppa/sys/procfs.h
index 2e6d10956..8d12dfb65 100644
--- a/libc/sysdeps/linux/hppa/sys/procfs.h
+++ b/libc/sysdeps/linux/hppa/sys/procfs.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2015 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
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library. If not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_PROCFS_H
#define _SYS_PROCFS_H 1
@@ -29,15 +28,21 @@
GDB unless you know what you are doing. */
#include <features.h>
-#include <signal.h>
#include <sys/time.h>
#include <sys/types.h>
-#include <sys/ucontext.h>
#include <sys/user.h>
-#include <asm/elf.h>
__BEGIN_DECLS
+typedef unsigned long elf_greg_t;
+#define ELF_NGREG 80 /* We only need 64 at present, but leave space
+ for expansion. */
+typedef elf_greg_t elf_gregset_t[ELF_NGREG];
+
+#define ELF_NFPREG 32
+typedef double elf_fpreg_t;
+typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
+
struct elf_siginfo
{
int si_signo; /* Signal number. */
diff --git a/libc/sysdeps/linux/hppa/sys/ucontext.h b/libc/sysdeps/linux/hppa/sys/ucontext.h
index 143114384..4c293ef6c 100644
--- a/libc/sysdeps/linux/hppa/sys/ucontext.h
+++ b/libc/sysdeps/linux/hppa/sys/ucontext.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* Don't rely on this, the interface is currently messed up and may need to
be broken to be fixed. */
diff --git a/libc/sysdeps/linux/hppa/sys/user.h b/libc/sysdeps/linux/hppa/sys/user.h
new file mode 100644
index 000000000..c871f1a03
--- /dev/null
+++ b/libc/sysdeps/linux/hppa/sys/user.h
@@ -0,0 +1 @@
+/* This file is not needed, but in practice gdb might try to include it. */
diff --git a/libc/sysdeps/linux/hppa/syscall.c b/libc/sysdeps/linux/hppa/syscall.c
index cd11e084e..e22b290f1 100644
--- a/libc/sysdeps/linux/hppa/syscall.c
+++ b/libc/sysdeps/linux/hppa/syscall.c
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <stdarg.h>
#include <errno.h>
diff --git a/libc/sysdeps/linux/hppa/udiv_qrnnd.s b/libc/sysdeps/linux/hppa/udiv_qrnnd.s
index 8e9c07a20..5304c6a86 100644
--- a/libc/sysdeps/linux/hppa/udiv_qrnnd.s
+++ b/libc/sysdeps/linux/hppa/udiv_qrnnd.s
@@ -16,9 +16,8 @@
;! License for more details.
;! You should have received a copy of the GNU Lesser General Public License
-;! along with the GNU MP 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.
+;! along with the GNU MP Library; see the file COPYING.LIB. If not, see
+;! <http://www.gnu.org/licenses/>.
;! INPUT PARAMETERS
diff --git a/libc/sysdeps/linux/i386/Makefile.arch b/libc/sysdeps/linux/i386/Makefile.arch
index bff33a8f2..1c72d23fd 100644
--- a/libc/sysdeps/linux/i386/Makefile.arch
+++ b/libc/sysdeps/linux/i386/Makefile.arch
@@ -5,15 +5,14 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-CSRC := brk.c sigaction.c __syscall_error.c
+CSRC-y := brk.c __syscall_error.c sigaction.c
-SSRC := \
- __longjmp.S vfork.S clone.S setjmp.S bsd-setjmp.S bsd-_setjmp.S \
- sync_file_range.S syscall.S mmap.S mmap64.S
+SSRC-y := \
+ __longjmp.S setjmp.S bsd-setjmp.S bsd-_setjmp.S \
+ sync_file_range.S syscall.S mmap.S \
+ copysign.S
-ifeq ($(UCLIBC_HAS_ADVANCED_REALTIME),y)
-SSRC += posix_fadvise64.S
-CSRC += posix_fadvise.c
-endif
-
-include $(top_srcdir)libc/sysdeps/linux/Makefile.commonarch
+SSRC-$(UCLIBC_HAS_LFS) += mmap64.S
+SSRC-$(if $(findstring yy,$(UCLIBC_HAS_ADVANCED_REALTIME)$(UCLIBC_HAS_LFS)),y) += posix_fadvise64.S
+SSRC-$(if $(UCLIBC_HAS_THREADS_NATIVE),,y) += vfork.S clone.S
+SSRC-$(UCLIBC_HAS_CONTEXT_FUNCS) += makecontext.S setcontext.S getcontext.S swapcontext.S
diff --git a/libc/sysdeps/linux/i386/__longjmp.S b/libc/sysdeps/linux/i386/__longjmp.S
index e2809c06c..dd71b7c08 100644
--- a/libc/sysdeps/linux/i386/__longjmp.S
+++ b/libc/sysdeps/linux/i386/__longjmp.S
@@ -14,13 +14,9 @@
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. */
+ see <http://www.gnu.org/licenses/>. */
-#include <features.h>
-#define _ASM
-#define _SETJMP_H
-#include <bits/setjmp.h>
+#include <jmpbuf-offsets.h>
.global __longjmp
.type __longjmp,%function
diff --git a/libc/sysdeps/linux/i386/__syscall_error.c b/libc/sysdeps/linux/i386/__syscall_error.c
index 7509d4409..36946bc6d 100644
--- a/libc/sysdeps/linux/i386/__syscall_error.c
+++ b/libc/sysdeps/linux/i386/__syscall_error.c
@@ -28,9 +28,8 @@
int __syscall_error(void) attribute_hidden;
int __syscall_error(void)
{
- register int edx __asm__ ("%edx");
- __asm__ ("mov %eax, %edx\n\t"
- "negl %edx");
- __set_errno (edx);
+ register int eax __asm__ ("%eax");
+ int _errno = -eax;
+ __set_errno (_errno);
return -1;
}
diff --git a/libc/sysdeps/linux/i386/bits/atomic.h b/libc/sysdeps/linux/i386/bits/atomic.h
index a20f424f8..66849acbc 100644
--- a/libc/sysdeps/linux/i386/bits/atomic.h
+++ b/libc/sysdeps/linux/i386/bits/atomic.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <stdint.h>
@@ -60,21 +59,21 @@ typedef uintmax_t uatomic_max_t;
#define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
({ __typeof (*mem) ret; \
- __asm__ __volatile__ (LOCK_PREFIX "cmpxchgb %b2, %1" \
+ __asm__ __volatile__ (LOCK_PREFIX "cmpxchgb %b2, %1" \
: "=a" (ret), "=m" (*mem) \
: "q" (newval), "m" (*mem), "0" (oldval)); \
ret; })
#define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \
({ __typeof (*mem) ret; \
- __asm__ __volatile__ (LOCK_PREFIX "cmpxchgw %w2, %1" \
+ __asm__ __volatile__ (LOCK_PREFIX "cmpxchgw %w2, %1" \
: "=a" (ret), "=m" (*mem) \
: "r" (newval), "m" (*mem), "0" (oldval)); \
ret; })
#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
({ __typeof (*mem) ret; \
- __asm__ __volatile__ (LOCK_PREFIX "cmpxchgl %2, %1" \
+ __asm__ __volatile__ (LOCK_PREFIX "cmpxchgl %2, %1" \
: "=a" (ret), "=m" (*mem) \
: "r" (newval), "m" (*mem), "0" (oldval)); \
ret; })
@@ -92,7 +91,7 @@ typedef uintmax_t uatomic_max_t;
# ifdef __PIC__
# define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
({ __typeof (*mem) ret; \
- __asm__ __volatile__ ("xchgl %2, %%ebx\n\t" \
+ __asm__ __volatile__ ("xchgl %2, %%ebx\n\t" \
LOCK_PREFIX "cmpxchg8b %1\n\t" \
"xchgl %2, %%ebx" \
: "=A" (ret), "=m" (*mem) \
@@ -131,7 +130,7 @@ typedef uintmax_t uatomic_max_t;
: "=r" (result), "=m" (*mem) \
: "0" (newvalue), "m" (*mem)); \
else if (sizeof (*mem) == 4) \
- __asm__ __volatile__ ("xchgl %0, %1" \
+ __asm__ __volatile__ ("xchgl %0, %1" \
: "=r" (result), "=m" (*mem) \
: "0" (newvalue), "m" (*mem)); \
else \
@@ -146,11 +145,11 @@ typedef uintmax_t uatomic_max_t;
({ __typeof (*mem) __result; \
__typeof (value) __addval = (value); \
if (sizeof (*mem) == 1) \
- __asm__ __volatile__ (LOCK_PREFIX "xaddb %b0, %1" \
+ __asm__ __volatile__ (LOCK_PREFIX "xaddb %b0, %1" \
: "=r" (__result), "=m" (*mem) \
: "0" (__addval), "m" (*mem)); \
else if (sizeof (*mem) == 2) \
- __asm__ __volatile__ (LOCK_PREFIX "xaddw %w0, %1" \
+ __asm__ __volatile__ (LOCK_PREFIX "xaddw %w0, %1" \
: "=r" (__result), "=m" (*mem) \
: "0" (__addval), "m" (*mem)); \
else if (sizeof (*mem) == 4) \
@@ -204,11 +203,11 @@ typedef uintmax_t uatomic_max_t;
#define atomic_add_negative(mem, value) \
({ unsigned char __result; \
if (sizeof (*mem) == 1) \
- __asm__ __volatile__ (LOCK_PREFIX "addb %b2, %0; sets %1" \
+ __asm__ __volatile__ (LOCK_PREFIX "addb %b2, %0; sets %1" \
: "=m" (*mem), "=qm" (__result) \
: "iq" (value), "m" (*mem)); \
else if (sizeof (*mem) == 2) \
- __asm__ __volatile__ (LOCK_PREFIX "addw %w2, %0; sets %1" \
+ __asm__ __volatile__ (LOCK_PREFIX "addw %w2, %0; sets %1" \
: "=m" (*mem), "=qm" (__result) \
: "ir" (value), "m" (*mem)); \
else if (sizeof (*mem) == 4) \
@@ -223,11 +222,11 @@ typedef uintmax_t uatomic_max_t;
#define atomic_add_zero(mem, value) \
({ unsigned char __result; \
if (sizeof (*mem) == 1) \
- __asm__ __volatile__ (LOCK_PREFIX "addb %b2, %0; setz %1" \
+ __asm__ __volatile__ (LOCK_PREFIX "addb %b2, %0; setz %1" \
: "=m" (*mem), "=qm" (__result) \
: "ir" (value), "m" (*mem)); \
else if (sizeof (*mem) == 2) \
- __asm__ __volatile__ (LOCK_PREFIX "addw %w2, %0; setz %1" \
+ __asm__ __volatile__ (LOCK_PREFIX "addw %w2, %0; setz %1" \
: "=m" (*mem), "=qm" (__result) \
: "ir" (value), "m" (*mem)); \
else if (sizeof (*mem) == 4) \
@@ -241,15 +240,15 @@ typedef uintmax_t uatomic_max_t;
#define atomic_increment(mem) \
(void) ({ if (sizeof (*mem) == 1) \
- __asm__ __volatile__ (LOCK_PREFIX "incb %b0" \
+ __asm__ __volatile__ (LOCK_PREFIX "incb %b0" \
: "=m" (*mem) \
: "m" (*mem)); \
else if (sizeof (*mem) == 2) \
- __asm__ __volatile__ (LOCK_PREFIX "incw %w0" \
+ __asm__ __volatile__ (LOCK_PREFIX "incw %w0" \
: "=m" (*mem) \
: "m" (*mem)); \
else if (sizeof (*mem) == 4) \
- __asm__ __volatile__ (LOCK_PREFIX "incl %0" \
+ __asm__ __volatile__ (LOCK_PREFIX "incl %0" \
: "=m" (*mem) \
: "m" (*mem)); \
else \
@@ -276,7 +275,7 @@ typedef uintmax_t uatomic_max_t;
: "=m" (*mem), "=qm" (__result) \
: "m" (*mem)); \
else if (sizeof (*mem) == 4) \
- __asm__ __volatile__ (LOCK_PREFIX "incl %0; sete %1" \
+ __asm__ __volatile__ (LOCK_PREFIX "incl %0; sete %1" \
: "=m" (*mem), "=qm" (__result) \
: "m" (*mem)); \
else \
@@ -286,15 +285,15 @@ typedef uintmax_t uatomic_max_t;
#define atomic_decrement(mem) \
(void) ({ if (sizeof (*mem) == 1) \
- __asm__ __volatile__ (LOCK_PREFIX "decb %b0" \
+ __asm__ __volatile__ (LOCK_PREFIX "decb %b0" \
: "=m" (*mem) \
: "m" (*mem)); \
else if (sizeof (*mem) == 2) \
- __asm__ __volatile__ (LOCK_PREFIX "decw %w0" \
+ __asm__ __volatile__ (LOCK_PREFIX "decw %w0" \
: "=m" (*mem) \
: "m" (*mem)); \
else if (sizeof (*mem) == 4) \
- __asm__ __volatile__ (LOCK_PREFIX "decl %0" \
+ __asm__ __volatile__ (LOCK_PREFIX "decl %0" \
: "=m" (*mem) \
: "m" (*mem)); \
else \
@@ -305,7 +304,7 @@ typedef uintmax_t uatomic_max_t;
do \
__tmpval = __oldval; \
while ((__oldval = __arch_compare_and_exchange_val_64_acq \
- (__memp, __oldval - 1, __oldval)) == __tmpval); \
+ (__memp, __oldval - 1, __oldval)) == __tmpval); \
} \
})
@@ -321,7 +320,7 @@ typedef uintmax_t uatomic_max_t;
: "=m" (*mem), "=qm" (__result) \
: "m" (*mem)); \
else if (sizeof (*mem) == 4) \
- __asm__ __volatile__ (LOCK_PREFIX "decl %0; sete %1" \
+ __asm__ __volatile__ (LOCK_PREFIX "decl %0; sete %1" \
: "=m" (*mem), "=qm" (__result) \
: "m" (*mem)); \
else \
@@ -361,7 +360,7 @@ typedef uintmax_t uatomic_max_t;
__asm__ __volatile__ (LOCK_PREFIX "btsl %3, %1; setc %0" \
: "=q" (__result), "=m" (*mem) \
: "m" (*mem), "ir" (bit)); \
- else \
+ else \
abort (); \
__result; })
diff --git a/libc/sysdeps/linux/i386/bits/byteswap.h b/libc/sysdeps/linux/i386/bits/byteswap.h
index 33af20888..651852e57 100644
--- a/libc/sysdeps/linux/i386/bits/byteswap.h
+++ b/libc/sysdeps/linux/i386/bits/byteswap.h
@@ -13,121 +13,43 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
-#if !defined _BYTESWAP_H && !defined _NETINET_IN_H
-# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
-#endif
-
-#ifndef _BITS_BYTESWAP_H
-#define _BITS_BYTESWAP_H 1
+#ifndef _ASM_BITS_BYTESWAP_H
+#define _ASM_BITS_BYTESWAP_H 1
-/* Swap bytes in 16 bit value. */
-#define __bswap_constant_16(x) \
- ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))
-
-#ifdef __GNUC__
-# if __GNUC__ >= 2
-# define __bswap_16(x) \
+#define __bswap_non_constant_16(x) \
(__extension__ \
- ({ register unsigned short int __v, __x = (x); \
- if (__builtin_constant_p (__x)) \
- __v = __bswap_constant_16 (__x); \
- else \
- __asm__ ("rorw $8, %w0" \
- : "=r" (__v) \
- : "0" (__x) \
- : "cc"); \
+ ({ register unsigned short int __v; \
+ __asm__ ("rorw $8, %w0" \
+ : "=r" (__v) \
+ : "0" (x) \
+ : "cc"); \
__v; }))
-# else
-/* This is better than nothing. */
-# define __bswap_16(x) \
- (__extension__ \
- ({ register unsigned short int __x = (x); __bswap_constant_16 (__x); }))
-# endif
-#else
-static __inline unsigned short int
-__bswap_16 (unsigned short int __bsx)
-{
- return __bswap_constant_16 (__bsx);
-}
-#endif
-
-/* Swap bytes in 32 bit value. */
-#define __bswap_constant_32(x) \
- ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
- (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
-#ifdef __GNUC__
-# if __GNUC__ >= 2
/* To swap the bytes in a word the i486 processors and up provide the
`bswap' opcode. On i386 we have to use three instructions. */
-# if !defined __i486__ && !defined __pentium__ && !defined __pentiumpro__ \
+#if !defined __i486__ && !defined __pentium__ && !defined __pentiumpro__ \
&& !defined __pentium4__
-# define __bswap_32(x) \
+# define __bswap_non_constant_32(x) \
(__extension__ \
- ({ register unsigned int __v, __x = (x); \
- if (__builtin_constant_p (__x)) \
- __v = __bswap_constant_32 (__x); \
- else \
- __asm__ ("rorw $8, %w0;" \
- "rorl $16, %0;" \
- "rorw $8, %w0" \
- : "=r" (__v) \
- : "0" (__x) \
- : "cc"); \
+ ({ register unsigned int __v; \
+ __asm__ ("rorw $8, %w0;" \
+ "rorl $16, %0;" \
+ "rorw $8, %w0" \
+ : "=r" (__v) \
+ : "0" (x) \
+ : "cc"); \
__v; }))
-# else
-# define __bswap_32(x) \
+#else
+# define __bswap_non_constant_32(x) \
(__extension__ \
- ({ register unsigned int __v, __x = (x); \
- if (__builtin_constant_p (__x)) \
- __v = __bswap_constant_32 (__x); \
- else \
- __asm__ ("bswap %0" : "=r" (__v) : "0" (__x)); \
+ ({ register unsigned int __v; \
+ __asm__ ("bswap %0" : "=r" (__v) : "0" (x)); \
__v; }))
-# endif
-# else
-# define __bswap_32(x) \
- (__extension__ \
- ({ register unsigned int __x = (x); __bswap_constant_32 (__x); }))
-# endif
-#else
-static __inline unsigned int
-__bswap_32 (unsigned int __bsx)
-{
- return __bswap_constant_32 (__bsx);
-}
#endif
-
-#if defined __GNUC__ && __GNUC__ >= 2
-/* Swap bytes in 64 bit value. */
-#define __bswap_constant_64(x) \
- ((((x) & 0xff00000000000000ull) >> 56) \
- | (((x) & 0x00ff000000000000ull) >> 40) \
- | (((x) & 0x0000ff0000000000ull) >> 24) \
- | (((x) & 0x000000ff00000000ull) >> 8) \
- | (((x) & 0x00000000ff000000ull) << 8) \
- | (((x) & 0x0000000000ff0000ull) << 24) \
- | (((x) & 0x000000000000ff00ull) << 40) \
- | (((x) & 0x00000000000000ffull) << 56))
-
-# define __bswap_64(x) \
- (__extension__ \
- ({ union { __extension__ unsigned long long int __ll; \
- unsigned long int __l[2]; } __w, __r; \
- if (__builtin_constant_p (x)) \
- __r.__ll = __bswap_constant_64 (x); \
- else \
- { \
- __w.__ll = (x); \
- __r.__l[0] = __bswap_32 (__w.__l[1]); \
- __r.__l[1] = __bswap_32 (__w.__l[0]); \
- } \
- __r.__ll; }))
#endif
-#endif /* _BITS_BYTESWAP_H */
+#include <bits/byteswap-common.h>
diff --git a/libc/sysdeps/linux/i386/bits/fcntl.h b/libc/sysdeps/linux/i386/bits/fcntl.h
index 0b53b459b..4dfeae831 100644
--- a/libc/sysdeps/linux/i386/bits/fcntl.h
+++ b/libc/sysdeps/linux/i386/bits/fcntl.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FCNTL_H
# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
@@ -50,9 +49,8 @@
# define O_DIRECTORY 0200000 /* Must be a directory. */
# define O_NOFOLLOW 0400000 /* Do not follow links. */
# define O_NOATIME 01000000 /* Do not set atime. */
-# if 0
# define O_CLOEXEC 02000000 /* Set close_on_exec. */
-# endif
+# define O_PATH 010000000 /* Resolve pathname but do not open file. */
#endif
/* For now Linux has synchronisity options for data and read operations.
@@ -102,6 +100,8 @@
# define F_NOTIFY 1026 /* Request notfications on a directory. */
# define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with
close-on-exit set on new fd. */
+# define F_SETPIPE_SZ 1031 /* Set pipe page size array. */
+# define F_GETPIPE_SZ 1032 /* Get pipe page size array. */
#endif
/* For F_[GET|SET]FD. */
@@ -189,7 +189,7 @@ struct flock64
#endif
-#ifdef __USE_GNU
+#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
@@ -212,7 +212,7 @@ struct flock64
__BEGIN_DECLS
-#ifdef __USE_GNU
+#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)
diff --git a/libc/sysdeps/linux/i386/bits/fenv.h b/libc/sysdeps/linux/i386/bits/fenv.h
index ef3fcb384..9bd976fc1 100644
--- a/libc/sysdeps/linux/i386/bits/fenv.h
+++ b/libc/sysdeps/linux/i386/bits/fenv.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FENV_H
# error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
@@ -82,9 +81,9 @@ typedef struct
fenv_t;
/* If the default argument is used we use this value. */
-#define FE_DFL_ENV ((__const fenv_t *) -1)
+#define FE_DFL_ENV ((const fenv_t *) -1)
#ifdef __USE_GNU
/* Floating-point environment where none of the exception is masked. */
-# define FE_NOMASK_ENV ((__const fenv_t *) -2)
+# define FE_NOMASK_ENV ((const fenv_t *) -2)
#endif
diff --git a/libc/sysdeps/linux/i386/bits/huge_vall.h b/libc/sysdeps/linux/i386/bits/huge_vall.h
new file mode 100644
index 000000000..7e9c24d8a
--- /dev/null
+++ b/libc/sysdeps/linux/i386/bits/huge_vall.h
@@ -0,0 +1,42 @@
+/* `HUGE_VALL' constant for ix86 (where it is infinity).
+ Used by <stdlib.h> and <math.h> functions for overflow.
+ Copyright (C) 1992, 1995, 1996, 1997, 1999, 2000, 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.
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _MATH_H
+# error "Never use <bits/huge_vall.h> directly; include <math.h> instead."
+#endif
+
+#if __GNUC_PREREQ(3,3)
+# define HUGE_VALL (__builtin_huge_vall())
+#elif __GNUC_PREREQ(2,96)
+# define HUGE_VALL (__extension__ 0x1.0p32767L)
+#else
+
+# define __HUGE_VALL_bytes { 0, 0, 0, 0, 0, 0, 0, 0x80, 0xff, 0x7f, 0, 0 }
+
+# define __huge_vall_t union { unsigned char __c[12]; long double __ld; }
+# ifdef __GNUC__
+# define HUGE_VALL (__extension__ \
+ ((__huge_vall_t) { __c: __HUGE_VALL_bytes }).__ld)
+# else /* Not GCC. */
+static __huge_vall_t __huge_vall = { __HUGE_VALL_bytes };
+# define HUGE_VALL (__huge_vall.__ld)
+# endif /* GCC. */
+
+#endif /* GCC 2.95 */
diff --git a/libc/sysdeps/linux/i386/bits/kernel_stat.h b/libc/sysdeps/linux/i386/bits/kernel_stat.h
index 20eb6d2ef..231a984b4 100644
--- a/libc/sysdeps/linux/i386/bits/kernel_stat.h
+++ b/libc/sysdeps/linux/i386/bits/kernel_stat.h
@@ -1,17 +1,12 @@
#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... */
struct kernel_stat {
- unsigned short st_dev;
- unsigned short __pad1;
+ unsigned long st_dev;
unsigned long st_ino;
unsigned short st_mode;
unsigned short st_nlink;
@@ -22,19 +17,16 @@ struct kernel_stat {
unsigned long st_size;
unsigned long st_blksize;
unsigned long st_blocks;
- unsigned long st_atime;
- unsigned long __unused1;
- unsigned long st_mtime;
- unsigned long __unused2;
- unsigned long st_ctime;
- unsigned long __unused3;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
unsigned long __unused4;
unsigned long __unused5;
};
struct kernel_stat64 {
- unsigned short st_dev;
- unsigned char __pad0[10];
+ unsigned long long st_dev;
+ unsigned char __pad0[4];
#define _HAVE_STAT64___ST_INO
unsigned long __st_ino;
unsigned int st_mode;
@@ -47,12 +39,9 @@ struct kernel_stat64 {
unsigned long st_blksize;
unsigned long st_blocks; /* Number 512-byte blocks allocated. */
unsigned long __pad4; /* future possible st_blocks high bits */
- unsigned long st_atime;
- unsigned long __pad5;
- unsigned long st_mtime;
- unsigned long __pad6;
- unsigned long st_ctime;
- unsigned long __pad7; /* will be high 32 bits of ctime someday */
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
unsigned long long st_ino;
};
diff --git a/libc/sysdeps/linux/i386/bits/kernel_types.h b/libc/sysdeps/linux/i386/bits/kernel_types.h
index 6609dd312..59044b8e6 100644
--- a/libc/sysdeps/linux/i386/bits/kernel_types.h
+++ b/libc/sysdeps/linux/i386/bits/kernel_types.h
@@ -7,9 +7,14 @@
/* a hack for compiling a 32 bit user space with 64 bit
* kernel on x86_64 */
-#if !defined(__ARCH_I386_POSIX_TYPES_H) && !defined(_ASM_X86_64_POSIX_TYPES_H)
+#if !defined(__ARCH_I386_POSIX_TYPES_H) && \
+ !defined(_ASM_X86_64_POSIX_TYPES_H) && \
+ !defined(_ASM_X86_POSIX_TYPES_32_H) && \
+ !defined(_ASM_X86_POSIX_TYPES_64_H)
#define _ASM_X86_64_POSIX_TYPES_H
#define __ARCH_I386_POSIX_TYPES_H
+#define _ASM_X86_POSIX_TYPES_32_H
+#define _ASM_X86_POSIX_TYPES_64_H
typedef unsigned short __kernel_dev_t;
typedef unsigned long __kernel_ino_t;
@@ -35,6 +40,8 @@ typedef unsigned int __kernel_gid32_t;
typedef unsigned short __kernel_old_uid_t;
typedef unsigned short __kernel_old_gid_t;
typedef __kernel_dev_t __kernel_old_dev_t;
+typedef long __kernel_long_t;
+typedef unsigned long __kernel_ulong_t;
typedef long long __kernel_loff_t;
typedef struct {
@@ -45,4 +52,4 @@ typedef struct {
#endif
} __kernel_fsid_t;
-#endif /* __ARCH_I386_POSIX_TYPES_H */
+#endif
diff --git a/libc/sysdeps/linux/i386/bits/mathdef.h b/libc/sysdeps/linux/i386/bits/mathdef.h
index a3786fc81..ca4d5e5eb 100644
--- a/libc/sysdeps/linux/i386/bits/mathdef.h
+++ b/libc/sysdeps/linux/i386/bits/mathdef.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#if !defined _MATH_H && !defined _COMPLEX_H
# error "Never use <bits/mathdef.h> directly; include <math.h> instead"
diff --git a/libc/sysdeps/linux/i386/bits/mathinline.h b/libc/sysdeps/linux/i386/bits/mathinline.h
index ca7277d76..b3a50a538 100644
--- a/libc/sysdeps/linux/i386/bits/mathinline.h
+++ b/libc/sysdeps/linux/i386/bits/mathinline.h
@@ -15,9 +15,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _MATH_H
# error "Never use <bits/mathinline.h> directly; include <math.h> instead."
@@ -26,7 +25,7 @@
#ifdef __cplusplus
# define __MATH_INLINE __inline
#else
-# define __MATH_INLINE extern __inline
+# define __MATH_INLINE __extern_inline
#endif
@@ -206,7 +205,7 @@ __NTH (__signbitl (long double __x))
__MATH_INLINE float_type __NTH (func (float_type __x)) \
{ \
register float_type __result; \
- __asm__ __volatile__ (op : "=t" (__result) : params); \
+ __asm__ __volatile__ (op : "=t" (__result) : params); \
return __result; \
}
@@ -529,8 +528,8 @@ __inline_mathcodeNP (tanh, __x, \
__inline_mathcodeNP (floor, __x, \
register long double __value; \
- __volatile unsigned short int __cw; \
- __volatile unsigned short int __cwtmp; \
+ __volatile__ unsigned short int __cw; \
+ __volatile__ unsigned short int __cwtmp; \
__asm__ __volatile__ ("fnstcw %0" : "=m" (__cw)); \
__cwtmp = (__cw & 0xf3ff) | 0x0400; /* rounding down */ \
__asm__ __volatile__ ("fldcw %0" : : "m" (__cwtmp)); \
@@ -540,8 +539,8 @@ __inline_mathcodeNP (floor, __x, \
__inline_mathcodeNP (ceil, __x, \
register long double __value; \
- __volatile unsigned short int __cw; \
- __volatile unsigned short int __cwtmp; \
+ __volatile__ unsigned short int __cw; \
+ __volatile__ unsigned short int __cwtmp; \
__asm__ __volatile__ ("fnstcw %0" : "=m" (__cw)); \
__cwtmp = (__cw & 0xf3ff) | 0x0800; /* rounding up */ \
__asm__ __volatile__ ("fldcw %0" : : "m" (__cwtmp)); \
@@ -713,11 +712,22 @@ __inline_mathcodeNP2 (drem, __x, __y, \
__MATH_INLINE int
__NTH (__finite (double __x))
{
- return (__extension__
- (((((union { double __d; int __i[2]; }) {__d: __x}).__i[1]
- | 0x800fffffu) + 1) >> 31));
+ union { double __d; int __i[2]; } u;
+ u.__d = __x;
+ /* Finite numbers have at least one zero bit in exponent. */
+ /* All other numbers will result in 0xffffffff after OR: */
+ return (u.__i[1] | 0x800fffff) != 0xffffffff;
}
+__MATH_INLINE int
+__NTH (__finitef (float __x))
+{
+ union { float __d; int __i; } u;
+ u.__d = __x;
+ return (u.__i | 0x807fffff) != 0xffffffff;
+}
+
+
/* Miscellaneous functions */
# ifdef __FAST_MATH__
__inline_mathcode (__coshm1, __x, \
diff --git a/libc/sysdeps/linux/i386/bits/mman.h b/libc/sysdeps/linux/i386/bits/mman.h
deleted file mode 100644
index 00cb98239..000000000
--- a/libc/sysdeps/linux/i386/bits/mman.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/* Definitions for POSIX memory map interface. Linux/i386 version.
- Copyright (C) 1997, 2000, 2003, 2005, 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 _SYS_MMAN_H
-# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
-#endif
-
-/* The following definitions basically come from the kernel headers.
- But the kernel header is not namespace clean. */
-
-
-/* Protections are chosen from these bits, OR'd together. The
- implementation does not necessarily support PROT_EXEC or PROT_WRITE
- without PROT_READ. The only guarantees are that no writing will be
- allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
-
-#define PROT_READ 0x1 /* Page can be read. */
-#define PROT_WRITE 0x2 /* Page can be written. */
-#define PROT_EXEC 0x4 /* Page can be executed. */
-#define PROT_NONE 0x0 /* Page can not be accessed. */
-#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of
- growsdown vma (mprotect only). */
-#define PROT_GROWSUP 0x02000000 /* Extend change to start of
- growsup vma (mprotect only). */
-
-/* Sharing types (must choose one and only one of these). */
-#define MAP_SHARED 0x01 /* Share changes. */
-#define MAP_PRIVATE 0x02 /* Changes are private. */
-#ifdef __USE_MISC
-# define MAP_TYPE 0x0f /* Mask for type of mapping. */
-#endif
-
-/* Other flags. */
-#define MAP_FIXED 0x10 /* Interpret addr exactly. */
-#ifdef __USE_MISC
-# define MAP_FILE 0
-# define MAP_ANONYMOUS 0x20 /* Don't use a file. */
-# define MAP_ANON MAP_ANONYMOUS
-#endif
-
-/* These are Linux-specific. */
-#ifdef __USE_MISC
-# define MAP_GROWSDOWN 0x00100 /* Stack-like segment. */
-# define MAP_DENYWRITE 0x00800 /* ETXTBSY */
-# define MAP_EXECUTABLE 0x01000 /* Mark it as an executable. */
-# define MAP_LOCKED 0x02000 /* Lock the mapping. */
-# define MAP_NORESERVE 0x04000 /* Don't check for reservations. */
-# define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */
-# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */
-#endif
-
-/* Flags to `msync'. */
-#define MS_ASYNC 1 /* Sync memory asynchronously. */
-#define MS_SYNC 4 /* Synchronous memory sync. */
-#define MS_INVALIDATE 2 /* Invalidate the caches. */
-
-/* Flags for `mlockall'. */
-#define MCL_CURRENT 1 /* Lock all currently mapped pages. */
-#define MCL_FUTURE 2 /* Lock all additions to address
- space. */
-
-/* Flags for `mremap'. */
-#ifdef __USE_GNU
-# define MREMAP_MAYMOVE 1
-# define MREMAP_FIXED 2
-#endif
-
-/* Advice to `madvise'. */
-#ifdef __USE_BSD
-# define MADV_NORMAL 0 /* No further special treatment. */
-# define MADV_RANDOM 1 /* Expect random page references. */
-# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
-# define MADV_WILLNEED 3 /* Will need these pages. */
-# define MADV_DONTNEED 4 /* Don't need these pages. */
-# define MADV_REMOVE 9 /* Remove these pages and resources. */
-# define MADV_DONTFORK 10 /* Do not inherit across fork. */
-# define MADV_DOFORK 11 /* Do inherit across fork. */
-#endif
-
-/* The POSIX people had to invent similar names for the same things. */
-#ifdef __USE_XOPEN2K
-# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
-# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
-# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
-# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
-# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
-#endif
diff --git a/libc/sysdeps/linux/i386/bits/select.h b/libc/sysdeps/linux/i386/bits/select.h
index 972bfb685..541294f62 100644
--- a/libc/sysdeps/linux/i386/bits/select.h
+++ b/libc/sysdeps/linux/i386/bits/select.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_SELECT_H
# error "Never use <bits/select.h> directly; include <sys/select.h> instead."
diff --git a/libc/sysdeps/linux/i386/bits/setjmp.h b/libc/sysdeps/linux/i386/bits/setjmp.h
index 107fe58b3..6eb29f1c0 100644
--- a/libc/sysdeps/linux/i386/bits/setjmp.h
+++ b/libc/sysdeps/linux/i386/bits/setjmp.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997, 1998, 2000, 2001, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 1997,1998,2000,2001,2003,2005,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
@@ -12,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* Define the machine-dependent type `jmp_buf'. Intel 386 version. */
#ifndef _BITS_SETJMP_H
@@ -24,23 +24,6 @@
# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
#endif
-#if defined __USE_MISC || defined _ASM
-# define JB_BX 0
-# define JB_SI 1
-# define JB_DI 2
-# define JB_BP 3
-# define JB_SP 4
-# define JB_PC 5
-# define JB_SIZE 24
-#endif
-
-#ifndef _ASM
typedef int __jmp_buf[6];
-#endif
-
-/* Test if longjmp to JMPBUF would unwind the frame
- containing a local variable at ADDRESS. */
-#define _JMPBUF_UNWINDS(jmpbuf, address) \
- ((void *) (address) < (void *) (jmpbuf)[JB_SP])
#endif /* bits/setjmp.h */
diff --git a/libc/sysdeps/linux/i386/bits/sigcontextinfo.h b/libc/sysdeps/linux/i386/bits/sigcontextinfo.h
index b7367bac6..4cafabdcb 100644
--- a/libc/sysdeps/linux/i386/bits/sigcontextinfo.h
+++ b/libc/sysdeps/linux/i386/bits/sigcontextinfo.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#define SIGCONTEXT struct sigcontext
#define SIGCONTEXT_EXTRA_ARGS
diff --git a/libc/sysdeps/linux/i386/bits/stackinfo.h b/libc/sysdeps/linux/i386/bits/stackinfo.h
index a9a6745aa..e1b61fae0 100644
--- a/libc/sysdeps/linux/i386/bits/stackinfo.h
+++ b/libc/sysdeps/linux/i386/bits/stackinfo.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* This file contains a bit of information about the stack allocation
of the processor. */
diff --git a/libc/sysdeps/linux/i386/bits/syscalls.h b/libc/sysdeps/linux/i386/bits/syscalls.h
index 014539c2a..566b5acf5 100644
--- a/libc/sysdeps/linux/i386/bits/syscalls.h
+++ b/libc/sysdeps/linux/i386/bits/syscalls.h
@@ -1,211 +1,193 @@
#ifndef _BITS_SYSCALLS_H
#define _BITS_SYSCALLS_H
+
#ifndef _SYSCALL_H
# error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
#endif
/*
- Some of the sneaky macros in the code were taken from
- glibc-2.2.5/sysdeps/unix/sysv/linux/i386/sysdep.h
-*/
+ * Some of the sneaky macros in the code were taken from
+ * glibc-2.2.5/sysdeps/unix/sysv/linux/i386/sysdep.h
+ */
#ifndef __ASSEMBLER__
#include <errno.h>
-#define SYS_ify(syscall_name) (__NR_##syscall_name)
-
-#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
-
-#define INTERNAL_SYSCALL_ERROR_P(val, err) \
- ((unsigned int) (val) >= 0xfffff001u)
-
-#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
-
-/* We need some help from the assembler to generate optimal code. We
- define some macros here which later will be used. */
-
-#if defined __SUPPORT_LD_DEBUG__ && defined __DOMULTI__
-#error LD debugging and DOMULTI are incompatible
+#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+(__extension__ \
+ ({ \
+ register unsigned int resultvar; \
+ __asm__ __volatile__ ( \
+ LOADARGS_##nr \
+ "movl %1, %%eax\n\t" \
+ "int $0x80\n\t" \
+ RESTOREARGS_##nr \
+ : "=a" (resultvar) \
+ : "g" (name) ASMFMT_##nr(args) : "memory", "cc" \
+ ); \
+ (int) resultvar; \
+ }) \
+)
+
+#if 1 /* defined __PIC__ || defined __pic__ */
+
+/* This code avoids pushing/popping ebx as much as possible.
+ * I think the main reason was that older GCCs had problems
+ * with proper saving/restoring of ebx if "b" constraint was used,
+ * which was breaking -fPIC code really badly.
+ * At least gcc 4.2.x seems to not need these tricks anymore,
+ * but this code is still useful because it often avoids
+ * using stack for saving ebx.
+ * Keeping it unconditionally enabled for now.
+ */
+
+/* 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__ (
+#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"
+ ".set _BITS_SYSCALLS_ASM,1\n\t"
#endif
-
-#ifdef __DOMULTI__
-__asm__ (".L__X'%ebx = 1\n\t"
- ".L__X'%ecx = 2\n\t"
- ".L__X'%edx = 2\n\t"
- ".L__X'%eax = 3\n\t"
- ".L__X'%esi = 3\n\t"
- ".L__X'%edi = 3\n\t"
- ".L__X'%ebp = 3\n\t"
- ".L__X'%esp = 3\n\t"
- ".ifndef _BITS_SYSCALLS_ASM\n\t"
- ".set _BITS_SYSCALLS_ASM,1\n\t"
- ".macro bpushl name reg\n\t"
- ".if 1 - \\name\n\t"
- ".if 2 - \\name\n\t"
- "pushl %ebx\n\t"
- ".else\n\t"
- "xchgl \\reg, %ebx\n\t"
- ".endif\n\t"
- ".endif\n\t"
- ".endm\n\t"
- ".macro bpopl name reg\n\t"
- ".if 1 - \\name\n\t"
- ".if 2 - \\name\n\t"
- "popl %ebx\n\t"
- ".else\n\t"
- "xchgl \\reg, %ebx\n\t"
- ".endif\n\t"
- ".endif\n\t"
- ".endm\n\t"
- ".macro bmovl name reg\n\t"
- ".if 1 - \\name\n\t"
- ".if 2 - \\name\n\t"
- "movl \\reg, %ebx\n\t"
- ".endif\n\t"
- ".endif\n\t"
- ".endm\n\t"
- ".endif\n\t");
-#else
-__asm__ (".L__X'%ebx = 1\n\t"
- ".L__X'%ecx = 2\n\t"
- ".L__X'%edx = 2\n\t"
- ".L__X'%eax = 3\n\t"
- ".L__X'%esi = 3\n\t"
- ".L__X'%edi = 3\n\t"
- ".L__X'%ebp = 3\n\t"
- ".L__X'%esp = 3\n\t"
- ".macro bpushl name reg\n\t"
- ".if 1 - \\name\n\t"
- ".if 2 - \\name\n\t"
- "pushl %ebx\n\t"
- ".else\n\t"
- "xchgl \\reg, %ebx\n\t"
- ".endif\n\t"
- ".endif\n\t"
- ".endm\n\t"
- ".macro bpopl name reg\n\t"
- ".if 1 - \\name\n\t"
- ".if 2 - \\name\n\t"
- "popl %ebx\n\t"
- ".else\n\t"
- "xchgl \\reg, %ebx\n\t"
- ".endif\n\t"
- ".endif\n\t"
- ".endm\n\t"
- ".macro bmovl name reg\n\t"
- ".if 1 - \\name\n\t"
- ".if 2 - \\name\n\t"
- "movl \\reg, %ebx\n\t"
- ".endif\n\t"
- ".endif\n\t"
- ".endm\n\t");
+ ".L__X'%ebx = 1\n\t"
+ ".L__X'%ecx = 2\n\t"
+ ".L__X'%edx = 2\n\t"
+ ".L__X'%eax = 3\n\t"
+ ".L__X'%esi = 3\n\t"
+ ".L__X'%edi = 3\n\t"
+ ".L__X'%ebp = 3\n\t"
+ ".L__X'%esp = 3\n\t"
+
+ /* Loading param #1 (ebx) is done by loading it into
+ * another register, and then performing bpushl+bmovl,
+ * since we must preserve ebx */
+
+ ".macro bpushl name reg\n\t"
+ ".if 1 - \\name\n\t" /* if reg!=ebx... */
+ ".if 2 - \\name\n\t" /* if reg can't be clobbered... */
+ "pushl %ebx\n\t" /* save ebx on stack */
+ ".else\n\t"
+ "xchgl \\reg, %ebx\n\t" /* else save ebx in reg, and load reg to ebx */
+ ".endif\n\t"
+ ".endif\n\t"
+ ".endm\n\t"
+
+ ".macro bmovl name reg\n\t"
+ ".if 1 - \\name\n\t"
+ ".if 2 - \\name\n\t" /* if reg can't be clobbered... */
+ "movl \\reg, %ebx\n\t" /* load reg to ebx */
+ ".endif\n\t"
+ ".endif\n\t"
+ ".endm\n\t"
+
+ ".macro bpopl name reg\n\t"
+ ".if 1 - \\name\n\t"
+ ".if 2 - \\name\n\t" /* if reg can't be clobbered... */
+ "popl %ebx\n\t" /* restore ebx from stack */
+ ".else\n\t"
+ "xchgl \\reg, %ebx\n\t" /* else restore ebx from reg */
+ ".endif\n\t"
+ ".endif\n\t"
+ ".endm\n\t"
+
+#if defined __DOMULTI__ || __GNUC_PREREQ (4, 6)
+ ".endif\n\t" /* _BITS_SYSCALLS_ASM */
#endif
-
-#undef _syscall0
-#define _syscall0(type,name) \
-type name(void) \
-{ \
-return (type) (INLINE_SYSCALL(name, 0)); \
-}
-
-#undef _syscall1
-#define _syscall1(type,name,type1,arg1) \
-type name(type1 arg1) \
-{ \
-return (type) (INLINE_SYSCALL(name, 1, arg1)); \
-}
-
-#undef _syscall2
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name(type1 arg1,type2 arg2) \
-{ \
-return (type) (INLINE_SYSCALL(name, 2, arg1, arg2)); \
-}
-
-#undef _syscall3
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name(type1 arg1,type2 arg2,type3 arg3) \
-{ \
-return (type) (INLINE_SYSCALL(name, 3, arg1, arg2, arg3)); \
-}
-
-#undef _syscall4
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
-{ \
-return (type) (INLINE_SYSCALL(name, 4, arg1, arg2, arg3, arg4)); \
-}
-
-#undef _syscall5
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
- type5,arg5) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
-{ \
-return (type) (INLINE_SYSCALL(name, 5, arg1, arg2, arg3, arg4, arg5)); \
-}
-
-#undef _syscall6
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
- type5,arg5,type6,arg6) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, type6 arg6) \
-{ \
-return (type) (INLINE_SYSCALL(name, 6, arg1, arg2, arg3, arg4, arg5, arg6)); \
-}
- #define INLINE_SYSCALL(name, nr, args...) \
- ({ \
- unsigned int _resultvar = INTERNAL_SYSCALL (name, , nr, args); \
- if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (_resultvar, ), 0)) \
- { \
- __set_errno (INTERNAL_SYSCALL_ERRNO (_resultvar, )); \
- _resultvar = 0xffffffff; \
- } \
- (int) _resultvar; })
-
-#define INTERNAL_SYSCALL(name, err, nr, args...) \
- ({ \
- register unsigned int resultvar; \
- __asm__ __volatile__ ( \
- LOADARGS_##nr \
- "movl %1, %%eax\n\t" \
- "int $0x80\n\t" \
- RESTOREARGS_##nr \
- : "=a" (resultvar) \
- : "i" (__NR_##name) ASMFMT_##nr(args) : "memory", "cc"); \
- (int) resultvar; })
+);
#define LOADARGS_0
-#define LOADARGS_1 \
- "bpushl .L__X'%k2, %k2\n\t" \
- "bmovl .L__X'%k2, %k2\n\t"
-#define LOADARGS_2 LOADARGS_1
-#define LOADARGS_3 LOADARGS_1
-#define LOADARGS_4 LOADARGS_1
-#define LOADARGS_5 LOADARGS_1
-#define LOADARGS_6 LOADARGS_1 "push %%ebp ; movl %7, %%ebp\n\t"
+#define LOADARGS_1 "bpushl .L__X'%k2, %k2\n\t" "bmovl .L__X'%k2, %k2\n\t"
+#define LOADARGS_2 LOADARGS_1
+#define LOADARGS_3 LOADARGS_1
+#define LOADARGS_4 LOADARGS_1
+#define LOADARGS_5 LOADARGS_1
+#define LOADARGS_6 LOADARGS_1 "push %%ebp\n\t" "movl %7, %%ebp\n\t"
#define RESTOREARGS_0
-#define RESTOREARGS_1 \
- "bpopl .L__X'%k2, %k2\n\t"
-#define RESTOREARGS_2 RESTOREARGS_1
-#define RESTOREARGS_3 RESTOREARGS_1
-#define RESTOREARGS_4 RESTOREARGS_1
-#define RESTOREARGS_5 RESTOREARGS_1
-#define RESTOREARGS_6 "pop %%ebp\n\t" RESTOREARGS_1
+#define RESTOREARGS_1 "bpopl .L__X'%k2, %k2\n\t"
+#define RESTOREARGS_2 RESTOREARGS_1
+#define RESTOREARGS_3 RESTOREARGS_1
+#define RESTOREARGS_4 RESTOREARGS_1
+#define RESTOREARGS_5 RESTOREARGS_1
+#define RESTOREARGS_6 "pop %%ebp\n\t" RESTOREARGS_1
#define ASMFMT_0()
+/* "acdSD" constraint would work too, but "SD" would use esi/edi and cause
+ * them to be pushed/popped by compiler, "a" would use eax and cause ebx
+ * to be saved/restored on stack, not in register. Narrowing choice down
+ * to "ecx or edx" results in smaller and faster code: */
#define ASMFMT_1(arg1) \
- , "acdSD" (arg1)
+ , "cd" (arg1)
+/* Can use "adSD" constraint here: */
#define ASMFMT_2(arg1, arg2) \
- , "adSD" (arg1), "c" (arg2)
+ , "d" (arg1), "c" (arg2)
+/* Can use "aSD" constraint here: */
#define ASMFMT_3(arg1, arg2, arg3) \
- , "aSD" (arg1), "c" (arg2), "d" (arg3)
+ , "a" (arg1), "c" (arg2), "d" (arg3)
+/* Can use "aD" constraint here: */
#define ASMFMT_4(arg1, arg2, arg3, arg4) \
- , "aD" (arg1), "c" (arg2), "d" (arg3), "S" (arg4)
+ , "a" (arg1), "c" (arg2), "d" (arg3), "S" (arg4)
#define ASMFMT_5(arg1, arg2, arg3, arg4, arg5) \
, "a" (arg1), "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5)
#define ASMFMT_6(arg1, arg2, arg3, arg4, arg5, arg6) \
- , "a" (arg1), "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5), "m" (arg6)
+ , "a" (arg1), "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5), "g" (arg6)
+
+#else /* !PIC */
+
+/* Simpler code which just uses "b" constraint to load ebx.
+ * Seems to work with gc 4.2.x, and generates slightly smaller,
+ * but slightly slower code. Example (time syscall):
+ *
+ * - 8b 4c 24 04 mov 0x4(%esp),%ecx
+ * - 87 cb xchg %ecx,%ebx
+ * + 53 push %ebx
+ * + 8b 5c 24 08 mov 0x8(%esp),%ebx
+ * b8 0d 00 00 00 mov $0xd,%eax
+ * cd 80 int $0x80
+ * - 87 cb xchg %ecx,%ebx
+ * + 5b pop %ebx
+ * c3 ret
+ *
+ * 2 bytes smaller, but uses stack via "push/pop ebx"
+ */
+
+#define LOADARGS_0
+#define LOADARGS_1
+#define LOADARGS_2
+#define LOADARGS_3
+#define LOADARGS_4
+#define LOADARGS_5
+#define LOADARGS_6 "push %%ebp\n\t" "movl %7, %%ebp\n\t"
+
+#define RESTOREARGS_0
+#define RESTOREARGS_1
+#define RESTOREARGS_2
+#define RESTOREARGS_3
+#define RESTOREARGS_4
+#define RESTOREARGS_5
+#define RESTOREARGS_6 "pop %%ebp\n\t"
+
+#define ASMFMT_0()
+#define ASMFMT_1(arg1) \
+ , "b" (arg1)
+#define ASMFMT_2(arg1, arg2) \
+ , "b" (arg1), "c" (arg2)
+#define ASMFMT_3(arg1, arg2, arg3) \
+ , "b" (arg1), "c" (arg2), "d" (arg3)
+#define ASMFMT_4(arg1, arg2, arg3, arg4) \
+ , "b" (arg1), "c" (arg2), "d" (arg3), "S" (arg4)
+#define ASMFMT_5(arg1, arg2, arg3, arg4, arg5) \
+ , "b" (arg1), "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5)
+#define ASMFMT_6(arg1, arg2, arg3, arg4, arg5, arg6) \
+ , "b" (arg1), "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5), "m" (arg6)
+
+#endif /* !PIC */
#endif /* __ASSEMBLER__ */
#endif /* _BITS_SYSCALLS_H */
diff --git a/libc/sysdeps/linux/i386/bits/uClibc_arch_features.h b/libc/sysdeps/linux/i386/bits/uClibc_arch_features.h
index f4730d987..5b6c2fc78 100644
--- a/libc/sysdeps/linux/i386/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/i386/bits/uClibc_arch_features.h
@@ -11,8 +11,8 @@
/* can your target use syscall6() for mmap ? */
#undef __UCLIBC_MMAP_HAS_6_ARGS__
-/* does your target use syscall4() for truncate64 ? (32bit arches only) */
-#undef __UCLIBC_TRUNCATE64_HAS_4_ARGS__
+/* does your target align 64bit values in register pairs ? (32bit arches only) */
+#undef __UCLIBC_SYSCALL_ALIGN_64BIT__
/* does your target have a broken create_module() ? */
#define __UCLIBC_BROKEN_CREATE_MODULE__
@@ -24,21 +24,21 @@
/* 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 */
+#define __UCLIBC_HAVE_ASM_CFI_DIRECTIVES__
/* define if target supports IEEE signed zero floats */
#define __UCLIBC_HAVE_SIGNED_ZERO__
+/* only weird assemblers generally need this */
+#undef __UCLIBC_ASM_LINE_SEP__
+
#if defined _LIBC
#define internal_function __attribute__ ((regparm (3), stdcall))
#endif
diff --git a/libc/sysdeps/linux/i386/bits/wchar.h b/libc/sysdeps/linux/i386/bits/wchar.h
index 442a4621e..b94fc7a3f 100644
--- a/libc/sysdeps/linux/i386/bits/wchar.h
+++ b/libc/sysdeps/linux/i386/bits/wchar.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _BITS_WCHAR_H
#define _BITS_WCHAR_H 1
diff --git a/libc/sysdeps/linux/i386/bits/wordsize.h b/libc/sysdeps/linux/i386/bits/wordsize.h
index 7c3cd9c7d..d8f66ddc5 100644
--- a/libc/sysdeps/linux/i386/bits/wordsize.h
+++ b/libc/sysdeps/linux/i386/bits/wordsize.h
@@ -12,13 +12,12 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#define __WORDSIZE 32
-#ifdef UCLIBC_INTERNAL
+#ifdef _LIBC
#ifndef smallint_type
#define smallint_type char
#endif
diff --git a/libc/sysdeps/linux/i386/brk.c b/libc/sysdeps/linux/i386/brk.c
index eda8ad9ce..a513886e3 100644
--- a/libc/sysdeps/linux/i386/brk.c
+++ b/libc/sysdeps/linux/i386/brk.c
@@ -1,6 +1,7 @@
/* brk system call for Linux/i386.
Copyright (C) 1995, 1996, 2000 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
+ Copyright (c) 2015 mirabilos <tg@mirbsd.org>
+ This file is part of uclibc-ng, derived from 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
@@ -13,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <errno.h>
#include <unistd.h>
@@ -24,26 +24,31 @@
/* This must be initialized data because commons can't have aliases. */
void *__curbrk attribute_hidden = 0;
-libc_hidden_proto(brk)
-int brk (void *addr)
+int brk(void *addr)
{
- void *__unbounded newbrk, *__unbounded scratch;
-
- __asm__ ("movl %%ebx, %1\n" /* Save %ebx in scratch register. */
- "movl %3, %%ebx\n" /* Put ADDR in %ebx to be syscall arg. */
- "int $0x80 # %2\n" /* Perform the system call. */
- "movl %1, %%ebx\n" /* Restore %ebx from scratch register. */
- : "=a" (newbrk), "=r" (scratch)
- : "0" (__NR_brk), "g" (__ptrvalue (addr)));
-
- __curbrk = newbrk;
-
- if (newbrk < addr)
- {
- __set_errno (ENOMEM);
- return -1;
- }
-
- return 0;
+ void *newbrk;
+
+ /*
+ * EBC is used in PIC code, we need to save/restore it manually.
+ * Unfortunately, GCC won't do that for us even if we use con-
+ * straints, and we cannot push it either as ESP clobbers are
+ * silently ignored, but EDX is preserved, so it's scratch space.
+ */
+ __asm__("xchgl %%edx,%%ebx"
+ "\n int $0x80"
+ "\n xchgl %%edx,%%ebx"
+ : "=a" (newbrk)
+ : "0" (__NR_brk), "d" (addr)
+ : "cc"
+ );
+
+ __curbrk = newbrk;
+
+ if (newbrk < addr) {
+ __set_errno(ENOMEM);
+ return -1;
+ }
+
+ return 0;
}
libc_hidden_def(brk)
diff --git a/libc/sysdeps/linux/i386/bsd-_setjmp.S b/libc/sysdeps/linux/i386/bsd-_setjmp.S
index f3cd6cbf6..fac94e351 100644
--- a/libc/sysdeps/linux/i386/bsd-_setjmp.S
+++ b/libc/sysdeps/linux/i386/bsd-_setjmp.S
@@ -13,17 +13,14 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* This just does a tail-call to `__sigsetjmp (ARG, 0)'.
We cannot do it in C because it must be a tail-call, so frame-unwinding
in setjmp doesn't clobber the state restored by longjmp. */
-#define _ASM
-#define _SETJMP_H
-#include <bits/setjmp.h>
+#include <jmpbuf-offsets.h>
.global _setjmp
.type _setjmp,%function
diff --git a/libc/sysdeps/linux/i386/bsd-setjmp.S b/libc/sysdeps/linux/i386/bsd-setjmp.S
index df46997d9..c634cf16a 100644
--- a/libc/sysdeps/linux/i386/bsd-setjmp.S
+++ b/libc/sysdeps/linux/i386/bsd-setjmp.S
@@ -13,13 +13,8 @@
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 _ASM
-#define _SETJMP_H
-#include <bits/setjmp.h>
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
.global setjmp
.type setjmp,%function
diff --git a/libc/sysdeps/linux/i386/clone.S b/libc/sysdeps/linux/i386/clone.S
index 14fc25ca1..632cf59df 100644
--- a/libc/sysdeps/linux/i386/clone.S
+++ b/libc/sysdeps/linux/i386/clone.S
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* clone() is even more special than fork() as it mucks with stacks
and invokes a function in the right context after its all over.
@@ -79,7 +78,10 @@ clone:
movl %eax,8(%ecx)
/* Don't leak any information. */
movl $0,4(%ecx)
+#ifndef RESET_PID
movl $0,(%ecx)
+#endif
+
/* Do the system call */
pushl %ebx
@@ -90,6 +92,10 @@ clone:
movl FLAGS+12(%esp),%ebx
movl CTID+12(%esp),%edi
movl $__NR_clone,%eax
+#ifdef RESET_PID
+ /* Remember the flag value. */
+ movl %ebx, (%ecx)
+#endif
int $0x80
popl %edi
popl %esi
@@ -121,3 +127,4 @@ __error:
jmp __syscall_error
.size clone,.-clone
+weak_alias(clone, __clone)
diff --git a/libc/sysdeps/linux/i386/copysign.S b/libc/sysdeps/linux/i386/copysign.S
new file mode 100644
index 000000000..6499ce05d
--- /dev/null
+++ b/libc/sysdeps/linux/i386/copysign.S
@@ -0,0 +1,55 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#define _ERRNO_H 1
+#include <features.h>
+#include <bits/errno.h>
+
+.text
+.global copysign
+.type copysign,%function
+copysign:
+ movl 16(%esp),%edx
+ movl 8(%esp),%eax
+ andl $0x80000000,%edx
+ andl $0x7fffffff,%eax
+ orl %edx,%eax
+ movl %eax,8(%esp)
+ fldl 4(%esp)
+ ret
+.size copysign,.-copysign
+
+libc_hidden_def(copysign)
+
+.global copysignf
+.type copysignf,%function
+copysignf:
+ movl 8(%esp),%edx
+ movl 4(%esp),%eax
+ andl $0x80000000,%edx
+ andl $0x7fffffff,%eax
+ orl %edx,%eax
+ movl %eax,4(%esp)
+ flds 4(%esp)
+ ret
+.size copysignf,.-copysignf
+
+libc_hidden_def(copysignf)
+
+.global copysignl
+.type copysignl,%function
+copysignl:
+ movl 24(%esp),%edx
+ movl 12(%esp),%eax
+ andl $0x8000,%edx
+ andl $0x7fff,%eax
+ orl %edx,%eax
+ movl %eax,12(%esp)
+ fldt 4(%esp)
+ ret
+.size copysignl,.-copysignl
+
+libc_hidden_def(copysignl)
+
diff --git a/libc/sysdeps/linux/i386/crt1.S b/libc/sysdeps/linux/i386/crt1.S
index a133cb9e0..35a6552e8 100644
--- a/libc/sysdeps/linux/i386/crt1.S
+++ b/libc/sysdeps/linux/i386/crt1.S
@@ -31,9 +31,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* This is the canonical entry point, usually the first thing in the text
segment. The SVR4/i386 ABI (pages 3-31, 3-32) says that when the entry
diff --git a/libc/sysdeps/linux/i386/crtn.S b/libc/sysdeps/linux/i386/crtn.S
index 191250487..34d5b38e2 100644
--- a/libc/sysdeps/linux/i386/crtn.S
+++ b/libc/sysdeps/linux/i386/crtn.S
@@ -6,7 +6,6 @@
popl %ebx
popl %ebp
ret
-.size _init,.-_init
@@ -16,7 +15,6 @@
popl %ebx
popl %ebp
ret
-.size _fini,.-_fini
diff --git a/libc/sysdeps/linux/i386/fpu_control.h b/libc/sysdeps/linux/i386/fpu_control.h
index c6cb005d7..c2a672d29 100644
--- a/libc/sysdeps/linux/i386/fpu_control.h
+++ b/libc/sysdeps/linux/i386/fpu_control.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FPU_CONTROL_H
#define _FPU_CONTROL_H 1
diff --git a/libc/sysdeps/linux/i386/getcontext.S b/libc/sysdeps/linux/i386/getcontext.S
new file mode 100644
index 000000000..3221b597c
--- /dev/null
+++ b/libc/sysdeps/linux/i386/getcontext.S
@@ -0,0 +1,84 @@
+/* Save current context.
+ Copyright (C) 2001-2012 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2001.
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+
+#include "ucontext_i.h"
+
+
+ENTRY(__getcontext)
+ /* Load address of the context data structure. */
+ movl 4(%esp), %eax
+
+ /* Return value of getcontext. EAX is the only register whose
+ value is not preserved. */
+ movl $0, oEAX(%eax)
+
+ /* Save the 32-bit register values and the return address. */
+ movl %ecx, oECX(%eax)
+ movl %edx, oEDX(%eax)
+ movl %edi, oEDI(%eax)
+ movl %esi, oESI(%eax)
+ movl %ebp, oEBP(%eax)
+ movl (%esp), %ecx
+ movl %ecx, oEIP(%eax)
+ leal 4(%esp), %ecx /* Exclude the return address. */
+ movl %ecx, oESP(%eax)
+ movl %ebx, oEBX(%eax)
+
+ /* Save the FS segment register. We don't touch the GS register
+ since it is used for threads. */
+ xorl %edx, %edx
+ movw %fs, %dx
+ movl %edx, oFS(%eax)
+
+ /* We have separate floating-point register content memory on the
+ stack. We use the __fpregs_mem block in the context. Set the
+ links up correctly. */
+ leal oFPREGSMEM(%eax), %ecx
+ movl %ecx, oFPREGS(%eax)
+ /* Save the floating-point context. */
+ fnstenv (%ecx)
+ /* And load it right back since the processor changes the mask.
+ Intel thought this opcode to be used in interrupt handlers which
+ would block all exceptions. */
+ fldenv (%ecx)
+
+ /* Save the current signal mask. */
+ pushl %ebx
+ cfi_adjust_cfa_offset (4)
+ cfi_rel_offset (ebx, 0)
+ leal oSIGMASK(%eax), %edx
+ xorl %ecx, %ecx
+ movl $SIG_BLOCK, %ebx
+ movl $__NR_sigprocmask, %eax
+ ENTER_KERNEL
+ popl %ebx
+ cfi_adjust_cfa_offset (-4)
+ cfi_restore (ebx)
+ cmpl $-4095, %eax /* Check %eax for error. */
+ jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
+
+ /* All done, return 0 for success. */
+ xorl %eax, %eax
+L(pseudo_end):
+ ret
+PSEUDO_END(__getcontext)
+
+weak_alias (__getcontext, getcontext)
diff --git a/libc/sysdeps/linux/i386/jmpbuf-offsets.h b/libc/sysdeps/linux/i386/jmpbuf-offsets.h
new file mode 100644
index 000000000..47aa49948
--- /dev/null
+++ b/libc/sysdeps/linux/i386/jmpbuf-offsets.h
@@ -0,0 +1,25 @@
+/* Private macros for accessing __jmp_buf contents. i386 version.
+ Copyright (C) 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#define JB_BX 0
+#define JB_SI 1
+#define JB_DI 2
+#define JB_BP 3
+#define JB_SP 4
+#define JB_PC 5
+#define JB_SIZE 24
diff --git a/libc/sysdeps/linux/i386/jmpbuf-unwind.h b/libc/sysdeps/linux/i386/jmpbuf-unwind.h
new file mode 100644
index 000000000..4516d9398
--- /dev/null
+++ b/libc/sysdeps/linux/i386/jmpbuf-unwind.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+#include <setjmp.h>
+#include <jmpbuf-offsets.h>
+
+/* Test if longjmp to JMPBUF would unwind the frame
+ containing a local variable at ADDRESS. */
+#define _JMPBUF_UNWINDS(jmpbuf, address) \
+ ((void *) (address) < (void *) (jmpbuf)[JB_SP])
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <stdint.h>
+#include <unwind.h>
+
+#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
+ _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
+
+#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
+ ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[JB_SP] - (_adj))
+#endif
diff --git a/libc/sysdeps/linux/i386/makecontext.S b/libc/sysdeps/linux/i386/makecontext.S
new file mode 100644
index 000000000..d12799d80
--- /dev/null
+++ b/libc/sysdeps/linux/i386/makecontext.S
@@ -0,0 +1,123 @@
+/* Create new context.
+ Copyright (C) 2001,2002,2005,2007,2008,2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2001.
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+
+#include "ucontext_i.h"
+
+
+ENTRY(__makecontext)
+ movl 4(%esp), %eax
+
+ /* Load the address of the function we are supposed to run. */
+ movl 8(%esp), %ecx
+
+ /* Compute the address of the stack. The information comes from
+ to us_stack element. */
+ movl oSS_SP(%eax), %edx
+ movl %ecx, oEIP(%eax)
+ addl oSS_SIZE(%eax), %edx
+
+ /* Remember the number of parameters for the exit handler since
+ it has to remove them. We store the number in the EBX register
+ which the function we will call must preserve. */
+ movl 12(%esp), %ecx
+ movl %ecx, oEBX(%eax)
+
+ /* Make room on the new stack for the parameters.
+ Room for the arguments, return address (== L(exitcode)) and
+ oLINK pointer is needed. One of the pointer sizes is subtracted
+ after aligning the stack. */
+ negl %ecx
+ leal -4(%edx,%ecx,4), %edx
+ negl %ecx
+
+ /* Align the stack. */
+ andl $0xfffffff0, %edx
+ subl $4, %edx
+
+ /* Store the future stack pointer. */
+ movl %edx, oESP(%eax)
+
+ /* Put the next context on the new stack (from the uc_link
+ element). */
+ movl oLINK(%eax), %eax
+ movl %eax, 4(%edx,%ecx,4)
+
+ /* Copy all the parameters. */
+ jecxz 2f
+1: movl 12(%esp,%ecx,4), %eax
+ movl %eax, (%edx,%ecx,4)
+ decl %ecx
+ jnz 1b
+2:
+
+ /* If the function we call returns we must continue with the
+ context which is given in the uc_link element. To do this
+ set the return address for the function the user provides
+ to a little bit of helper code which does the magic (see
+ below). */
+#ifdef __PIC__
+ call 1f
+ cfi_adjust_cfa_offset (4)
+1: popl %ecx
+ cfi_adjust_cfa_offset (-4)
+ addl $L(exitcode)-1b, %ecx
+ movl %ecx, (%edx)
+#else
+ movl $L(exitcode), (%edx)
+#endif
+ /* 'makecontext' returns no value. */
+L(pseudo_end):
+ ret
+
+ /* This is the helper code which gets called if a function which
+ is registered with 'makecontext' returns. In this case we
+ have to install the context listed in the uc_link element of
+ the context 'makecontext' manipulated at the time of the
+ 'makecontext' call. If the pointer is NULL the process must
+ terminate. */
+ cfi_endproc
+L(exitcode):
+ /* This removes the parameters passed to the function given to
+ 'makecontext' from the stack. EBX contains the number of
+ parameters (see above). */
+ leal (%esp,%ebx,4), %esp
+
+#ifdef __PIC__
+ call 1f
+1: popl %ebx
+ addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx
+#endif
+ cmpl $0, (%esp) /* Check the next context. */
+ je 2f /* If it is zero exit. */
+
+ call JUMPTARGET(__setcontext)
+ /* If this returns (which can happen if the syscall fails) we'll
+ exit the program with the return error value (-1). */
+
+ movl %eax, (%esp)
+2: call HIDDEN_JUMPTARGET(exit)
+ /* The 'exit' call should never return. In case it does cause
+ the process to terminate. */
+ hlt
+ cfi_startproc
+END(__makecontext)
+
+weak_alias (__makecontext, makecontext)
diff --git a/libc/sysdeps/linux/i386/mmap.S b/libc/sysdeps/linux/i386/mmap.S
index fe7a7986c..8f9b03243 100644
--- a/libc/sysdeps/linux/i386/mmap.S
+++ b/libc/sysdeps/linux/i386/mmap.S
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#define _ERRNO_H 1
#include <features.h>
diff --git a/libc/sysdeps/linux/i386/mmap64.S b/libc/sysdeps/linux/i386/mmap64.S
index a6b4aa042..2c80ceb01 100644
--- a/libc/sysdeps/linux/i386/mmap64.S
+++ b/libc/sysdeps/linux/i386/mmap64.S
@@ -12,18 +12,16 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+#include <_lfs_64.h>
#define _ERRNO_H 1
-#include <features.h>
#include <bits/errno.h>
#include <sys/syscall.h>
-#if defined __UCLIBC_HAS_LFS__ && defined __NR_mmap2
-
+#ifdef __NR_mmap2
#define LINKAGE 4
#define PTR_SIZE 4
diff --git a/libc/sysdeps/linux/i386/posix_fadvise.c b/libc/sysdeps/linux/i386/posix_fadvise.c
deleted file mode 100644
index 5406213b8..000000000
--- a/libc/sysdeps/linux/i386/posix_fadvise.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * posix_fadvise() for uClibc
- *
- * Copyright (C) 2008 Bernhard Reutner-Fischer <uclibc@uclibc.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-#include <sys/syscall.h>
-#if defined __USE_GNU
-#include <fcntl.h>
-
-
-#if defined __NR_fadvise64_64 || defined __NR_fadvise64
-libc_hidden_proto(posix_fadvise64)
-libc_hidden_proto(posix_fadvise)
-int posix_fadvise(int fd, off_t offset, off_t len, int advice)
-{
- if (posix_fadvise64(fd, offset, len, advice) != 0)
- return errno;
- return 0;
-}
-libc_hidden_def(posix_fadvise)
-#elif defined __UCLIBC_HAS_STUBS__
-libc_hidden_proto(posix_fadvise)
-int posix_fadvise(int fd attribute_unused, off_t offset attribute_unused,
- off_t len attribute_unused, int advice attribute_unused)
-{
- return ENOSYS;
-}
-libc_hidden_def(posix_fadvise)
-#endif
-#endif
diff --git a/libc/sysdeps/linux/i386/posix_fadvise64.S b/libc/sysdeps/linux/i386/posix_fadvise64.S
index da3f36394..3047b0d05 100644
--- a/libc/sysdeps/linux/i386/posix_fadvise64.S
+++ b/libc/sysdeps/linux/i386/posix_fadvise64.S
@@ -13,20 +13,18 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
-#define _ERRNO_H 1
-#include <features.h>
-#include <bits/errno.h>
+#include <_lfs_64.h>
#include <sys/syscall.h>
+#ifdef __NR_fadvise64_64
+
.text
.global posix_fadvise64
.type posix_fadvise64,%function
posix_fadvise64:
-#if defined __NR_fadvise64_64 && defined __UCLIBC_HAS_LFS__
/* Save regs */
pushl %ebp
pushl %ebx
@@ -35,12 +33,12 @@ posix_fadvise64:
movl $__NR_fadvise64_64, %eax /* Syscall number in %eax. */
- movl 24(%esp), %ebx
- movl 28(%esp), %ecx
- movl 32(%esp), %edx
- movl 36(%esp), %esi
- movl 40(%esp), %edi
- movl 44(%esp), %ebp
+ movl 20(%esp), %ebx
+ movl 24(%esp), %ecx
+ movl 28(%esp), %edx
+ movl 32(%esp), %esi
+ movl 36(%esp), %edi
+ movl 40(%esp), %ebp
/* Do the system call trap. */
int $0x80
@@ -51,48 +49,10 @@ posix_fadvise64:
popl %ebx
popl %ebp
- /* If 0 > %eax > -4096 there was an error. */
- cmpl $-4096, %eax
- ja __syscall_error
-#elif defined __NR_fadvise64
- /* Save regs */
- pushl %ebx
- pushl %esi
- pushl %edi
-
- /* does len overflow long? */
- cmpl $0, 40(%esp)
- movl $-EOVERFLOW, %eax
- ja overflow
+ /* Returns 0 on success, else an error code. */
+ negl %eax
- movl $__NR_fadvise64, %eax /* Syscall number in %eax. */
-
- movl 24(%esp), %ebx
- movl 28(%esp), %ecx
- movl 32(%esp), %edx
- movl 36(%esp), %esi
- movl 44(%esp), %edi
-
- /* Do the system call trap. */
- int $0x80
-overflow:
- /* Restore regs */
- popl %edi
- popl %esi
- popl %ebx
-
- /* If 0 > %eax > -4096 there was an error. */
- cmpl $-4096, %eax
- ja __syscall_error
-
-#elif defined __UCLIBC_HAS_STUBS__
- movl $-ENOSYS, %eax
- jmp __syscall_error
-#endif
/* Successful; return the syscall's value. */
ret
-
.size posix_fadvise64,.-posix_fadvise64
-
-libc_hidden_def(posix_fadvise64)
-
+#endif
diff --git a/libc/sysdeps/linux/i386/setcontext.S b/libc/sysdeps/linux/i386/setcontext.S
new file mode 100644
index 000000000..ae953cc6b
--- /dev/null
+++ b/libc/sysdeps/linux/i386/setcontext.S
@@ -0,0 +1,96 @@
+/* Install given context.
+ Copyright (C) 2001-2012 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2001.
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+
+#include "ucontext_i.h"
+
+
+ENTRY(__setcontext)
+ /* Load address of the context data structure. */
+ movl 4(%esp), %eax
+
+ /* Get the current signal mask. Note that we preserve EBX in case
+ the system call fails and we return from the function with an
+ error. */
+ pushl %ebx
+ cfi_adjust_cfa_offset (4)
+ xorl %edx, %edx
+ leal oSIGMASK(%eax), %ecx
+ movl $SIG_SETMASK, %ebx
+ cfi_rel_offset (ebx, 0)
+ movl $__NR_sigprocmask, %eax
+ ENTER_KERNEL
+ popl %ebx
+ cfi_adjust_cfa_offset (-4)
+ cfi_restore (ebx)
+ cmpl $-4095, %eax /* Check %eax for error. */
+ jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
+
+ /* EAX was modified, reload it. */
+ movl 4(%esp), %eax
+
+ /* Restore the floating-point context. Not the registers, only the
+ rest. */
+ movl oFPREGS(%eax), %ecx
+ fldenv (%ecx)
+
+ /* Restore the FS segment register. We don't touch the GS register
+ since it is used for threads. */
+ movl oFS(%eax), %ecx
+ movw %cx, %fs
+
+ /* Fetch the address to return to. */
+ movl oEIP(%eax), %ecx
+
+ /* Load the new stack pointer. */
+ cfi_def_cfa (eax, 0)
+ cfi_offset (edi, oEDI)
+ cfi_offset (esi, oESI)
+ cfi_offset (ebp, oEBP)
+ cfi_offset (ebx, oEBX)
+ cfi_offset (edx, oEDX)
+ cfi_offset (ecx, oECX)
+ movl oESP(%eax), %esp
+
+ /* Push the return address on the new stack so we can return there. */
+ pushl %ecx
+
+ /* Load the values of all the 32-bit registers (except ESP).
+ Since we are loading from EAX, it must be last. */
+ movl oEDI(%eax), %edi
+ movl oESI(%eax), %esi
+ movl oEBP(%eax), %ebp
+ movl oEBX(%eax), %ebx
+ movl oEDX(%eax), %edx
+ movl oECX(%eax), %ecx
+ movl oEAX(%eax), %eax
+
+ /* End FDE here, we fall into another context. */
+ cfi_endproc
+ cfi_startproc
+
+ /* The following 'ret' will pop the address of the code and jump
+ to it. */
+
+L(pseudo_end):
+ ret
+PSEUDO_END(__setcontext)
+
+weak_alias (__setcontext, setcontext)
diff --git a/libc/sysdeps/linux/i386/setjmp.S b/libc/sysdeps/linux/i386/setjmp.S
index 20a6a0bcf..505b85cf5 100644
--- a/libc/sysdeps/linux/i386/setjmp.S
+++ b/libc/sysdeps/linux/i386/setjmp.S
@@ -13,14 +13,8 @@
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 _ASM
-#define _SETJMP_H
-#include <bits/setjmp.h>
-
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
.global __sigsetjmp
.type __sigsetjmp,%function
diff --git a/libc/sysdeps/linux/i386/sigaction.c b/libc/sysdeps/linux/i386/sigaction.c
index e8729647f..77da69d5e 100644
--- a/libc/sysdeps/linux/i386/sigaction.c
+++ b/libc/sysdeps/linux/i386/sigaction.c
@@ -13,8 +13,7 @@
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.
+ see <http://www.gnu.org/licenses/>.
Totally hacked up for uClibc by Erik Andersen <andersen@codepoet.org>
*/
@@ -27,111 +26,81 @@
#define SA_RESTORER 0x04000000
-extern __typeof(sigaction) __libc_sigaction;
-
#if defined __NR_rt_sigaction
-/* Experimentally off - libc_hidden_proto(memcpy) */
-extern void restore_rt (void) __asm__ ("__restore_rt") attribute_hidden;
-extern void restore (void) __asm__ ("__restore") attribute_hidden;
+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 __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;
+ struct sigaction kact;
+
+ if (act) {
+ memcpy(&kact, act, sizeof(kact));
+ kact.sa_flags |= SA_RESTORER;
+ kact.sa_restorer = (act->sa_flags & SA_SIGINFO) ? &restore_rt : &restore;
+ act = &kact;
+ }
+ /* NB: kernel (as of 2.6.25) will return EINVAL
+ * if sizeof(act->sa_mask) does not match kernel's sizeof(sigset_t) */
+ return __syscall_rt_sigaction(sig, act, oact, sizeof(act->sa_mask));
}
-
#else
-extern void restore (void) __asm__ ("__restore") 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 __libc_sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
{
- int result;
- struct old_kernel_sigaction kact, koact;
-
-#ifdef SIGCANCEL
- if (sig == SIGCANCEL) {
- __set_errno (EINVAL);
- return -1;
- }
-#endif
-
- if (act) {
- kact.k_sa_handler = act->sa_handler;
- kact.sa_mask = act->sa_mask.__val[0];
- kact.sa_flags = act->sa_flags | SA_RESTORER;
- kact.sa_restorer = &restore;
- }
-
- __asm__ __volatile__ ("pushl %%ebx\n"
- "movl %2, %%ebx\n"
- "int $0x80\n"
- "popl %%ebx"
- : "=a" (result)
- : "0" (__NR_sigaction), "mr" (sig),
- "c" (act ? __ptrvalue (&kact) : 0),
- "d" (oact ? __ptrvalue (&koact) : 0));
-
- if (result < 0) {
- __set_errno(-result);
- return -1;
- }
-
- if (oact) {
- oact->sa_handler = koact.k_sa_handler;
- oact->sa_mask.__val[0] = koact.sa_mask;
- oact->sa_flags = koact.sa_flags;
- oact->sa_restorer = koact.sa_restorer;
- }
- return result;
+ int result;
+ struct old_kernel_sigaction kact, koact;
+
+ if (act) {
+ kact.k_sa_handler = act->sa_handler;
+ kact.sa_mask = act->sa_mask.__val[0];
+ kact.sa_flags = act->sa_flags | SA_RESTORER;
+ kact.sa_restorer = &restore;
+ }
+ __asm__ __volatile__ (
+ " pushl %%ebx\n"
+ " movl %3, %%ebx\n"
+ " int $0x80\n"
+ " popl %%ebx\n"
+ : "=a" (result), "=m" (koact)
+ : "0" (__NR_sigaction), "r" (sig), "m" (kact),
+ "c" (act ? &kact : NULL),
+ "d" (oact ? &koact : NULL));
+ if (result < 0) {
+ __set_errno(-result);
+ return -1;
+ }
+ if (oact) {
+ oact->sa_handler = koact.k_sa_handler;
+ oact->sa_mask.__val[0] = koact.sa_mask;
+ oact->sa_flags = koact.sa_flags;
+ oact->sa_restorer = koact.sa_restorer;
+ }
+ return result;
}
#endif
+
#ifndef LIBC_SIGACTION
-libc_hidden_proto(sigaction)
+# ifndef __UCLIBC_HAS_THREADS__
+strong_alias(__libc_sigaction,sigaction)
+libc_hidden_def(sigaction)
+# else
weak_alias(__libc_sigaction,sigaction)
libc_hidden_weak(sigaction)
+# endif
#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
@@ -140,33 +109,30 @@ libc_hidden_weak(sigaction)
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" \
- "__" #name ":\n" \
- " movl $" #syscall ", %eax\n" \
- " int $0x80" \
- );
+#define RESTORE(name, syscall) RESTORE2(name, syscall)
#ifdef __NR_rt_sigaction
/* The return code for realtime-signals. */
-RESTORE (restore_rt, __NR_rt_sigreturn)
+# define RESTORE2(name, syscall) \
+__asm__ ( \
+ ".text\n" \
+ "__" #name ":\n" \
+ " movl $" #syscall ", %eax\n" \
+ " int $0x80\n" \
+);
+RESTORE(restore_rt, __NR_rt_sigreturn)
#endif
#ifdef __NR_sigreturn
/* For the boring old signals. */
# undef RESTORE2
# define RESTORE2(name, syscall) \
-__asm__ \
- ( \
- ".text\n" \
- "__" #name ":\n" \
- " popl %eax\n" \
- " movl $" #syscall ", %eax\n" \
- " int $0x80" \
- );
-
-RESTORE (restore, __NR_sigreturn)
+__asm__ ( \
+ ".text\n" \
+ "__" #name ":\n" \
+ " popl %eax\n" \
+ " movl $" #syscall ", %eax\n" \
+ " int $0x80\n" \
+);
+RESTORE(restore, __NR_sigreturn)
#endif
diff --git a/libc/sysdeps/linux/i386/swapcontext.S b/libc/sysdeps/linux/i386/swapcontext.S
new file mode 100644
index 000000000..ee5d0e4d5
--- /dev/null
+++ b/libc/sysdeps/linux/i386/swapcontext.S
@@ -0,0 +1,110 @@
+/* Save current context and install the given one.
+ Copyright (C) 2001-2012 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2001.
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+
+#include "ucontext_i.h"
+
+
+ENTRY(__swapcontext)
+ /* Load address of the context data structure we save in. */
+ movl 4(%esp), %eax
+
+ /* Return value of swapcontext. EAX is the only register whose
+ value is not preserved. */
+ movl $0, oEAX(%eax)
+
+ /* Save the 32-bit register values and the return address. */
+ movl %ecx, oECX(%eax)
+ movl %edx, oEDX(%eax)
+ movl %edi, oEDI(%eax)
+ movl %esi, oESI(%eax)
+ movl %ebp, oEBP(%eax)
+ movl (%esp), %ecx
+ movl %ecx, oEIP(%eax)
+ leal 4(%esp), %ecx
+ movl %ecx, oESP(%eax)
+ movl %ebx, oEBX(%eax)
+
+ /* Save the FS segment register. */
+ xorl %edx, %edx
+ movw %fs, %dx
+ movl %edx, oFS(%eax)
+
+ /* We have separate floating-point register content memory on the
+ stack. We use the __fpregs_mem block in the context. Set the
+ links up correctly. */
+ leal oFPREGSMEM(%eax), %ecx
+ movl %ecx, oFPREGS(%eax)
+ /* Save the floating-point context. */
+ fnstenv (%ecx)
+
+ /* Load address of the context data structure we have to load. */
+ movl 8(%esp), %ecx
+
+ /* Save the current signal mask and install the new one. */
+ pushl %ebx
+ leal oSIGMASK(%eax), %edx
+ leal oSIGMASK(%ecx), %ecx
+ movl $SIG_SETMASK, %ebx
+ movl $__NR_sigprocmask, %eax
+ ENTER_KERNEL
+ popl %ebx
+ cmpl $-4095, %eax /* Check %eax for error. */
+ jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
+
+ /* EAX was modified, reload it. */
+ movl 8(%esp), %eax
+
+ /* Restore the floating-point context. Not the registers, only the
+ rest. */
+ movl oFPREGS(%eax), %ecx
+ fldenv (%ecx)
+
+ /* Restore the FS segment register. We don't touch the GS register
+ since it is used for threads. */
+ movl oFS(%eax), %edx
+ movw %dx, %fs
+
+ /* Fetch the address to return to. */
+ movl oEIP(%eax), %ecx
+
+ /* Load the new stack pointer. */
+ movl oESP(%eax), %esp
+
+ /* Push the return address on the new stack so we can return there. */
+ pushl %ecx
+
+ /* Load the values of all the 32-bit registers (except ESP).
+ Since we are loading from EAX, it must be last. */
+ movl oEDI(%eax), %edi
+ movl oESI(%eax), %esi
+ movl oEBP(%eax), %ebp
+ movl oEBX(%eax), %ebx
+ movl oEDX(%eax), %edx
+ movl oECX(%eax), %ecx
+ movl oEAX(%eax), %eax
+
+ /* The following 'ret' will pop the address of the code and jump
+ to it. */
+L(pseudo_end):
+ ret
+PSEUDO_END(__swapcontext)
+
+weak_alias (__swapcontext, swapcontext)
diff --git a/libc/sysdeps/linux/i386/sync_file_range.S b/libc/sysdeps/linux/i386/sync_file_range.S
index 6cdaf452a..d2cbd5170 100644
--- a/libc/sysdeps/linux/i386/sync_file_range.S
+++ b/libc/sysdeps/linux/i386/sync_file_range.S
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#define _ERRNO_H 1
#include <features.h>
diff --git a/libc/sysdeps/linux/i386/sys/debugreg.h b/libc/sysdeps/linux/i386/sys/debugreg.h
index c99c94359..ac1926b5b 100644
--- a/libc/sysdeps/linux/i386/sys/debugreg.h
+++ b/libc/sysdeps/linux/i386/sys/debugreg.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_DEBUGREG_H
#define _SYS_DEBUGREG_H 1
diff --git a/libc/sysdeps/linux/i386/sys/elf.h b/libc/sysdeps/linux/i386/sys/elf.h
index d959cdca1..9d64e9768 100644
--- a/libc/sysdeps/linux/i386/sys/elf.h
+++ b/libc/sysdeps/linux/i386/sys/elf.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_ELF_H
#define _SYS_ELF_H 1
diff --git a/libc/sysdeps/linux/i386/sys/io.h b/libc/sysdeps/linux/i386/sys/io.h
index 87b99a94a..fa750995c 100644
--- a/libc/sysdeps/linux/i386/sys/io.h
+++ b/libc/sysdeps/linux/i386/sys/io.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_IO_H
#define _SYS_IO_H 1
diff --git a/libc/sysdeps/linux/i386/sys/perm.h b/libc/sysdeps/linux/i386/sys/perm.h
index e389e6679..c26868114 100644
--- a/libc/sysdeps/linux/i386/sys/perm.h
+++ b/libc/sysdeps/linux/i386/sys/perm.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_PERM_H
diff --git a/libc/sysdeps/linux/i386/sys/procfs.h b/libc/sysdeps/linux/i386/sys/procfs.h
index f0be43309..673baa1ec 100644
--- a/libc/sysdeps/linux/i386/sys/procfs.h
+++ b/libc/sysdeps/linux/i386/sys/procfs.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_PROCFS_H
#define _SYS_PROCFS_H 1
diff --git a/libc/sysdeps/linux/i386/sys/reg.h b/libc/sysdeps/linux/i386/sys/reg.h
index 39003c45b..b993f999a 100644
--- a/libc/sysdeps/linux/i386/sys/reg.h
+++ b/libc/sysdeps/linux/i386/sys/reg.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_REG_H
#define _SYS_REG_H 1
diff --git a/libc/sysdeps/linux/i386/sys/ucontext.h b/libc/sysdeps/linux/i386/sys/ucontext.h
index d6474c722..6306623ab 100644
--- a/libc/sysdeps/linux/i386/sys/ucontext.h
+++ b/libc/sysdeps/linux/i386/sys/ucontext.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_UCONTEXT_H
#define _SYS_UCONTEXT_H 1
diff --git a/libc/sysdeps/linux/i386/sys/user.h b/libc/sysdeps/linux/i386/sys/user.h
index c5cfff256..80dd8a23c 100644
--- a/libc/sysdeps/linux/i386/sys/user.h
+++ b/libc/sysdeps/linux/i386/sys/user.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_USER_H
#define _SYS_USER_H 1
diff --git a/libc/sysdeps/linux/i386/sys/vm86.h b/libc/sysdeps/linux/i386/sys/vm86.h
index 8faeed7f1..1f7871bfb 100644
--- a/libc/sysdeps/linux/i386/sys/vm86.h
+++ b/libc/sysdeps/linux/i386/sys/vm86.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_VM86_H
diff --git a/libc/sysdeps/linux/i386/sysdep.h b/libc/sysdeps/linux/i386/sysdep.h
new file mode 100644
index 000000000..c92a10663
--- /dev/null
+++ b/libc/sysdeps/linux/i386/sysdep.h
@@ -0,0 +1,429 @@
+/* Copyright (C) 1992,1993,1995-2000,2002-2006,2007
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper, <drepper@gnu.org>, August 1995.
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _LINUX_I386_SYSDEP_H
+#define _LINUX_I386_SYSDEP_H 1
+
+#include <sys/syscall.h>
+#include <common/sysdep.h>
+
+#ifdef __ASSEMBLER__
+
+/* Syntactic details of assembler. */
+
+/* ELF uses byte-counts for .align, most others use log2 of count of bytes. */
+#define ALIGNARG(log2) 1<<log2
+/* For ELF we need the `.type' directive to make shared libs work right. */
+#define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg;
+#define ASM_SIZE_DIRECTIVE(name) .size name,.-name;
+
+/* In ELF C symbols are asm symbols. */
+#undef NO_UNDERSCORES
+#define NO_UNDERSCORES
+
+/* Define an entry point visible from C.
+
+ There is currently a bug in gdb which prevents us from specifying
+ incomplete stabs information. Fake some entries here which specify
+ the current source file. */
+#define ENTRY(name) \
+ .globl C_SYMBOL_NAME(name); \
+ ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
+ .align ALIGNARG(4); \
+ C_LABEL(name) \
+ cfi_startproc; \
+ CALL_MCOUNT
+
+#undef END
+#define END(name) \
+ cfi_endproc; \
+ ASM_SIZE_DIRECTIVE(name) \
+
+/* If compiled for profiling, call `mcount' at the start of each function. */
+#ifdef PROF
+/* The mcount code relies on a normal frame pointer being on the stack
+ to locate our caller, so push one just for its benefit. */
+#define CALL_MCOUNT \
+ pushl %ebp; cfi_adjust_cfa_offset (4); movl %esp, %ebp; \
+ cfi_def_cfa_register (ebp); call JUMPTARGET(mcount); \
+ popl %ebp; cfi_def_cfa (esp, 4);
+#else
+#define CALL_MCOUNT /* Do nothing. */
+#endif
+
+#ifdef NO_UNDERSCORES
+/* Since C identifiers are not normally prefixed with an underscore
+ on this system, the asm identifier `syscall_error' intrudes on the
+ C name space. Make sure we use an innocuous name. */
+#define syscall_error __syscall_error
+#define mcount _mcount
+#endif
+
+#undef JUMPTARGET
+#ifdef __PIC__
+#define JUMPTARGET(name) name##@PLT
+#define SYSCALL_PIC_SETUP \
+ pushl %ebx; \
+ cfi_adjust_cfa_offset (4); \
+ call 0f; \
+0: popl %ebx; \
+ cfi_adjust_cfa_offset (-4); \
+ addl $_GLOBAL_OFFSET_TABLE+[.-0b], %ebx;
+
+
+# define SETUP_PIC_REG(reg) \
+ .ifndef __x86.get_pc_thunk.reg; \
+ .section .gnu.linkonce.t.__x86.get_pc_thunk.reg,"ax",@progbits; \
+ .globl __x86.get_pc_thunk.reg; \
+ .hidden __x86.get_pc_thunk.reg; \
+ .type __x86.get_pc_thunk.reg,@function; \
+__x86.get_pc_thunk.reg: \
+ movl (%esp), %e##reg; \
+ ret; \
+ .size __x86.get_pc_thunk.reg, . - __x86.get_pc_thunk.reg; \
+ .previous; \
+ .endif; \
+ call __x86.get_pc_thunk.reg
+
+# define LOAD_PIC_REG(reg) \
+ SETUP_PIC_REG(reg); addl $_GLOBAL_OFFSET_TABLE_, %e##reg
+
+#else
+#define JUMPTARGET(name) name
+#define SYSCALL_PIC_SETUP /* Nothing. */
+#endif
+
+/* Local label name for asm code. */
+#ifndef L
+#ifdef HAVE_ELF
+#define L(name) .L##name
+#else
+#define L(name) name
+#endif
+#endif
+
+/* Avoid conflics with thunk section */
+#undef __i686
+#endif /* __ASSEMBLER__ */
+
+/* For Linux we can use the system call table in the header file
+ /usr/include/asm/unistd.h
+ of the kernel. But these symbols do not follow the SYS_* syntax
+ so we have to redefine the `SYS_ify' macro here. */
+#undef SYS_ify
+#define SYS_ify(syscall_name) __NR_##syscall_name
+
+#if defined USE_DL_SYSINFO \
+ && (!defined NOT_IN_libc || defined IS_IN_libpthread)
+# define I386_USE_SYSENTER 1
+#else
+# undef I386_USE_SYSENTER
+#endif
+
+#ifdef __ASSEMBLER__
+
+/* Linux uses a negative return value to indicate syscall errors,
+ unlike most Unices, which use the condition codes' carry flag.
+
+ Since version 2.1 the return value of a system call might be
+ negative even if the call succeeded. E.g., the `lseek' system call
+ might return a large offset. Therefore we must not anymore test
+ for < 0, but test for a real error by making sure the value in %eax
+ is a real error number. Linus said he will make sure the no syscall
+ returns a value in -1 .. -4095 as a valid result so we can savely
+ test with -4095. */
+
+/* We don't want the label for the error handle to be global when we define
+ it here. */
+#ifdef __PIC__
+# define SYSCALL_ERROR_LABEL 0f
+#else
+# define SYSCALL_ERROR_LABEL syscall_error
+#endif
+
+#undef PSEUDO
+#define PSEUDO(name, syscall_name, args) \
+ .text; \
+ ENTRY (name) \
+ DO_CALL (syscall_name, args); \
+ cmpl $-4095, %eax; \
+ jae SYSCALL_ERROR_LABEL; \
+ L(pseudo_end):
+
+#undef PSEUDO_END
+#define PSEUDO_END(name) \
+ SYSCALL_ERROR_HANDLER \
+ END (name)
+
+#undef PSEUDO_NOERRNO
+#define PSEUDO_NOERRNO(name, syscall_name, args) \
+ .text; \
+ ENTRY (name) \
+ DO_CALL (syscall_name, args)
+
+#undef PSEUDO_END_NOERRNO
+#define PSEUDO_END_NOERRNO(name) \
+ END (name)
+
+#define ret_NOERRNO ret
+
+/* The function has to return the error code. */
+#undef PSEUDO_ERRVAL
+#define PSEUDO_ERRVAL(name, syscall_name, args) \
+ .text; \
+ ENTRY (name) \
+ DO_CALL (syscall_name, args); \
+ negl %eax
+
+#undef PSEUDO_END_ERRVAL
+#define PSEUDO_END_ERRVAL(name) \
+ END (name)
+
+#ifndef __PIC__
+# define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */
+#else
+
+# ifdef RTLD_PRIVATE_ERRNO
+# define SYSCALL_ERROR_HANDLER \
+0:SETUP_PIC_REG(cx); \
+ addl $_GLOBAL_OFFSET_TABLE_, %ecx; \
+ xorl %edx, %edx; \
+ subl %eax, %edx; \
+ movl %edx, rtld_errno@GOTOFF(%ecx); \
+ orl $-1, %eax; \
+ jmp L(pseudo_end);
+
+# elif defined _LIBC_REENTRANT
+
+# if defined USE___THREAD
+# ifndef NOT_IN_libc
+# define SYSCALL_ERROR_ERRNO __libc_errno
+# else
+# define SYSCALL_ERROR_ERRNO errno
+# endif
+# define SYSCALL_ERROR_HANDLER \
+0:SETUP_PIC_REG (cx); \
+ addl $_GLOBAL_OFFSET_TABLE_, %ecx; \
+ movl SYSCALL_ERROR_ERRNO@GOTNTPOFF(%ecx), %ecx; \
+ xorl %edx, %edx; \
+ subl %eax, %edx; \
+ SYSCALL_ERROR_HANDLER_TLS_STORE (%edx, %ecx); \
+ orl $-1, %eax; \
+ jmp L(pseudo_end);
+# ifndef NO_TLS_DIRECT_SEG_REFS
+# define SYSCALL_ERROR_HANDLER_TLS_STORE(src, destoff) \
+ movl src, %gs:(destoff)
+# else
+# define SYSCALL_ERROR_HANDLER_TLS_STORE(src, destoff) \
+ addl %gs:0, destoff; \
+ movl src, (destoff)
+# endif
+# else
+# define SYSCALL_ERROR_HANDLER \
+0:pushl %ebx; \
+ cfi_adjust_cfa_offset (4); \
+ cfi_rel_offset (ebx, 0); \
+ SETUP_PIC_REG (bx); \
+ addl $_GLOBAL_OFFSET_TABLE_, %ebx; \
+ xorl %edx, %edx; \
+ subl %eax, %edx; \
+ pushl %edx; \
+ cfi_adjust_cfa_offset (4); \
+ call __errno_location@PLT; \
+ popl %ecx; \
+ cfi_adjust_cfa_offset (-4); \
+ popl %ebx; \
+ cfi_adjust_cfa_offset (-4); \
+ cfi_restore (ebx); \
+ movl %ecx, (%eax); \
+ orl $-1, %eax; \
+ jmp L(pseudo_end);
+/* A quick note: it is assumed that the call to `__errno_location' does
+ not modify the stack! */
+# endif
+# else
+/* Store (- %eax) into errno through the GOT. */
+# define SYSCALL_ERROR_HANDLER \
+0:SETUP_PIC_REG(cx); \
+ addl $_GLOBAL_OFFSET_TABLE_, %ecx; \
+ xorl %edx, %edx; \
+ subl %eax, %edx; \
+ movl errno@GOT(%ecx), %ecx; \
+ movl %edx, (%ecx); \
+ orl $-1, %eax; \
+ jmp L(pseudo_end);
+# endif /* _LIBC_REENTRANT */
+#endif /* __PIC__ */
+
+
+/* The original calling convention for system calls on Linux/i386 is
+ to use int $0x80. */
+#ifdef I386_USE_SYSENTER
+# ifdef SHARED
+# define ENTER_KERNEL call *%gs:SYSINFO_OFFSET
+# else
+# define ENTER_KERNEL call *_dl_sysinfo
+# endif
+#else
+# define ENTER_KERNEL int $0x80
+#endif
+
+/* Linux takes system call arguments in registers:
+
+ syscall number %eax call-clobbered
+ arg 1 %ebx call-saved
+ arg 2 %ecx call-clobbered
+ arg 3 %edx call-clobbered
+ arg 4 %esi call-saved
+ arg 5 %edi call-saved
+ arg 6 %ebp call-saved
+
+ The stack layout upon entering the function is:
+
+ 24(%esp) Arg# 6
+ 20(%esp) Arg# 5
+ 16(%esp) Arg# 4
+ 12(%esp) Arg# 3
+ 8(%esp) Arg# 2
+ 4(%esp) Arg# 1
+ (%esp) Return address
+
+ (Of course a function with say 3 arguments does not have entries for
+ arguments 4, 5, and 6.)
+
+ The following code tries hard to be optimal. A general assumption
+ (which is true according to the data books I have) is that
+
+ 2 * xchg is more expensive than pushl + movl + popl
+
+ Beside this a neat trick is used. The calling conventions for Linux
+ tell that among the registers used for parameters %ecx and %edx need
+ not be saved. Beside this we may clobber this registers even when
+ they are not used for parameter passing.
+
+ As a result one can see below that we save the content of the %ebx
+ register in the %edx register when we have less than 3 arguments
+ (2 * movl is less expensive than pushl + popl).
+
+ Second unlike for the other registers we don't save the content of
+ %ecx and %edx when we have more than 1 and 2 registers resp.
+
+ The code below might look a bit long but we have to take care for
+ the pipelined processors (i586). Here the `pushl' and `popl'
+ instructions are marked as NP (not pairable) but the exception is
+ two consecutive of these instruction. This gives no penalty on
+ other processors though. */
+
+#undef DO_CALL
+#define DO_CALL(syscall_name, args) \
+ PUSHARGS_##args \
+ DOARGS_##args \
+ movl $SYS_ify (syscall_name), %eax; \
+ ENTER_KERNEL \
+ POPARGS_##args
+
+#define PUSHARGS_0 /* No arguments to push. */
+#define DOARGS_0 /* No arguments to frob. */
+#define POPARGS_0 /* No arguments to pop. */
+#define _PUSHARGS_0 /* No arguments to push. */
+#define _DOARGS_0(n) /* No arguments to frob. */
+#define _POPARGS_0 /* No arguments to pop. */
+
+#define PUSHARGS_1 movl %ebx, %edx; L(SAVEBX1): PUSHARGS_0
+#define DOARGS_1 _DOARGS_1 (4)
+#define POPARGS_1 POPARGS_0; movl %edx, %ebx; L(RESTBX1):
+#define _PUSHARGS_1 pushl %ebx; cfi_adjust_cfa_offset (4); \
+ cfi_rel_offset (ebx, 0); L(PUSHBX1): _PUSHARGS_0
+#define _DOARGS_1(n) movl n(%esp), %ebx; _DOARGS_0(n-4)
+#define _POPARGS_1 _POPARGS_0; popl %ebx; cfi_adjust_cfa_offset (-4); \
+ cfi_restore (ebx); L(POPBX1):
+
+#define PUSHARGS_2 PUSHARGS_1
+#define DOARGS_2 _DOARGS_2 (8)
+#define POPARGS_2 POPARGS_1
+#define _PUSHARGS_2 _PUSHARGS_1
+#define _DOARGS_2(n) movl n(%esp), %ecx; _DOARGS_1 (n-4)
+#define _POPARGS_2 _POPARGS_1
+
+#define PUSHARGS_3 _PUSHARGS_2
+#define DOARGS_3 _DOARGS_3 (16)
+#define POPARGS_3 _POPARGS_3
+#define _PUSHARGS_3 _PUSHARGS_2
+#define _DOARGS_3(n) movl n(%esp), %edx; _DOARGS_2 (n-4)
+#define _POPARGS_3 _POPARGS_2
+
+#define PUSHARGS_4 _PUSHARGS_4
+#define DOARGS_4 _DOARGS_4 (24)
+#define POPARGS_4 _POPARGS_4
+#define _PUSHARGS_4 pushl %esi; cfi_adjust_cfa_offset (4); \
+ cfi_rel_offset (esi, 0); L(PUSHSI1): _PUSHARGS_3
+#define _DOARGS_4(n) movl n(%esp), %esi; _DOARGS_3 (n-4)
+#define _POPARGS_4 _POPARGS_3; popl %esi; cfi_adjust_cfa_offset (-4); \
+ cfi_restore (esi); L(POPSI1):
+
+#define PUSHARGS_5 _PUSHARGS_5
+#define DOARGS_5 _DOARGS_5 (32)
+#define POPARGS_5 _POPARGS_5
+#define _PUSHARGS_5 pushl %edi; cfi_adjust_cfa_offset (4); \
+ cfi_rel_offset (edi, 0); L(PUSHDI1): _PUSHARGS_4
+#define _DOARGS_5(n) movl n(%esp), %edi; _DOARGS_4 (n-4)
+#define _POPARGS_5 _POPARGS_4; popl %edi; cfi_adjust_cfa_offset (-4); \
+ cfi_restore (edi); L(POPDI1):
+
+#define PUSHARGS_6 _PUSHARGS_6
+#define DOARGS_6 _DOARGS_6 (40)
+#define POPARGS_6 _POPARGS_6
+#define _PUSHARGS_6 pushl %ebp; cfi_adjust_cfa_offset (4); \
+ cfi_rel_offset (ebp, 0); L(PUSHBP1): _PUSHARGS_5
+#define _DOARGS_6(n) movl n(%esp), %ebp; _DOARGS_5 (n-4)
+#define _POPARGS_6 _POPARGS_5; popl %ebp; cfi_adjust_cfa_offset (-4); \
+ cfi_restore (ebp); L(POPBP1):
+
+#endif /* __ASSEMBLER__ */
+
+
+/* Pointer mangling support. */
+#if defined NOT_IN_libc && defined IS_IN_rtld
+/* We cannot use the thread descriptor because in ld.so we use setjmp
+ earlier than the descriptor is initialized. Using a global variable
+ is too complicated here since we have no PC-relative addressing mode. */
+#else
+# ifdef __ASSEMBLER__
+# define PTR_MANGLE(reg) xorl %gs:POINTER_GUARD, reg; \
+ roll $9, reg
+# define PTR_DEMANGLE(reg) rorl $9, reg; \
+ xorl %gs:POINTER_GUARD, reg
+# else
+# include <stddef.h>
+# define PTR_MANGLE(var) __asm__ ("xorl %%gs:%c2, %0\n" \
+ "roll $9, %0" \
+ : "=r" (var) \
+ : "0" (var), \
+ "i" (offsetof (tcbhead_t, \
+ pointer_guard)))
+# define PTR_DEMANGLE(var) __asm__ ("rorl $9, %0\n" \
+ "xorl %%gs:%c2, %0" \
+ : "=r" (var) \
+ : "0" (var), \
+ "i" (offsetof (tcbhead_t, \
+ pointer_guard)))
+# endif
+#endif
+
+#endif /* linux/i386/sysdep.h */
diff --git a/libc/sysdeps/linux/i386/ucontext_i.sym b/libc/sysdeps/linux/i386/ucontext_i.sym
new file mode 100644
index 000000000..b11a5509c
--- /dev/null
+++ b/libc/sysdeps/linux/i386/ucontext_i.sym
@@ -0,0 +1,30 @@
+#include <stddef.h>
+#include <signal.h>
+#include <sys/ucontext.h>
+
+--
+
+SIG_BLOCK
+SIG_SETMASK
+
+#define ucontext(member) offsetof (ucontext_t, member)
+#define mcontext(member) ucontext (uc_mcontext.member)
+#define mreg(reg) mcontext (gregs[REG_##reg])
+
+oLINK ucontext (uc_link)
+oSS_SP ucontext (uc_stack.ss_sp)
+oSS_SIZE ucontext (uc_stack.ss_size)
+oGS mreg (GS)
+oFS mreg (FS)
+oEDI mreg (EDI)
+oESI mreg (ESI)
+oEBP mreg (EBP)
+oESP mreg (ESP)
+oEBX mreg (EBX)
+oEDX mreg (EDX)
+oECX mreg (ECX)
+oEAX mreg (EAX)
+oEIP mreg (EIP)
+oFPREGS mcontext (fpregs)
+oSIGMASK ucontext (uc_sigmask)
+oFPREGSMEM ucontext (__fpregs_mem)
diff --git a/libc/sysdeps/linux/i386/vfork.S b/libc/sysdeps/linux/i386/vfork.S
index 8005ff1d2..d85726f19 100644
--- a/libc/sysdeps/linux/i386/vfork.S
+++ b/libc/sysdeps/linux/i386/vfork.S
@@ -18,9 +18,19 @@
__vfork:
popl %ecx
+
+#ifdef SAVE_PID
+ SAVE_PID
+#endif
+
movl $__NR_vfork,%eax
int $0x80
pushl %ecx
+
+#ifdef RESTORE_PID
+ RESTORE_PID
+#endif
+
cmpl $-4095,%eax
jae __syscall_error
ret
@@ -28,4 +38,4 @@ __vfork:
.size __vfork,.-__vfork
weak_alias(__vfork,vfork)
-libc_hidden_weak(vfork)
+libc_hidden_def(vfork)
diff --git a/libc/sysdeps/linux/i960/AUTHORS b/libc/sysdeps/linux/i960/AUTHORS
deleted file mode 100644
index 0d6554927..000000000
--- a/libc/sysdeps/linux/i960/AUTHORS
+++ /dev/null
@@ -1,4 +0,0 @@
-The initial support (inspired by what was done in an old i960 port of uC-libc):
-
-Martin Proulx <mproulx at okiok.com>
-http://www.okiok.com
diff --git a/libc/sysdeps/linux/i960/Makefile b/libc/sysdeps/linux/i960/Makefile
deleted file mode 100644
index d6ae358eb..000000000
--- a/libc/sysdeps/linux/i960/Makefile
+++ /dev/null
@@ -1,55 +0,0 @@
-# Makefile 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.
-
-TOPDIR=../../../../
-include $(TOPDIR)Rules.mak
-
-#FIXME -- this arch should include its own crti.S and crtn.S
-UCLIBC_CTOR_DTOR=n
-
-CRT_SRC := crt0.S
-CRT_OBJ := crt0.o crt1.o
-CTOR_TARGETS := $(TOPDIR)lib/crti.o $(TOPDIR)lib/crtn.o
-
-SSRC := clone.S _mmap.S setjmp.S vfork.S
-SOBJ := $(patsubst %.S,%.o, $(SSRC))
-
-OBJS := $(SOBJ)
-
-OBJ_LIST := ../../../obj.sysdeps.$(TARGET_ARCH)
-
-all: $(OBJ_LIST) $(CTOR_TARGETS)
-
-$(OBJ_LIST): $(OBJS) $(CRT_OBJ)
- $(STRIPTOOL) -x -R .note -R .comment $^
- $(INSTALL) -d $(TOPDIR)lib/
- cp $(CRT_OBJ) $(TOPDIR)lib/
- echo $(patsubst %, sysdeps/linux/$(TARGET_ARCH)/%, $(OBJS)) > $@
-
-$(CRT_OBJ): $(CRT_SRC)
- $(CC) $(ASFLAGS) -DL_$* $< -c -o $*.o
-
-$(SOBJ): %.o : %.S
- $(CC) $(ASFLAGS) -c $< -o $@
-
-ifeq ($(UCLIBC_CTOR_DTOR),y)
-$(TOPDIR)lib/crti.o: crti.S
- $(INSTALL) -d $(TOPDIR)lib/
- $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c $< -o $@
-
-$(TOPDIR)lib/crtn.o: crtn.S
- $(INSTALL) -d $(TOPDIR)lib/
- $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c $< -o $@
-else
-$(CTOR_TARGETS):
- $(INSTALL) -d $(TOPDIR)lib/
- $(AR) $(ARFLAGS) $@
-endif
-
-headers:
-
-clean:
- $(RM) *.o *~ core
diff --git a/libc/sysdeps/linux/i960/README b/libc/sysdeps/linux/i960/README
deleted file mode 100644
index 751673508..000000000
--- a/libc/sysdeps/linux/i960/README
+++ /dev/null
@@ -1,71 +0,0 @@
-Overview
----------------------------------------------------------------------------
-
-This is the README file for the i960 support in uClibc.
-
-This has been tested with gcc 2.95.3 and i960-intel-coff target.
-
-There is no support at all to compile with the intel CTOOLS, as this would
-have required too many changes to uClibc. So you won't see any support
-in the asm files for position independent data or code.
-
-Quirks needed
----------------------------------------------------------------------------
-
-prepended underscore
---------------------
-
-As the i960 compiler prepends an underscore to symbols, it is critical that
-Rules.mak defines SYMBOL_PREFIX as _, such that -D__UCLIBC_UNDERSCORES__
-is added to CFLAGS to make sure that underscores are applied to symbol
-names when needed.
-
-
-__va_copy in va-i960.h
-----------------------
-
-When compiled with gcc-2.95, the __va_copy macro in va-i960.h seems to be broken
-and it has to be modified in order for uClibc to compile correctly.
-
-Change:
-
-#define __va_copy(dest, src) (dest) = (src)
-
-To:
-
-#define __va_copy(dest, src) dest[0] = src[0]; dest[1] = src[1]
-
-
-gcc integration
----------------------------------------------------------------------------
-
-I've preferred modifying the specs file so that the i960-intel-coff compiler
-directly compiles with uClibc.
-
-First, compile and install the standard i960-intel-coff compiler, which is meant
-to be used with newlib.
-
-Then, compile uClibc, installing over the newlib include files and libraries.
-
-Update the specs file with the included specs.uclinux.gcc-2.95.i960-intel-coff
-
-This specs file always build relocatable objects, which has the disadvantage
-of not letting you know if the link is missing any symbols.
-
-coff2flt
----------------------------------------------------------------------------
-
-In order to run the executables under uClinux, fully relocatable binaries
-need to be built using coff2flt.
-
-We have built a working coff2flt that works with the i960 and the current version
-of binfmt_flat with uClinux.
-
-Contact Martin Proulx <mproulx at okiok.com> for further informations.
-
-
-
-
-
-Check:
- _mmap.S: besoin???
diff --git a/libc/sysdeps/linux/i960/bits/mman.h b/libc/sysdeps/linux/i960/bits/mman.h
deleted file mode 100644
index 48f46c274..000000000
--- a/libc/sysdeps/linux/i960/bits/mman.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* Definitions for POSIX memory map interface. Linux/i960 version.
- Copyright (C) 1997, 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 _SYS_MMAN_H
-# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
-#endif
-
-/* The following definitions basically come from the kernel headers.
- But the kernel header is not namespace clean. */
-
-
-/* Protections are chosen from these bits, OR'd together. The
- implementation does not necessarily support PROT_EXEC or PROT_WRITE
- without PROT_READ. The only guarantees are that no writing will be
- allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
-
-#define PROT_READ 0x1 /* Page can be read. */
-#define PROT_WRITE 0x2 /* Page can be written. */
-#define PROT_EXEC 0x4 /* Page can be executed. */
-#define PROT_NONE 0x0 /* Page can not be accessed. */
-
-/* Sharing types (must choose one and only one of these). */
-#define MAP_SHARED 0x01 /* Share changes. */
-#define MAP_PRIVATE 0x02 /* Changes are private. */
-#ifdef __USE_MISC
-# define MAP_TYPE 0x0f /* Mask for type of mapping. */
-#endif
-
-/* Other flags. */
-#define MAP_FIXED 0x10 /* Interpret addr exactly. */
-#ifdef __USE_MISC
-# define MAP_FILE 0
-# define MAP_ANONYMOUS 0x20 /* Don't use a file. */
-# define MAP_ANON MAP_ANONYMOUS
-#endif
-
-/* These are Linux-specific. */
-#ifdef __USE_MISC
-# define MAP_GROWSDOWN 0x0100 /* Stack-like segment. */
-# define MAP_DENYWRITE 0x0800 /* ETXTBSY */
-# define MAP_EXECUTABLE 0x1000 /* Mark it as an executable. */
-# define MAP_LOCKED 0x2000 /* Lock the mapping. */
-# define MAP_NORESERVE 0x4000 /* Don't check for reservations. */
-#endif
-
-/* Flags to `msync'. */
-#define MS_ASYNC 1 /* Sync memory asynchronously. */
-#define MS_SYNC 4 /* Synchronous memory sync. */
-#define MS_INVALIDATE 2 /* Invalidate the caches. */
-
-/* Flags for `mlockall'. */
-#define MCL_CURRENT 1 /* Lock all currently mapped pages. */
-#define MCL_FUTURE 2 /* Lock all additions to address
- space. */
-
-/* Flags for `mremap'. */
-#ifdef __USE_GNU
-# define MREMAP_MAYMOVE 1
-# define MREMAP_FIXED 2
-#endif
-
-/* Advice to `madvise'. */
-#ifdef __USE_BSD
-# define MADV_NORMAL 0 /* No further special treatment. */
-# define MADV_RANDOM 1 /* Expect random page references. */
-# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
-# define MADV_WILLNEED 3 /* Will need these pages. */
-# define MADV_DONTNEED 4 /* Don't need these pages. */
-#endif
-
-/* The POSIX people had to invent similar names for the same things. */
-#ifdef __USE_XOPEN2K
-# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
-# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
-# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
-# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
-# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
-#endif
diff --git a/libc/sysdeps/linux/i960/bits/setjmp.h b/libc/sysdeps/linux/i960/bits/setjmp.h
deleted file mode 100644
index f90e4cec7..000000000
--- a/libc/sysdeps/linux/i960/bits/setjmp.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Define the machine-dependent type `jmp_buf'. i960 version. */
-
-#ifndef _BITS_SETJMP_H
-#define _BITS_SETJMP_H 1
-
-#if !defined _SETJMP_H && !defined _PTHREAD_H
-# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
-#endif
-
-/*
- * assume that every single local and global register
- * must be saved.
- *
- * ___SAVEREGS is the number of quads to save.
- *
- * Using the structure will guarantee quad-word alignment for the
- * jmp_buf type.
- */
-
-#define ___SAVEREGS 8
-
-typedef struct __jmp_buf__ {
- long _q0;
- long _q1;
- long _q2;
- long _q3;
-} __attribute__ ((aligned (16))) __jmp_buf[___SAVEREGS] ;
-
-/* I have not yet figured out what this should be for the i960... */
-
-#if 0
-/* Test if longjmp to JMPBUF would unwind the frame
- containing a local variable at ADDRESS. */
-#define _JMPBUF_UNWINDS(jmpbuf, address) \
- ((void *) (address) < (void *) (jmpbuf)[0].__sp)
-#endif
-
-#endif /* bits/setjmp.h */
diff --git a/libc/sysdeps/linux/i960/bits/syscalls.h b/libc/sysdeps/linux/i960/bits/syscalls.h
deleted file mode 100644
index b21851333..000000000
--- a/libc/sysdeps/linux/i960/bits/syscalls.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef _BITS_SYSCALLS_H
-#define _BITS_SYSCALLS_H
-#ifndef _SYSCALL_H
-# error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
-#endif
-
-#include <features.h>
-
-/* Do something very evil for now. Until we create our own syscall
- * macros, short circuit bits/sysnum.h and use asm/unistd.h instead */
-#warning "fixme -- add arch specific syscall macros.h"
-#include <asm/unistd.h>
-
-#endif /* _BITS_SYSCALLS_H */
-
diff --git a/libc/sysdeps/linux/i960/bits/uClibc_arch_features.h b/libc/sysdeps/linux/i960/bits/uClibc_arch_features.h
deleted file mode 100644
index cd6bcd9d0..000000000
--- a/libc/sysdeps/linux/i960/bits/uClibc_arch_features.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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 ? */
-#undef __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() ? */
-#define __UCLIBC_BROKEN_CREATE_MODULE__
-
-/* 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 IEEE signed zero floats */
-#define __UCLIBC_HAVE_SIGNED_ZERO__
-
-#endif /* _BITS_UCLIBC_ARCH_FEATURES_H */
diff --git a/libc/sysdeps/linux/i960/clone.S b/libc/sysdeps/linux/i960/clone.S
deleted file mode 100644
index f602fbabc..000000000
--- a/libc/sysdeps/linux/i960/clone.S
+++ /dev/null
@@ -1,62 +0,0 @@
-#
-# clone.S, part of the i960 support for the uClibc library.
-#
-# Copyright (C) 2002 by Okiok Data Ltd. http://www.okiok.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.,
-# at 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# Derived from an old port of uC-libc to the i960 by Keith Adams (kma@cse.ogi.edu).
-#
-
-#include <sys/syscall.h>
-#include <bits/errno.h>
-
-/* clone is even more special than fork as it mucks with stacks
- and invokes a function in the right context after its all over. */
-
-/* int _clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */
-
- .globl clone
-clone:
- /* set up new stack image in regs r4-r7; argument will be in r3 in child. */
- ldconst 0, r4 /* pfp == 0 */
- addo 16, g1, r5 /* sp == newfp + 16 */
- mov g0, r6 /* rip == fnc */
- mov g2, r7
- stq r4, (g1)
-
- addo sp, 4, sp
- st g10, -4(sp)
- mov sp, g10
- ldconst __NR_clone, g13
- calls 0
-
- /* Do the system call */
- cmpibg 0, g0, __syscall_error /* if < 0, error */
- be thread_start /* if == 0, we're the child */
- ret /* we're the parent */
-
-__syscall_error:
- not g0, r3
- callx ___errno_location
- st r3, (g0)
- ret
-
-thread_start:
- # our new pfp is in g1; here we go
- flushreg
- mov g1, pfp
- flushreg
- ret
diff --git a/libc/sysdeps/linux/i960/crt0.S b/libc/sysdeps/linux/i960/crt0.S
deleted file mode 100644
index b167ad71a..000000000
--- a/libc/sysdeps/linux/i960/crt0.S
+++ /dev/null
@@ -1,58 +0,0 @@
-#
-# crt0.S, part of the i960 support for the uClibc library.
-#
-# Copyright (C) 2002 by Okiok Data Ltd. http://www.okiok.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.,
-# at 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-
-/*
- *
- * The behavior in this file is tightly coupled with how the linux kernel sets things up
- * on the stack before calling us.
- *
- * Currently fs/binfmt_flat.c (for STACK_GROWS_UP) and arch/i960/kernel/process.c
- * build things so that a pointer to argc is left in g13 by start_thread().
- *
- * ^
- * | <- sp somewhere around here, after being aligned.
- * |
- * |envp -> envp[0]
- * |argv -> argv[0]
- * |argc <- g13
- *
- * A complete picture of how things are set up can be seen in the comments of
- * create_flat_tables_stack_grows_up in fs/binfmt_flat.c
- *
- * I believe having to use this register could probably be avoided.
- *
- */
-
- .globl start
-start:
- mov g13, r3
- ldt (r3), g0
- callx ___uClibc_main
-
-/* We might want to add some instruction so that it crashes if main returns */
-
-/* Define a symbol for the first piece of initialized data. */
- .data
- .globl __data_start
-__data_start:
- .long 0
- .weak data_start
- data_start = __data_start
-
diff --git a/libc/sysdeps/linux/i960/mmap.S b/libc/sysdeps/linux/i960/mmap.S
deleted file mode 100644
index bc4267948..000000000
--- a/libc/sysdeps/linux/i960/mmap.S
+++ /dev/null
@@ -1,52 +0,0 @@
-#
-# __mmap.S, part of the i960 support for the uClibc library.
-#
-# Copyright (C) 2002 by Okiok Data Ltd. http://www.okiok.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.,
-# at 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# Derived from an old port of uC-libc to the i960 by Keith Adams (kma@cse.ogi.edu).
-#
-
-#include <sys/syscall.h>
-
-/* This is a plain system call. The 6 arguments are already set up correctly */
-/* void * mmap(void *start, size_t length, int prot , int flags, int fd, off_t offset) */
-
-
- .globl _mmap
-_mmap:
- mov g13, r3
- ldconst __NR_mmap, g13
- calls 0
- mov r3, g13
-
- /* We now need to check if the return value is a small negative integer. */
- /* This is somewhat tricky as the return code (normally an address) is an */
- /* unsigned type, or an ordinal in i960 assembler. */
- /* We'll use the fact that, integers from -256 to -1 are ordinals 0xFFFFFF00 to 0xFFFFFFFF. */
- /* So by checking that the return address is in the top range of the ordinals, we'll */
- /* in fact be checking if it's not an encoded negated erro code. */
-
- /* The range -256 to -1 should be enough since that in uClinux 2.0.39, there are */
- /* 124 system calls for the i960. */
-
- ldconst 0xFFFFFF00, r3 /* This is the integer's -256 representation */
- cmpobl g0, r3, 1f /* Something smaller than this means it's out of the range, and a valid address */
- subi g0, 0, r3 /* If it's an errno, save its negated (now positive) value in _errno. */
- st r3, _errno
- subi 1, 0, g0 /* And return -1. */
-1:
- ret
diff --git a/libc/sysdeps/linux/i960/setjmp.S b/libc/sysdeps/linux/i960/setjmp.S
deleted file mode 100644
index 2133ef557..000000000
--- a/libc/sysdeps/linux/i960/setjmp.S
+++ /dev/null
@@ -1,124 +0,0 @@
-/*******************************************************************************
- *
- * Copyright (c) 1993 Intel Corporation
- *
- * Intel hereby grants you permission to copy, modify, and distribute this
- * software and its documentation. Intel grants this permission provided
- * that the above copyright notice appears in all copies and that both the
- * copyright notice and this permission notice appear in supporting
- * documentation. In addition, Intel grants this permission provided that
- * you prominently mark as "not part of the original" any modifications
- * made to this software or documentation, and that the name of Intel
- * Corporation not be used in advertising or publicity pertaining to
- * distribution of the software or the documentation without specific,
- * written prior permission.
- *
- * Intel Corporation provides this AS IS, WITHOUT ANY WARRANTY, EXPRESS OR
- * IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY
- * OR FITNESS FOR A PARTICULAR PURPOSE. Intel makes no guarantee or
- * representations regarding the use of, or the results of the use of,
- * the software and documentation in terms of correctness, accuracy,
- * reliability, currentness, or otherwise; and you rely on the software,
- * documentation and results solely at your own risk.
- *
- * IN NO EVENT SHALL INTEL BE LIABLE FOR ANY LOSS OF USE, LOSS OF BUSINESS,
- * LOSS OF PROFITS, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES
- * OF ANY KIND. IN NO EVENT SHALL INTEL'S TOTAL LIABILITY EXCEED THE SUM
- * PAID TO INTEL FOR THE PRODUCT LICENSED HEREUNDER.
- *
- ******************************************************************************/
-
-/***************************************************************************
- *
- * Modified from the original in order to fit with
- * uClibc's setjmp, _setjmp, __sigsetjmp and ___sigjmp_save.
- *
- *
- * int setjmp (jmp_buf __env) is the BSD style setjmp function.
- * It simply calls __sigsetjmp(env, 1)
- *
- * int _setjmp (jmp_buf __env) is the posix style setjmp function.
- * It simply calls __sigsetjmp(env, 0)
- * This is the one normally used.
- *
- ***************************************************************************/
-
- .text
- .align 4
- .globl _setjmp
- .globl __setjmp
-
-_setjmp:
- mov 1, g1 /* __sigsetjmp(env, 1) */
- bx __sigsetjmp
-
-__setjmp:
- mov 0, g1 /* __sigsetjmp(env, 0) */
- bx __sigsetjmp
-
-
-/******************************************************************************/
-/* */
-/* setjmp(), longjmp() */
-/* */
-/******************************************************************************/
- .file "setjmp.S"
- .text
- /* .link_pix */
-
- .align 4
- .globl __sigsetjmp
-__sigsetjmp:
- flushreg
- andnot 0xf,pfp,g2 /* get pfp, mask out return status bits */
- st g2, 0x58(g0) /* save fp of caller*/
- /* save globals not killed by the calling convention */
- stq g8, 0x40(g0) /* save g8-g11*/
- st g12, 0x50(g0) /* save g12*/
- st g14, 0x54(g0) /* save g14*/
- /* save previous frame local registers */
- ldq (g2), g4 /* get previous frame pfp, sp, rip, r3 */
- stq g4, (g0) /* save pfp, sp, rip, r3 */
- ldq 0x10(g2), g4 /* get previous frame r4-r7 */
- stq g4, 0x10(g0) /* save r4-r7 */
- ldq 0x20(g2), g4 /* get previous frame r8-r11 */
- stq g4, 0x20(g0) /* save r8-r11 */
- ldq 0x30(g2), g4 /* get previous frame r12-r15 */
- stq g4, 0x30(g0) /* save r12-r15 */
-
- bx ___sigjmp_save
-
- /*
- * fake a return to the place that called the corresponding __sigsetjmp
- */
- .align 4
- .globl ___longjmp
-___longjmp:
- call 0f /* ensure there is at least one stack frame */
-
-0:
- flushreg /* do this before swapping stack */
- ld 0x58(g0), pfp /* get fp of caller of setjmp */
- /* restore local registers
- * the following code modifies the frame of the function which originally
- * called setjmp.
- */
- ldq (g0), g4 /* get pfp, sp, rip, r3 */
- stq g4, (pfp) /* restore pfp, sp, rip, r3 */
- ldq 0x10(g0), g4 /* get r4-r7 */
- stq g4, 0x10(pfp) /* restore r4-r7 */
- ldq 0x20(g0), g4 /* get r8-r11 */
- stq g4, 0x20(pfp) /* restore r8-r11 */
- ldq 0x30(g0), g4 /* get r12-r15 */
- stq g4, 0x30(pfp) /* restore r12-r15 */
- /* restore global registers */
- ldq 0x40(g0), g8 /* get old g8-g11 values */
- ld 0x50(g0), g12 /* get old g12 value */
- ld 0x54(g0), g14 /* get old g14 value */
-
- mov g1, g0 /* get return value */
- cmpo g0, 0 /* make sure it is not zero */
- bne 0f
- mov 1, g0 /* return 1 by default */
-0:
- ret /* return to caller of __sigsetjmp */
diff --git a/libc/sysdeps/linux/i960/specs.uclinux.gcc-2.95.i960-intel-coff b/libc/sysdeps/linux/i960/specs.uclinux.gcc-2.95.i960-intel-coff
deleted file mode 100644
index cefd8533e..000000000
--- a/libc/sysdeps/linux/i960/specs.uclinux.gcc-2.95.i960-intel-coff
+++ /dev/null
@@ -1,64 +0,0 @@
-*asm:
-%{mka:-AKA}%{mkb:-AKB}%{msa:-ASA}%{msb:-ASB} %{mmc:-AMC}%{mca:-ACA}%{mcc:-ACC}%{mcf:-ACF} %{mja:-AJX}%{mjd:-AJX}%{mjf:-AJX}%{mrp:-AJX} %{!mka:%{!mkb:%{!msa:%{!msb:%{!mmc:%{!mca:%{!mcc:%{!mcf:%{!mja:%{!mjd:%{!mjf:%{!mrp:-AKB}}}}}}}}}}}} %{mlink-relax:-linkrelax}
-
-*asm_final:
-
-
-*cpp:
-%{mic*:-D__i960 %{mka:-D__i960KA}%{mkb:-D__i960KB} %{mja:-D__i960JA}%{mjd:-D__i960JD}%{mjf:-D__i960JF} %{mrp:-D__i960RP} %{msa:-D__i960SA}%{msb:-D__i960SB} %{mmc:-D__i960MC} %{mca:-D__i960CA}%{mcc:-D__i960CC} %{mcf:-D__i960CF}} %{mka:-D__i960KA__ -D__i960_KA__} %{mkb:-D__i960KB__ -D__i960_KB__} %{msa:-D__i960SA__ -D__i960_SA__} %{msb:-D__i960SB__ -D__i960_SB__} %{mmc:-D__i960MC__ -D__i960_MC__} %{mca:-D__i960CA__ -D__i960_CA__} %{mcc:-D__i960CC__ -D__i960_CC__} %{mcf:-D__i960CF__ -D__i960_CF__} %{!mka:%{!mkb:%{!msa:%{!msb:%{!mmc:%{!mca: %{!mcc:%{!mcf:-D__i960_KB -D__i960KB__ %{mic*:-D__i960KB}}}}}}}}} %{mlong-double-64:-D__LONG_DOUBLE_64__}
-
-*cc1:
-%{!mka:%{!mkb:%{!msa:%{!msb:%{!mmc:%{!mca:%{!mcc:%{!mcf:%{!mja:%{!mjd:%{!mjf:%{!mrp:-mka}}}}}}}}}}}} %{!gs*:%{!gc*:%{mbout:%{g*:-gstabs}} %{mcoff:%{g*:-gcoff}} %{!mbout:%{!mcoff:%{g*:-gstabs}}}}}
-
-*cc1plus:
-
-
-*endfile:
-crtn.o%s
-
-*link:
-%{mka:-AKA}%{mkb:-AKB}%{msa:-ASA}%{msb:-ASB} %{mmc:-AMC}%{mca:-ACA}%{mcc:-ACC}%{mcf:-ACF} %{mja:-AJX}%{mjd:-AJX}%{mjf:-AJX}%{mrp:-AJX} %{mbout:-Fbout}%{mcoff:-Fcoff} %{mlink-relax:-relax} -r -d
-
-*lib:
--lc -lgcc
-
-*libgcc:
-
-
-*startfile:
-%{!shared:%{pg:pgcrt0%O%s}%{!pg:%{p:pcrt0%O%s}%{!p:crt0%O%s}}} crti.o%s
-
-*switches_need_spaces:
-
-
-*signed_char:
-%{!fsigned-char:%{!mic*:-D__CHAR_UNSIGNED__}}
-
-*predefines:
--Di960 -Di80960 -DI960 -DI80960 -Acpu(i960) -Amachine(i960) -Dunix -Dlinux -Asystem(posix) -D__linux__ -D__uClinux__ -DEMBED
-
-*cross_compile:
-1
-
-*version:
-2.95.3
-
-*multilib:
-. !mnumerics !msoft-float !mlong-double-64;float mnumerics !msoft-float !mlong-double-64;soft-float !mnumerics msoft-float !mlong-double-64;ld64 !mnumerics !msoft-float mlong-double-64;float/ld64 mnumerics !msoft-float mlong-double-64;soft-float/ld64 !mnumerics msoft-float mlong-double-64;
-
-*multilib_defaults:
-mnumerics
-
-*multilib_extra:
-
-
-*multilib_matches:
-msb mnumerics;msc mnumerics;mkb mnumerics;mkc mnumerics;mmc mnumerics;mcb mnumerics;mcc mnumerics;mjf mnumerics;msa msoft-float;mka msoft-float;mca msoft-float;mcf msoft-float;mnumerics mnumerics;msoft-float msoft-float;mlong-double-64 mlong-double-64;
-
-*linker:
-collect2
-
-*link_command:
-%{!fsyntax-only: %{!c:%{!M:%{!MM:%{!E:%{!S:%(linker) %l %X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r} %{s} %{t} %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}} %{static:} %{L*} %D %o %{!nostdlib:%{!nodefaultlibs:%G %L %G}} %{!A:%{!nostdlib:%{!nostartfiles:%E}}} %{T*}
- }}}}}}
-
diff --git a/libc/sysdeps/linux/i960/vfork.S b/libc/sysdeps/linux/i960/vfork.S
deleted file mode 100644
index 1646e1be4..000000000
--- a/libc/sysdeps/linux/i960/vfork.S
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * clone.S, part of the i960 support for the uClibc library.
- *
- * Copyright (C) 2002 by Okiok Data Ltd. http://www.okiok.com/
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-/*
- * Derived from an old port of uC-libc to the i960 by Keith Adams (kma@cse.ogi.edu).
- */
-
-#include <sys/syscall.h>
-
-#ifndef __NR_vfork
-#define __NR_vfork __NR_fork /* uClinux-2.0 only has fork which is vfork */
-#endif
-
- .globl ___vfork
- .hidden ___vfork
-___vfork:
- mov g13, r3
- ldconst __NR_vfork, g13
- calls 0
- mov r3, g13
- cmpible 0, g0, 1f
- subo g0, 0, r3
- st r3, _errno
-1:
- ret
-
-weak_alias(__vfork,vfork)
-libc_hidden_weak(vfork)
diff --git a/libc/sysdeps/linux/ia64/Makefile.arch b/libc/sysdeps/linux/ia64/Makefile.arch
index 2b3212498..e95e86873 100644
--- a/libc/sysdeps/linux/ia64/Makefile.arch
+++ b/libc/sysdeps/linux/ia64/Makefile.arch
@@ -5,10 +5,8 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-CSRC := __syscall_error.c
+CSRC-y := __syscall_error.c
-SSRC := \
+SSRC-y := \
__longjmp.S brk.S bsd-setjmp.S bsd-_setjmp.S clone2.S fork.S \
pipe.S setjmp.S syscall.S vfork.S
-
-include $(top_srcdir)libc/sysdeps/linux/Makefile.commonarch
diff --git a/libc/sysdeps/linux/ia64/__longjmp.S b/libc/sysdeps/linux/ia64/__longjmp.S
index 04c51e75e..fb34ab237 100644
--- a/libc/sysdeps/linux/ia64/__longjmp.S
+++ b/libc/sysdeps/linux/ia64/__longjmp.S
@@ -12,9 +12,8 @@
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.
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>.
Note that __sigsetjmp() did NOT flush the register stack. Instead,
we do it here since __longjmp() is usually much less frequently
@@ -44,18 +43,18 @@
LEAF(__longjmp)
alloc r8=ar.pfs,2,1,0,0
mov r27=ar.rsc
- add r2=0x98,in0 // r2 <- &jmpbuf.orig_jmp_buf_addr
+ add r2=0x98,in0 /* r2 <- &jmpbuf.orig_jmp_buf_addr */
;;
- ld8 r8=[r2],-16 // r8 <- orig_jmp_buf_addr
+ ld8 r8=[r2],-16 /* r8 <- orig_jmp_buf_addr */
mov r10=ar.bsp
- and r11=~0x3,r27 // clear ar.rsc.mode
+ and r11=~0x3,r27 /* clear ar.rsc.mode */
;;
- flushrs // flush dirty regs to backing store (must be first in insn grp)
- ld8 r23=[r2],8 // r23 <- jmpbuf.ar_bsp
- sub r8=r8,in0 // r8 <- &orig_jmpbuf - &jmpbuf
+ flushrs /* flush dirty regs to backing store (must be first in insn grp) */
+ ld8 r23=[r2],8 /* r23 <- jmpbuf.ar_bsp */
+ sub r8=r8,in0 /* r8 <- &orig_jmpbuf - &jmpbuf */
;;
- ld8 r25=[r2] // r25 <- jmpbuf.ar_unat
- extr.u r8=r8,3,6 // r8 <- (&orig_jmpbuf - &jmpbuf)/8 & 0x3f
+ ld8 r25=[r2] /* r25 <- jmpbuf.ar_unat */
+ extr.u r8=r8,3,6 /* r8 <- (&orig_jmpbuf - &jmpbuf)/8 & 0x3f */
;;
cmp.lt pNeg,pPos=r8,r0
mov r2=in0
@@ -65,49 +64,49 @@ LEAF(__longjmp)
(pPos) sub r17=64,r8
(pNeg) sub r17=r0,r8
;;
- mov ar.rsc=r11 // put RSE in enforced lazy mode
+ mov ar.rsc=r11 /* put RSE in enforced lazy mode */
shr.u r8=r25,r16
- add r3=8,in0 // r3 <- &jmpbuf.r1
+ add r3=8,in0 /* r3 <- &jmpbuf.r1 */
shl r9=r25,r17
;;
or r25=r8,r9
;;
mov r26=ar.rnat
- mov ar.unat=r25 // setup ar.unat (NaT bits for r1, r4-r7, and r12)
+ mov ar.unat=r25 /* setup ar.unat (NaT bits for r1, r4-r7, and r12) */
;;
- ld8.fill.nta sp=[r2],16 // r12 (sp)
- ld8.fill.nta gp=[r3],16 // r1 (gp)
- dep r11=-1,r23,3,6 // r11 <- ia64_rse_rnat_addr(jmpbuf.ar_bsp)
+ ld8.fill.nta sp=[r2],16 /* r12 (sp) */
+ ld8.fill.nta gp=[r3],16 /* r1 (gp) */
+ dep r11=-1,r23,3,6 /* r11 <- ia64_rse_rnat_addr(jmpbuf.ar_bsp) */
;;
- ld8.nta r16=[r2],16 // caller's unat
- ld8.nta r17=[r3],16 // fpsr
+ ld8.nta r16=[r2],16 /* caller's unat */
+ ld8.nta r17=[r3],16 /* fpsr */
;;
- ld8.fill.nta r4=[r2],16 // r4
- ld8.fill.nta r5=[r3],16 // r5 (gp)
- cmp.geu p8,p0=r10,r11 // p8 <- (ar.bsp >= jmpbuf.ar_bsp)
+ ld8.fill.nta r4=[r2],16 /* r4 */
+ ld8.fill.nta r5=[r3],16 /* r5 (gp) */
+ cmp.geu p8,p0=r10,r11 /* p8 <- (ar.bsp >= jmpbuf.ar_bsp) */
;;
- ld8.fill.nta r6=[r2],16 // r6
- ld8.fill.nta r7=[r3],16 // r7
+ ld8.fill.nta r6=[r2],16 /* r6 */
+ ld8.fill.nta r7=[r3],16 /* r7 */
;;
- mov ar.unat=r16 // restore caller's unat
- mov ar.fpsr=r17 // restore fpsr
+ mov ar.unat=r16 /* restore caller's unat */
+ mov ar.fpsr=r17 /* restore fpsr */
;;
- ld8.nta r16=[r2],16 // b0
- ld8.nta r17=[r3],16 // b1
+ ld8.nta r16=[r2],16 /* b0 */
+ ld8.nta r17=[r3],16 /* b1 */
;;
-(p8) ld8 r26=[r11] // r26 <- *ia64_rse_rnat_addr(jmpbuf.ar_bsp)
- mov ar.bspstore=r23 // restore ar.bspstore
+(p8) ld8 r26=[r11] /* r26 <- *ia64_rse_rnat_addr(jmpbuf.ar_bsp) */
+ mov ar.bspstore=r23 /* restore ar.bspstore */
;;
- ld8.nta r18=[r2],16 // b2
- ld8.nta r19=[r3],16 // b3
+ ld8.nta r18=[r2],16 /* b2 */
+ ld8.nta r19=[r3],16 /* b3 */
;;
- ld8.nta r20=[r2],16 // b4
- ld8.nta r21=[r3],16 // b5
+ ld8.nta r20=[r2],16 /* b4 */
+ ld8.nta r21=[r3],16 /* b5 */
;;
- ld8.nta r11=[r2],16 // ar.pfs
- ld8.nta r22=[r3],56 // ar.lc
+ ld8.nta r11=[r2],16 /* ar.pfs */
+ ld8.nta r22=[r3],56 /* ar.lc */
;;
- ld8.nta r24=[r2],32 // pr
+ ld8.nta r24=[r2],32 /* pr */
mov b0=r16
;;
ldf.fill.nta f2=[r2],32
@@ -149,12 +148,12 @@ LEAF(__longjmp)
ldf.fill.nta f31=[r3]
(p8) mov r8=1
- mov ar.rnat=r26 // restore ar.rnat
+ mov ar.rnat=r26 /* restore ar.rnat */
;;
- mov ar.rsc=r27 // restore ar.rsc
+ mov ar.rsc=r27 /* restore ar.rsc */
(p9) mov r8=in1
- invala // virt. -> phys. regnum mapping may change
+ invala /* virt. -> phys. regnum mapping may change */
mov pr=r24,-1
ret
END(__longjmp)
diff --git a/libc/sysdeps/linux/ia64/bits/atomic.h b/libc/sysdeps/linux/ia64/bits/atomic.h
index 1020c2f22..1b6ee2b57 100644
--- a/libc/sysdeps/linux/ia64/bits/atomic.h
+++ b/libc/sysdeps/linux/ia64/bits/atomic.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <stdint.h>
#include <ia64intrin.h>
@@ -92,12 +91,12 @@ typedef uintmax_t uatomic_max_t;
do \
{ \
__oldval = __val; \
- if (__builtin_expect (__val <= 0, 0)) \
+ if (unlikely (__val <= 0)) \
break; \
__val = atomic_compare_and_exchange_val_acq (__memp, __oldval - 1, \
__oldval); \
} \
- while (__builtin_expect (__val != __oldval, 0)); \
+ while (unlikely (__val != __oldval)); \
__oldval; })
#define atomic_bit_test_set(mem, bit) \
@@ -113,7 +112,7 @@ typedef uintmax_t uatomic_max_t;
__oldval | __mask, \
__oldval); \
} \
- while (__builtin_expect (__val != __oldval, 0)); \
+ while (unlikely (__val != __oldval)); \
__oldval & __mask; })
#define atomic_full_barrier() __sync_synchronize ()
diff --git a/libc/sysdeps/linux/ia64/bits/byteswap.h b/libc/sysdeps/linux/ia64/bits/byteswap.h
index 6862aa0b6..0e352fcad 100644
--- a/libc/sysdeps/linux/ia64/bits/byteswap.h
+++ b/libc/sysdeps/linux/ia64/bits/byteswap.h
@@ -13,98 +13,37 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
-#if !defined _BYTESWAP_H && !defined _NETINET_IN_H
-# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
-#endif
-
-#ifndef _BITS_BYTESWAP_H
-#define _BITS_BYTESWAP_H 1
-
-/* Swap bytes in 16 bit value. */
-#define __bswap_constant_16(x) \
- ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))
+#ifndef _ASM_BITS_BYTESWAP_H
+#define _ASM_BITS_BYTESWAP_H 1
-#if defined __GNUC__ && __GNUC__ >= 2
-# define __bswap_16(x) \
+#define __bswap_non_constant_16(x) \
(__extension__ \
- ({ register unsigned short int __v, __x = (x); \
- if (__builtin_constant_p (x)) \
- __v = __bswap_constant_16 (__x); \
- else \
- __asm__ __volatile__ ("shl %0 = %1, 48 ;;" \
- "mux1 %0 = %0, @rev ;;" \
- : "=r" (__v) \
- : "r" ((unsigned short int) (__x))); \
+ ({ register unsigned short int __v; \
+ __asm__ __volatile__ ("shl %0 = %1, 48 ;;" \
+ "mux1 %0 = %0, @rev ;;" \
+ : "=r" (__v) \
+ : "r" ((unsigned short int) (x))); \
__v; }))
-#else
-/* This is better than nothing. */
-static __inline unsigned short int
-__bswap_16 (unsigned short int __bsx)
-{
- return __bswap_constant_16 (__bsx);
-}
-#endif
-
-/* Swap bytes in 32 bit value. */
-#define __bswap_constant_32(x) \
- ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
- (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
-
-#if defined __GNUC__ && __GNUC__ >= 2
-# define __bswap_32(x) \
+#define __bswap_non_constant_32(x) \
(__extension__ \
- ({ register unsigned int __v, __x = (x); \
- if (__builtin_constant_p (x)) \
- __v = __bswap_constant_32 (__x); \
- else \
- __asm__ __volatile__ ("shl %0 = %1, 32 ;;" \
- "mux1 %0 = %0, @rev ;;" \
- : "=r" (__v) \
- : "r" ((unsigned int) (__x))); \
+ ({ register unsigned int __v; \
+ __asm__ __volatile__ ("shl %0 = %1, 32 ;;" \
+ "mux1 %0 = %0, @rev ;;" \
+ : "=r" (__v) \
+ : "r" ((unsigned int) (x))); \
__v; }))
-#else
-static __inline unsigned int
-__bswap_32 (unsigned int __bsx)
-{
- return __bswap_constant_32 (__bsx);
-}
-#endif
-
-/* Swap bytes in 64 bit value. */
-#define __bswap_constant_64(x) \
- ((((x) & 0xff00000000000000ul) >> 56) \
- | (((x) & 0x00ff000000000000ul) >> 40) \
- | (((x) & 0x0000ff0000000000ul) >> 24) \
- | (((x) & 0x000000ff00000000ul) >> 8) \
- | (((x) & 0x00000000ff000000ul) << 8) \
- | (((x) & 0x0000000000ff0000ul) << 24) \
- | (((x) & 0x000000000000ff00ul) << 40) \
- | (((x) & 0x00000000000000fful) << 56))
-
-#if defined __GNUC__ && __GNUC__ >= 2
-# define __bswap_64(x) \
+#define __bswap_non_constant_64(x) \
(__extension__ \
- ({ register unsigned long int __v, __x = (x); \
- if (__builtin_constant_p (x)) \
- __v = __bswap_constant_64 (__x); \
- else \
- __asm__ __volatile__ ("mux1 %0 = %1, @rev ;;" \
- : "=r" (__v) \
- : "r" ((unsigned long int) (__x))); \
+ ({ register unsigned long int __v; \
+ __asm__ __volatile__ ("mux1 %0 = %1, @rev ;;" \
+ : "=r" (__v) \
+ : "r" ((unsigned long int) (x))); \
__v; }))
-
-#else
-static __inline unsigned long int
-__bswap_64 (unsigned long int __bsx)
-{
- return __bswap_constant_64 (__bsx);
-}
#endif
-#endif /* _BITS_BYTESWAP_H */
+#include <bits/byteswap-common.h>
diff --git a/libc/sysdeps/linux/ia64/bits/fcntl.h b/libc/sysdeps/linux/ia64/bits/fcntl.h
index 2a4b9ca35..bbc905c8c 100644
--- a/libc/sysdeps/linux/ia64/bits/fcntl.h
+++ b/libc/sysdeps/linux/ia64/bits/fcntl.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FCNTL_H
# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
@@ -49,9 +48,8 @@
# define O_DIRECTORY 0200000 /* must be a directory */
# define O_NOFOLLOW 0400000 /* don't follow links */
# define O_NOATIME 01000000 /* Do not set atime. */
-# if 0
# define O_CLOEXEC 02000000 /* Set close_on_exec. */
-# endif
+# define O_PATH 010000000 /* Resolve pathname but do not open file. */
#endif
#ifdef __USE_LARGEFILE64
@@ -98,6 +96,8 @@
# define F_NOTIFY 1026 /* Request notfications on a directory. */
# define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with
close-on-exit set on new fd. */
+# define F_SETPIPE_SZ 1031 /* Set pipe page size array. */
+# define F_GETPIPE_SZ 1032 /* Get pipe page size array. */
#endif
/* For F_[GET|SET]FD. */
@@ -161,7 +161,6 @@ struct flock64
};
#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
@@ -183,7 +182,7 @@ struct flock64
#endif
-#ifdef __USE_GNU
+#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
@@ -206,7 +205,7 @@ struct flock64
__BEGIN_DECLS
-#ifdef __USE_GNU
+#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)
diff --git a/libc/sysdeps/linux/ia64/bits/fenv.h b/libc/sysdeps/linux/ia64/bits/fenv.h
index 32515f079..3b4afde3a 100644
--- a/libc/sysdeps/linux/ia64/bits/fenv.h
+++ b/libc/sysdeps/linux/ia64/bits/fenv.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FENV_H
# error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
@@ -73,15 +72,15 @@ typedef unsigned long int fexcept_t;
typedef unsigned long int fenv_t;
/* If the default argument is used we use this value. */
-#define FE_DFL_ENV ((__const fenv_t *) 0xc009804c0270033fUL)
+#define FE_DFL_ENV ((const fenv_t *) 0xc009804c0270033fUL)
#ifdef __USE_GNU
/* Floating-point environment where only FE_UNNORMAL is masked since this
exception is not generally supported by glibc. */
-# define FE_NOMASK_ENV ((__const fenv_t *) 0xc009804c02700302UL)
+# define FE_NOMASK_ENV ((const fenv_t *) 0xc009804c02700302UL)
/* Floating-point environment with (processor-dependent) non-IEEE
floating point. In this case, turning on flush-to-zero mode for
s0, s2, and s3. */
-# define FE_NONIEEE_ENV ((__const fenv_t *) 0xc009a04d0270037fUL)
+# define FE_NONIEEE_ENV ((const fenv_t *) 0xc009a04d0270037fUL)
#endif
diff --git a/libc/sysdeps/linux/ia64/bits/huge_vall.h b/libc/sysdeps/linux/ia64/bits/huge_vall.h
new file mode 100644
index 000000000..a043f88b0
--- /dev/null
+++ b/libc/sysdeps/linux/ia64/bits/huge_vall.h
@@ -0,0 +1,41 @@
+/* `HUGE_VALL' constant for ia64 (where it is infinity).
+ Used by <stdlib.h> and <math.h> functions for overflow.
+ Copyright (C) 2000, 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.
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _MATH_H
+# error "Never use <bits/huge_vall.h> directly; include <math.h> instead."
+#endif
+
+#if __GNUC_PREREQ(3,3)
+# define HUGE_VALL (__builtin_huge_vall())
+#elif __GNUC_PREREQ(2,96)
+# define HUGE_VALL (__extension__ 0x1.0p32767L)
+#else
+
+# define __HUGE_VALL_bytes { 0,0,0,0,0,0,0, 0x80, 0xff, 0x7f, 0,0,0,0,0,0}
+
+# define __huge_vall_t union { unsigned char __c[16]; long double __ld; }
+# ifdef __GNUC__
+# define HUGE_VALL (__extension__ \
+ ((__huge_vall_t) { __c: __HUGE_VALL_bytes }).__ld)
+# else /* Not GCC. */
+static __huge_vall_t __huge_vall = { __HUGE_VALL_bytes };
+# define HUGE_VALL (__huge_vall.__ld)
+# endif /* GCC. */
+
+#endif /* GCC 2.95 */
diff --git a/libc/sysdeps/linux/ia64/bits/ipc.h b/libc/sysdeps/linux/ia64/bits/ipc.h
index 858c332f1..eb014d7b9 100644
--- a/libc/sysdeps/linux/ia64/bits/ipc.h
+++ b/libc/sysdeps/linux/ia64/bits/ipc.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_IPC_H
# error "Never use <bits/ipc.h> directly; include <sys/ipc.h> instead."
diff --git a/libc/sysdeps/linux/ia64/bits/kernel_stat.h b/libc/sysdeps/linux/ia64/bits/kernel_stat.h
index c67c92d16..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
@@ -23,39 +19,15 @@ struct kernel_stat {
unsigned int __pad0;
unsigned long st_rdev;
unsigned long st_size;
- unsigned long st_atime;
- unsigned long st_atime_nsec;
- unsigned long st_mtime;
- unsigned long st_mtime_nsec;
- unsigned long st_ctime;
- unsigned long st_ctime_nsec;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
unsigned long st_blksize;
long st_blocks;
unsigned long __unused[3];
};
-#define STAT_HAVE_NSEC 1
-
-struct __old_kernel_stat {
- unsigned int st_dev;
- unsigned int st_ino;
- unsigned int st_mode;
- unsigned int st_nlink;
- unsigned int st_uid;
- unsigned int st_gid;
- unsigned int st_rdev;
- unsigned int __pad1;
- unsigned long st_size;
- unsigned long st_atime;
- unsigned long st_mtime;
- unsigned long st_ctime;
- unsigned int st_blksize;
- int st_blocks;
- unsigned int __unused1;
- unsigned int __unused2;
-};
-
/* 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/kernel_types.h b/libc/sysdeps/linux/ia64/bits/kernel_types.h
index c8ef86d77..e31dc6534 100644
--- a/libc/sysdeps/linux/ia64/bits/kernel_types.h
+++ b/libc/sysdeps/linux/ia64/bits/kernel_types.h
@@ -52,5 +52,7 @@ typedef __kernel_gid_t __kernel_gid32_t;
typedef unsigned int __kernel_dev_t;
typedef unsigned int __kernel_old_dev_t;
+typedef long __kernel_long_t;
+typedef unsigned long __kernel_ulong_t;
#endif /* _ASM_IA64_POSIX_TYPES_H */
diff --git a/libc/sysdeps/linux/ia64/bits/local_lim.h b/libc/sysdeps/linux/ia64/bits/local_lim.h
new file mode 100644
index 000000000..ccba222e3
--- /dev/null
+++ b/libc/sysdeps/linux/ia64/bits/local_lim.h
@@ -0,0 +1,99 @@
+/* Minimum guaranteed maximum values for system limits. Linux/IA-64 version.
+ Copyright (C) 1993-1998,2000,2002-2004,2008 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ 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,
+ see <http://www.gnu.org/licenses/>. */
+
+/* The kernel header pollutes the namespace with the NR_OPEN symbol
+ and defines LINK_MAX although filesystems have different maxima. A
+ similar thing is true for OPEN_MAX: the limit can be changed at
+ runtime and therefore the macro must not be defined. Remove this
+ after including the header if necessary. */
+#ifndef NR_OPEN
+# define __undef_NR_OPEN
+#endif
+#ifndef LINK_MAX
+# define __undef_LINK_MAX
+#endif
+#ifndef OPEN_MAX
+# define __undef_OPEN_MAX
+#endif
+#ifndef ARG_MAX
+# define __undef_ARG_MAX
+#endif
+
+/* The kernel sources contain a file with all the needed information. */
+#include <linux/limits.h>
+
+/* Have to remove NR_OPEN? */
+#ifdef __undef_NR_OPEN
+# undef NR_OPEN
+# undef __undef_NR_OPEN
+#endif
+/* Have to remove LINK_MAX? */
+#ifdef __undef_LINK_MAX
+# undef LINK_MAX
+# undef __undef_LINK_MAX
+#endif
+/* Have to remove OPEN_MAX? */
+#ifdef __undef_OPEN_MAX
+# undef OPEN_MAX
+# undef __undef_OPEN_MAX
+#endif
+/* Have to remove ARG_MAX? */
+#ifdef __undef_ARG_MAX
+# undef ARG_MAX
+# undef __undef_ARG_MAX
+#endif
+
+/* The number of data keys per process. */
+#define _POSIX_THREAD_KEYS_MAX 128
+/* This is the value this implementation supports. */
+#define PTHREAD_KEYS_MAX 1024
+
+/* Controlling the iterations of destructors for thread-specific data. */
+#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
+/* Number of iterations this implementation does. */
+#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
+
+/* The number of threads per process. */
+#define _POSIX_THREAD_THREADS_MAX 64
+/* We have no predefined limit on the number of threads. */
+#undef PTHREAD_THREADS_MAX
+
+/* Maximum amount by which a process can descrease its asynchronous I/O
+ priority level. */
+#define AIO_PRIO_DELTA_MAX 20
+
+/* Minimum size for a thread. We are free to choose a reasonable value. */
+#define PTHREAD_STACK_MIN 196608
+
+/* Maximum number of timer expiration overruns. */
+#define DELAYTIMER_MAX 2147483647
+
+/* Maximum tty name length. */
+#define TTY_NAME_MAX 32
+
+/* Maximum login name length. This is arbitrary. */
+#define LOGIN_NAME_MAX 256
+
+/* Maximum host name length. */
+#define HOST_NAME_MAX 64
+
+/* Maximum message queue priority level. */
+#define MQ_PRIO_MAX 32768
+
+/* Maximum value the semaphore can have. */
+#define SEM_VALUE_MAX (2147483647)
diff --git a/libc/sysdeps/linux/ia64/bits/mathdef.h b/libc/sysdeps/linux/ia64/bits/mathdef.h
index 5da23cc8a..b1cc1e709 100644
--- a/libc/sysdeps/linux/ia64/bits/mathdef.h
+++ b/libc/sysdeps/linux/ia64/bits/mathdef.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#if !defined _MATH_H && !defined _COMPLEX_H
# error "Never use <bits/mathdef.h> directly; include <math.h> instead"
diff --git a/libc/sysdeps/linux/ia64/bits/mathinline.h b/libc/sysdeps/linux/ia64/bits/mathinline.h
index 9bb5f1a71..7db5a8ef4 100644
--- a/libc/sysdeps/linux/ia64/bits/mathinline.h
+++ b/libc/sysdeps/linux/ia64/bits/mathinline.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _MATH_H
# error "Never use <bits/mathinline.h> directly; include <math.h> instead."
@@ -24,7 +23,7 @@
#ifdef __cplusplus
# define __MATH_INLINE __inline
#else
-# define __MATH_INLINE extern __inline
+# define __MATH_INLINE __extern_inline
#endif
#if defined __USE_ISOC99 && defined __GNUC__ && __GNUC__ >= 2
diff --git a/libc/sysdeps/linux/ia64/bits/mman.h b/libc/sysdeps/linux/ia64/bits/mman.h
index a27a30fc0..a9d56ed07 100644
--- a/libc/sysdeps/linux/ia64/bits/mman.h
+++ b/libc/sysdeps/linux/ia64/bits/mman.h
@@ -1,104 +1,4 @@
-/* Definitions for POSIX memory map interface. Linux/ia64 version.
- Copyright (C) 1997,1998,2000,2003,2005,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 _SYS_MMAN_H
-# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
-#endif
-
-/* The following definitions basically come from the kernel headers.
- But the kernel header is not namespace clean. */
-
-
-/* Protections are chosen from these bits, OR'd together. The
- implementation does not necessarily support PROT_EXEC or PROT_WRITE
- without PROT_READ. The only guarantees are that no writing will be
- allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
-
-#define PROT_READ 0x1 /* Page can be read. */
-#define PROT_WRITE 0x2 /* Page can be written. */
-#define PROT_EXEC 0x4 /* Page can be executed. */
-#define PROT_NONE 0x0 /* Page can not be accessed. */
-#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of
- growsdown vma (mprotect only). */
-#define PROT_GROWSUP 0x02000000 /* Extend change to start of
- growsup vma (mprotect only). */
-
-/* Sharing types (must choose one and only one of these). */
-#define MAP_SHARED 0x01 /* Share changes. */
-#define MAP_PRIVATE 0x02 /* Changes are private. */
-#ifdef __USE_MISC
-# define MAP_TYPE 0x0f /* Mask for type of mapping. */
-#endif
-
-/* Other flags. */
-#define MAP_FIXED 0x10 /* Interpret addr exactly. */
-#ifdef __USE_MISC
-# define MAP_FILE 0
-# define MAP_ANONYMOUS 0x20 /* Don't use a file. */
-# define MAP_ANON MAP_ANONYMOUS
-#endif
-
-/* These are Linux-specific. */
#ifdef __USE_MISC
-# define MAP_GROWSDOWN 0x00100 /* Stack-like segment. */
# define MAP_GROWSUP 0x00200 /* Register stack-like segment */
-# define MAP_DENYWRITE 0x00800 /* ETXTBSY */
-# define MAP_EXECUTABLE 0x01000 /* Mark it as an executable. */
-# define MAP_LOCKED 0x02000 /* Lock the mapping. */
-# define MAP_NORESERVE 0x04000 /* Don't check for reservations. */
-# define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */
-# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */
-#endif
-
-/* Flags to `msync'. */
-#define MS_ASYNC 0x1 /* Sync memory asynchronously. */
-#define MS_INVALIDATE 0x2 /* Invalidate the caches. */
-#define MS_SYNC 0x4 /* Synchronous memory sync. */
-
-/* Flags for `mlockall'. */
-#define MCL_CURRENT 0x1 /* Lock all currently mapped pages. */
-#define MCL_FUTURE 0x2 /* Lock all additions to address
- space. */
-
-/* Flags for `mremap'. */
-#ifdef __USE_GNU
-# define MREMAP_MAYMOVE 1
-# define MREMAP_FIXED 2
-#endif
-
-/* Advice to `madvise'. */
-#ifdef __USE_BSD
-# define MADV_NORMAL 0 /* No further special treatment. */
-# define MADV_RANDOM 1 /* Expect random page references. */
-# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
-# define MADV_WILLNEED 3 /* Will need these pages. */
-# define MADV_DONTNEED 4 /* Don't need these pages. */
-# define MADV_REMOVE 9 /* Remove these pages and resources. */
-# define MADV_DONTFORK 10 /* Do not inherit across fork. */
-# define MADV_DOFORK 11 /* Do inherit across fork. */
-#endif
-
-/* The POSIX people had to invent similar names for the same things. */
-#ifdef __USE_XOPEN2K
-# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
-# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
-# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
-# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
-# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
#endif
+#include <bits/mman-common.h>
diff --git a/libc/sysdeps/linux/ia64/bits/msq.h b/libc/sysdeps/linux/ia64/bits/msq.h
index cd268eea3..2dea98627 100644
--- a/libc/sysdeps/linux/ia64/bits/msq.h
+++ b/libc/sysdeps/linux/ia64/bits/msq.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_MSG_H
#error "Never use <bits/msq.h> directly; include <sys/msg.h> instead."
diff --git a/libc/sysdeps/linux/ia64/bits/sem.h b/libc/sysdeps/linux/ia64/bits/sem.h
index 449f1ecc4..aa56e155d 100644
--- a/libc/sysdeps/linux/ia64/bits/sem.h
+++ b/libc/sysdeps/linux/ia64/bits/sem.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_SEM_H
# error "Never include <bits/sem.h> directly; use <sys/sem.h> instead."
diff --git a/libc/sysdeps/linux/ia64/bits/setjmp.h b/libc/sysdeps/linux/ia64/bits/setjmp.h
index 76625753d..4ebc5565d 100644
--- a/libc/sysdeps/linux/ia64/bits/setjmp.h
+++ b/libc/sysdeps/linux/ia64/bits/setjmp.h
@@ -1,5 +1,5 @@
/* Define the machine-dependent type `jmp_buf'. Linux/IA-64 version.
- Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
+ Copyright (C) 1999,2000,2003,2005,2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by David Mosberger-Tang <davidm@hpl.hp.com>.
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _BITS_SETJMP_H
#define _BITS_SETJMP_H 1
@@ -32,9 +31,4 @@
/* the __jmp_buf element type should be __float80 per ABI... */
typedef long __jmp_buf[_JBLEN] __attribute__ ((aligned (16))); /* guarantees 128-bit alignment! */
-/* Test if longjmp to JMPBUF would unwind the frame containing a local
- variable at ADDRESS. */
-#define _JMPBUF_UNWINDS(_jmpbuf, _address) \
- ((void *)(_address) < (void *)(((long *)_jmpbuf)[0]))
-
#endif /* bits/setjmp.h */
diff --git a/libc/sysdeps/linux/ia64/bits/shm.h b/libc/sysdeps/linux/ia64/bits/shm.h
index 7f38f2dd7..0d0c96e6f 100644
--- a/libc/sysdeps/linux/ia64/bits/shm.h
+++ b/libc/sysdeps/linux/ia64/bits/shm.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_SHM_H
# error "Never include <bits/shm.h> directly; use <sys/shm.h> instead."
diff --git a/libc/sysdeps/linux/ia64/bits/sigaction.h b/libc/sysdeps/linux/ia64/bits/sigaction.h
index 11599d520..edec85ba0 100644
--- a/libc/sysdeps/linux/ia64/bits/sigaction.h
+++ b/libc/sysdeps/linux/ia64/bits/sigaction.h
@@ -13,39 +13,29 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SIGNAL_H
# error "Never include <bits/sigaction.h> directly; use <signal.h> instead."
#endif
/* Structure describing the action to be taken when a signal arrives. */
-struct sigaction
- {
- /* Signal handler. */
+struct sigaction {
#ifdef __USE_POSIX199309
- union
- {
- /* Used if SA_SIGINFO is not set. */
- __sighandler_t sa_handler;
- /* Used if SA_SIGINFO is set. */
- void (*sa_sigaction) (int, siginfo_t *, void *);
- }
- __sigaction_handler;
-# define sa_handler __sigaction_handler.sa_handler
-# define sa_sigaction __sigaction_handler.sa_sigaction
+ union {
+ __sighandler_t sa_handler;
+ void (*sa_sigaction)(int, siginfo_t *, void *);
+ } __sigaction_handler;
+# define sa_handler __sigaction_handler.sa_handler
+# define sa_sigaction __sigaction_handler.sa_sigaction
#else
- __sighandler_t sa_handler;
+ __sighandler_t sa_handler;
#endif
-
- /* Special flags. */
- unsigned long int sa_flags;
-
- /* Additional set of signals to be blocked. */
- __sigset_t sa_mask;
- };
+ unsigned long sa_flags;
+ sigset_t sa_mask;
+ /* IA64 has no sa_restorer field. */
+};
/* Bits in `sa_flags'. */
#define SA_NOCLDSTOP 0x00000001 /* Don't send SIGCHLD when children stop. */
diff --git a/libc/sysdeps/linux/ia64/bits/sigcontext.h b/libc/sysdeps/linux/ia64/bits/sigcontext.h
index 72c60ec24..6c2b521cd 100644
--- a/libc/sysdeps/linux/ia64/bits/sigcontext.h
+++ b/libc/sysdeps/linux/ia64/bits/sigcontext.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H
# error "Never use <bits/sigcontext.h> directly; include <signal.h> instead."
@@ -25,6 +24,8 @@
#ifndef _BITS_SIGCONTEXT_H
#define _BITS_SIGCONTEXT_H 1
+#define __need_size_t
+#include <stddef.h>
#include <bits/sigstack.h>
struct ia64_fpreg
diff --git a/libc/sysdeps/linux/ia64/bits/siginfo.h b/libc/sysdeps/linux/ia64/bits/siginfo.h
index 66310c65b..df18b3606 100644
--- a/libc/sysdeps/linux/ia64/bits/siginfo.h
+++ b/libc/sysdeps/linux/ia64/bits/siginfo.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#if !defined _SIGNAL_H && !defined __need_siginfo_t \
&& !defined __need_sigevent_t
@@ -103,6 +102,14 @@ typedef struct siginfo
long int si_band; /* Band event for SIGPOLL. */
int si_fd;
} _sigpoll;
+
+ /* SIGSYS. */
+ struct
+ {
+ void *_call_addr; /* Calling user insn. */
+ int _syscall; /* Triggering system call number. */
+ unsigned int _arch; /* AUDIT_ARCH_* of syscall. */
+ } _sigsys;
} _sifields;
} siginfo_t;
@@ -121,6 +128,9 @@ typedef struct siginfo
# define si_addr _sifields._sigfault.si_addr
# define si_band _sifields._sigpoll.si_band
# define si_fd _sifields._sigpoll.si_fd
+# define si_call_addr _sifields._sigsys._call_addr
+# define si_syscall _sifields._sigsys._syscall
+# define si_arch _sifields._sigsys._arch
# ifdef __USE_GNU
# define si_imm _sifields._sigfault._si_imm
@@ -298,7 +308,11 @@ enum
/* Structure to transport application-defined values with signals. */
# define __SIGEV_MAX_SIZE 64
-# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 4)
+# if __WORDSIZE == 64
+# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 4)
+# else
+# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 3)
+# endif
typedef struct sigevent
{
@@ -310,6 +324,10 @@ typedef struct sigevent
{
int _pad[__SIGEV_PAD_SIZE];
+ /* When SIGEV_SIGNAL and SIGEV_THREAD_ID set, LWP ID of the
+ thread to receive the signal. */
+ __pid_t _tid;
+
struct
{
void (*_function) (sigval_t); /* Function to start. */
diff --git a/libc/sysdeps/linux/ia64/bits/sigstack.h b/libc/sysdeps/linux/ia64/bits/sigstack.h
index c9c9d2fed..4e2021b75 100644
--- a/libc/sysdeps/linux/ia64/bits/sigstack.h
+++ b/libc/sysdeps/linux/ia64/bits/sigstack.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SIGNAL_H
# error "Never include this file directly. Use <signal.h> instead"
@@ -24,12 +23,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/ia64/bits/stackinfo.h b/libc/sysdeps/linux/ia64/bits/stackinfo.h
index b7dc5d91d..67cdec057 100644
--- a/libc/sysdeps/linux/ia64/bits/stackinfo.h
+++ b/libc/sysdeps/linux/ia64/bits/stackinfo.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* This file contains a bit of information about the stack allocation
of the processor. */
diff --git a/libc/sysdeps/linux/ia64/bits/stat.h b/libc/sysdeps/linux/ia64/bits/stat.h
index a5a121b28..e868b0950 100644
--- a/libc/sysdeps/linux/ia64/bits/stat.h
+++ b/libc/sysdeps/linux/ia64/bits/stat.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2000, 2001, 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
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_STAT_H
# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
@@ -39,7 +38,7 @@ struct stat
int pad0;
__dev_t st_rdev; /* Device number, if device. */
__off_t st_size; /* Size of file, in bytes. */
-#if 0 /*def __USE_MISC*/
+#ifdef __USE_MISC
/* Nanosecond resolution timestamps are stored in a format
equivalent to 'struct timespec'. This is the type used
whenever possible but the Unix namespace rules do not allow the
@@ -78,7 +77,7 @@ struct stat64
int pad0;
__dev_t st_rdev; /* Device number, if device. */
__off_t st_size; /* Size of file, in bytes. */
-#if 0 /*def __USE_MISC*/
+#ifdef __USE_MISC
/* Nanosecond resolution timestamps are stored in a format
equivalent to 'struct timespec'. This is the type used
whenever possible but the Unix namespace rules do not allow the
@@ -138,3 +137,8 @@ struct stat64
#define __S_IREAD 0400 /* Read by owner. */
#define __S_IWRITE 0200 /* Write by owner. */
#define __S_IEXEC 0100 /* Execute by owner. */
+
+#ifdef __USE_ATFILE
+# define UTIME_NOW ((1l << 30) - 1l)
+# define UTIME_OMIT ((1l << 30) - 2l)
+#endif
diff --git a/libc/sysdeps/linux/ia64/bits/syscalls.h b/libc/sysdeps/linux/ia64/bits/syscalls.h
index 0c3d6ca3a..47ab2b8ca 100644
--- a/libc/sysdeps/linux/ia64/bits/syscalls.h
+++ b/libc/sysdeps/linux/ia64/bits/syscalls.h
@@ -15,9 +15,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _BITS_SYSCALLS_H
#define _BITS_SYSCALLS_H
@@ -30,30 +29,63 @@
#include <errno.h>
-#define SYS_ify(syscall_name) (__NR_##syscall_name)
-
#undef IA64_USE_NEW_STUB
-/* taken from asm-ia64/break.h */
#define __IA64_BREAK_SYSCALL 0x100000
-#define ___IA64_BREAK_SYSCALL "0x100000"
-
-#define _DO_SYSCALL(name, nr, args...) \
- LOAD_ARGS_##nr (args) \
- register long _r8 __asm__ ("r8"); \
- register long _r10 __asm__ ("r10"); \
- register long _r15 __asm__ ("r15") = SYS_ify(name); \
- long _retval; \
- LOAD_REGS_##nr \
- __asm__ __volatile__ ("break " ___IA64_BREAK_SYSCALL ";;\n\t" \
- : "=r" (_r8), "=r" (_r10), "=r" (_r15) ASM_OUTARGS_##nr \
- : "2" (_r15) ASM_ARGS_##nr \
- : "memory" ASM_CLOBBERS_##nr); \
- _retval = _r8; \
- if (_r10 == -1) { \
- __set_errno (_retval); \
- _retval = -1; \
- }
+
+/* mostly taken from glibc sysdeps/unix/sysv/linux/ia64/sysdep.h */
+#define BREAK_INSN_1(num) "break " #num ";;\n\t"
+#define BREAK_INSN(num) BREAK_INSN_1(num)
+
+/* On IA-64 we have stacked registers for passing arguments. The
+ "out" registers end up being the called function's "in"
+ registers.
+
+ Also, since we have plenty of registers we have two return values
+ from a syscall. r10 is set to -1 on error, whilst r8 contains the
+ (non-negative) errno on error or the return value on success.
+ */
+
+# define DO_INLINE_SYSCALL_NCS(name, nr, args...) \
+ LOAD_ARGS_##nr (args) \
+ register long _r8 __asm__ ("r8"); \
+ register long _r10 __asm__ ("r10"); \
+ register long _r15 __asm__ ("r15") = name; \
+ long _retval; \
+ LOAD_REGS_##nr \
+ __asm__ __volatile__ (BREAK_INSN (__IA64_BREAK_SYSCALL) \
+ : "=r" (_r8), "=r" (_r10), "=r" (_r15) \
+ ASM_OUTARGS_##nr \
+ : "2" (_r15) ASM_ARGS_##nr \
+ : "memory" ASM_CLOBBERS_##nr); \
+ _retval = _r8;
+
+#define INLINE_SYSCALL_NCS(name, nr, args...) \
+(__extension__ \
+ ({ \
+ DO_INLINE_SYSCALL_NCS (name, nr, args) \
+ if (unlikely (_r10 == -1)) \
+ { \
+ __set_errno (_retval); \
+ _retval = -1; \
+ } \
+ _retval; \
+ }) \
+)
+
+#define INTERNAL_SYSCALL_DECL(err) long int err
+
+#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+(__extension__ \
+ ({ \
+ DO_INLINE_SYSCALL_NCS (name, nr, args) \
+ err = _r10; \
+ _retval; \
+ }) \
+)
+#define INTERNAL_SYSCALL_ERROR_P(val, err) (err == -1)
+
+#define INTERNAL_SYSCALL_ERRNO(val, err) (val)
#define LOAD_ARGS_0()
#define LOAD_REGS_0
@@ -102,15 +134,6 @@
#define ASM_OUTARGS_5 ASM_OUTARGS_4, "=r" (_out4)
#define ASM_OUTARGS_6 ASM_OUTARGS_5, "=r" (_out5)
-#ifdef IA64_USE_NEW_STUB
-#define ASM_ARGS_0
-#define ASM_ARGS_1 ASM_ARGS_0, "4" (_out0)
-#define ASM_ARGS_2 ASM_ARGS_1, "5" (_out1)
-#define ASM_ARGS_3 ASM_ARGS_2, "6" (_out2)
-#define ASM_ARGS_4 ASM_ARGS_3, "7" (_out3)
-#define ASM_ARGS_5 ASM_ARGS_4, "8" (_out4)
-#define ASM_ARGS_6 ASM_ARGS_5, "9" (_out5)
-#else
#define ASM_ARGS_0
#define ASM_ARGS_1 ASM_ARGS_0, "3" (_out0)
#define ASM_ARGS_2 ASM_ARGS_1, "4" (_out1)
@@ -118,7 +141,6 @@
#define ASM_ARGS_4 ASM_ARGS_3, "6" (_out3)
#define ASM_ARGS_5 ASM_ARGS_4, "7" (_out4)
#define ASM_ARGS_6 ASM_ARGS_5, "8" (_out5)
-#endif
#define ASM_CLOBBERS_0 ASM_CLOBBERS_1, "out0"
#define ASM_CLOBBERS_1 ASM_CLOBBERS_2, "out1"
@@ -126,6 +148,7 @@
#define ASM_CLOBBERS_3 ASM_CLOBBERS_4, "out3"
#define ASM_CLOBBERS_4 ASM_CLOBBERS_5, "out4"
#define ASM_CLOBBERS_5 ASM_CLOBBERS_6, "out5"
+#define ASM_CLOBBERS_6 ASM_CLOBBERS_6_COMMON , "b7"
#define ASM_CLOBBERS_6_COMMON , "out6", "out7", \
/* Non-stacked integer registers, minus r8, r10, r15. */ \
"r2", "r3", "r9", "r11", "r12", "r13", "r14", "r16", "r17", "r18", \
@@ -138,55 +161,5 @@
/* Branch registers. */ \
"b6"
-#ifdef IA64_USE_NEW_STUB
-# define ASM_CLOBBERS_6 ASM_CLOBBERS_6_COMMON
-#else
-# define ASM_CLOBBERS_6 ASM_CLOBBERS_6_COMMON , "b7"
-#endif
-
-
-
-#define _syscall0(type,name) \
-type name(void) \
-{ \
- _DO_SYSCALL(name, 0); return (type) _retval; \
-}
-
-#define _syscall1(type,name,type1,arg1) \
-type name(type1 arg1) \
-{ \
- _DO_SYSCALL(name, 1, arg1); return (type) _retval; \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name(type1 arg1, type2 arg2) \
-{ \
- _DO_SYSCALL(name, 2, arg1, arg2); return (type) _retval; \
-}
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name(type1 arg1, type2 arg2, type3 arg3) \
-{ \
- _DO_SYSCALL(name, 3, arg1, arg2, arg3); return (type) _retval; \
-}
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
-{ \
- _DO_SYSCALL(name, 4, arg1, arg2, arg3, arg4); return (type) _retval; \
-}
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
-{ \
- _DO_SYSCALL(name, 5, arg1, arg2, arg3, arg4, arg5); return (type) _retval; \
-}
-
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
-{ \
- _DO_SYSCALL(name, 6, arg1, arg2, arg3, arg4, arg5, arg6); return (type) _retval; \
-}
-
#endif /* __ASSEMBLER__ */
#endif /* _BITS_SYSCALLS_H */
diff --git a/libc/sysdeps/linux/ia64/bits/uClibc_arch_features.h b/libc/sysdeps/linux/ia64/bits/uClibc_arch_features.h
index 953279e73..25c983206 100644
--- a/libc/sysdeps/linux/ia64/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/ia64/bits/uClibc_arch_features.h
@@ -11,28 +11,31 @@
/* 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 align 64bit values in register pairs ? (32bit arches only) */
+#undef __UCLIBC_SYSCALL_ALIGN_64BIT__
/* 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 */
+#undef __UCLIBC_ASM_LINE_SEP__
+
#endif /* _BITS_UCLIBC_ARCH_FEATURES_H */
diff --git a/libc/sysdeps/linux/ia64/bits/wordsize.h b/libc/sysdeps/linux/ia64/bits/wordsize.h
index dd698fa97..afb2131de 100644
--- a/libc/sysdeps/linux/ia64/bits/wordsize.h
+++ b/libc/sysdeps/linux/ia64/bits/wordsize.h
@@ -12,8 +12,7 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#define __WORDSIZE 64
diff --git a/libc/sysdeps/linux/ia64/brk.S b/libc/sysdeps/linux/ia64/brk.S
index e9974d515..3c5f922e4 100644
--- a/libc/sysdeps/linux/ia64/brk.S
+++ b/libc/sysdeps/linux/ia64/brk.S
@@ -15,9 +15,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include "sysdep.h"
diff --git a/libc/sysdeps/linux/ia64/clone2.S b/libc/sysdeps/linux/ia64/clone2.S
index 7f067dff8..c077f722a 100644
--- a/libc/sysdeps/linux/ia64/clone2.S
+++ b/libc/sysdeps/linux/ia64/clone2.S
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include "sysdep.h"
diff --git a/libc/sysdeps/linux/ia64/crt1.S b/libc/sysdeps/linux/ia64/crt1.S
index 774e84ff4..c88193c51 100644
--- a/libc/sysdeps/linux/ia64/crt1.S
+++ b/libc/sysdeps/linux/ia64/crt1.S
@@ -30,9 +30,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#define __ASSEMBLY__
#include "sysdep.h"
diff --git a/libc/sysdeps/linux/ia64/fork.S b/libc/sysdeps/linux/ia64/fork.S
index c657453f2..d09d925d8 100644
--- a/libc/sysdeps/linux/ia64/fork.S
+++ b/libc/sysdeps/linux/ia64/fork.S
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include "sysdep.h"
@@ -24,7 +23,10 @@
/* pid_t fork(void); */
/* Implemented as a clone system call with parameters SIGCHLD and 0 */
-ENTRY(__libc_fork)
+#ifdef __UCLIBC_HAS_THREADS__
+.weak fork
+#endif
+ENTRY(fork)
alloc r2=ar.pfs,0,0,2,0
mov out0=SIGCHLD /* Return SIGCHLD when child finishes */
/* no other clone flags; nothing shared */
@@ -34,9 +36,8 @@ ENTRY(__libc_fork)
cmp.eq p6,p0=-1,r10
(p6) br.cond.spnt.few __syscall_error
ret
-PSEUDO_END(__libc_fork)
-
-weak_alias (__libc_fork, __fork)
-libc_hidden_def (__fork)
-weak_alias (__libc_fork, fork)
-libc_hidden_weak (fork)
+PSEUDO_END(fork)
+#ifdef __UCLIBC_HAS_THREADS__
+strong_alias(fork,__libc_fork)
+#endif
+libc_hidden_def(fork)
diff --git a/libc/sysdeps/linux/ia64/jmpbuf-unwind.h b/libc/sysdeps/linux/ia64/jmpbuf-unwind.h
new file mode 100644
index 000000000..91e2df8e7
--- /dev/null
+++ b/libc/sysdeps/linux/ia64/jmpbuf-unwind.h
@@ -0,0 +1,11 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+#include <setjmp.h>
+
+/* Test if longjmp to JMPBUF would unwind the frame containing a local
+ variable at ADDRESS. */
+#define _JMPBUF_UNWINDS(_jmpbuf, _address) \
+ ((void *)(_address) < (void *)(((long *)_jmpbuf)[0]))
diff --git a/libc/sysdeps/linux/ia64/pipe.S b/libc/sysdeps/linux/ia64/pipe.S
index 2bfa8a71f..d2fc2d4ee 100644
--- a/libc/sysdeps/linux/ia64/pipe.S
+++ b/libc/sysdeps/linux/ia64/pipe.S
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* __pipe is a special syscall since it returns two values. */
diff --git a/libc/sysdeps/linux/ia64/setjmp.S b/libc/sysdeps/linux/ia64/setjmp.S
index 11dc0e62e..05f112ea0 100644
--- a/libc/sysdeps/linux/ia64/setjmp.S
+++ b/libc/sysdeps/linux/ia64/setjmp.S
@@ -13,9 +13,8 @@
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.
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>.
The layout of the jmp_buf is as follows. This is subject to change
and user-code should never depend on the particular layout of
@@ -95,15 +94,15 @@ ENTRY(__sigsetjmp)
mov r2=in0
add r3=8,in0
;;
-.mem.offset 8,0; st8.spill.nta [r2]=sp,16 // r12 (sp)
-.mem.offset 0,0; st8.spill.nta [r3]=gp,16 // r1 (gp)
+.mem.offset 8,0; st8.spill.nta [r2]=sp,16 /* r12 (sp) */
+.mem.offset 0,0; st8.spill.nta [r3]=gp,16 /* r1 (gp) */
;;
- st8.nta [r2]=loc2,16 // save caller's unat
- st8.nta [r3]=r17,16 // save fpsr
+ st8.nta [r2]=loc2,16 /* save caller's unat */
+ st8.nta [r3]=r17,16 /* save fpsr */
add r8=0xa0,in0
;;
-.mem.offset 8,0; st8.spill.nta [r2]=r4,16 // r4
-.mem.offset 0,0; st8.spill.nta [r3]=r5,16 // r5
+.mem.offset 8,0; st8.spill.nta [r2]=r4,16 /* r4 */
+.mem.offset 0,0; st8.spill.nta [r3]=r5,16 /* r5 */
add r9=0xb0,in0
;;
stf.spill.nta [r8]=f2,32
@@ -145,39 +144,39 @@ ENTRY(__sigsetjmp)
stf.spill.nta [r8]=f30
stf.spill.nta [r9]=f31
-.mem.offset 8,0; st8.spill.nta [r2]=r6,16 // r6
-.mem.offset 0,0; st8.spill.nta [r3]=r7,16 // r7
+.mem.offset 8,0; st8.spill.nta [r2]=r6,16 /* r6 */
+.mem.offset 0,0; st8.spill.nta [r3]=r7,16 /* r7 */
;;
mov r23=ar.bsp
mov r25=ar.unat
mov out0=in0
- st8.nta [r2]=loc0,16 // b0
- st8.nta [r3]=r17,16 // b1
+ st8.nta [r2]=loc0,16 /* b0 */
+ st8.nta [r3]=r17,16 /* b1 */
mov out1=in1
;;
- st8.nta [r2]=r18,16 // b2
- st8.nta [r3]=r19,16 // b3
+ st8.nta [r2]=r18,16 /* b2 */
+ st8.nta [r3]=r19,16 /* b3 */
;;
- st8.nta [r2]=r20,16 // b4
- st8.nta [r3]=r21,16 // b5
+ st8.nta [r2]=r20,16 /* b4 */
+ st8.nta [r3]=r21,16 /* b5 */
;;
- st8.nta [r2]=loc1,16 // ar.pfs
- st8.nta [r3]=r22,16 // ar.lc
+ st8.nta [r2]=loc1,16 /* ar.pfs */
+ st8.nta [r3]=r22,16 /* ar.lc */
;;
- st8.nta [r2]=r24,16 // pr
- st8.nta [r3]=r23,16 // ar.bsp
+ st8.nta [r2]=r24,16 /* pr */
+ st8.nta [r3]=r23,16 /* ar.bsp */
;;
- st8.nta [r2]=r25 // ar.unat
- st8.nta [r3]=in0 // &__jmp_buf
+ st8.nta [r2]=r25 /* ar.unat */
+ st8.nta [r3]=in0 /* &__jmp_buf */
#if defined NOT_IN_libc && defined IS_IN_rtld
/* In ld.so we never save the signal mask. */
;;
#else
br.call.dpnt.few rp=__sigjmp_save
#endif
-.ret0: // force a new bundle ::q
- mov.m ar.unat=loc2 // restore caller's unat
+.ret0: /* force a new bundle ::q */
+ mov.m ar.unat=loc2 /* restore caller's unat */
mov rp=loc0
mov ar.pfs=loc1
mov r8=0
diff --git a/libc/sysdeps/linux/ia64/sys/io.h b/libc/sysdeps/linux/ia64/sys/io.h
index 14736ff1c..f07e945ed 100644
--- a/libc/sysdeps/linux/ia64/sys/io.h
+++ b/libc/sysdeps/linux/ia64/sys/io.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_IO_H
#define _SYS_IO_H 1
@@ -24,6 +23,7 @@
__BEGIN_DECLS
+#if defined __UCLIBC_LINUX_SPECIFIC__
/* If TURN_ON is TRUE, request for permission to do direct i/o on the
port numbers in the range [FROM,FROM+NUM-1]. Otherwise, turn I/O
permission off for that range. This call requires root privileges.
@@ -38,6 +38,7 @@ extern int ioperm (unsigned long int __from, unsigned long int __num,
access any I/O port is granted. This call requires root
privileges. */
extern int iopl (int __level);
+#endif /* __UCLIBC_LINUX_SPECIFIC__ */
extern unsigned int _inb (unsigned long int __port);
extern unsigned int _inb (unsigned long int __port);
diff --git a/libc/sysdeps/linux/ia64/sys/procfs.h b/libc/sysdeps/linux/ia64/sys/procfs.h
index b5196b997..51c3f7ecb 100644
--- a/libc/sysdeps/linux/ia64/sys/procfs.h
+++ b/libc/sysdeps/linux/ia64/sys/procfs.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_PROCFS_H
#define _SYS_PROCFS_H 1
diff --git a/libc/sysdeps/linux/ia64/sys/ptrace.h b/libc/sysdeps/linux/ia64/sys/ptrace.h
index 986c4b2d3..09944880b 100644
--- a/libc/sysdeps/linux/ia64/sys/ptrace.h
+++ b/libc/sysdeps/linux/ia64/sys/ptrace.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_PTRACE_H
#define _SYS_PTRACE_H 1
diff --git a/libc/sysdeps/linux/ia64/sys/ucontext.h b/libc/sysdeps/linux/ia64/sys/ucontext.h
index 17dc85f99..ef5656717 100644
--- a/libc/sysdeps/linux/ia64/sys/ucontext.h
+++ b/libc/sysdeps/linux/ia64/sys/ucontext.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_UCONTEXT_H
#define _SYS_UCONTEXT_H 1
@@ -32,7 +31,7 @@
typedef struct sigcontext mcontext_t;
-#if defined __cplusplus && __GNUC_PREREQ (3, 5)
+#if __GNUC_PREREQ (3, 5)
# define _SC_GR0_OFFSET \
__builtin_offsetof (struct sigcontext, sc_gr[0])
#elif defined __GNUC__
diff --git a/libc/sysdeps/linux/ia64/sys/user.h b/libc/sysdeps/linux/ia64/sys/user.h
index 039218761..b998f63f0 100644
--- a/libc/sysdeps/linux/ia64/sys/user.h
+++ b/libc/sysdeps/linux/ia64/sys/user.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_USER_H
#define _SYS_USER_H 1
diff --git a/libc/sysdeps/linux/ia64/syscall.S b/libc/sysdeps/linux/ia64/syscall.S
index e4ac834c6..3a5daeeb5 100644
--- a/libc/sysdeps/linux/ia64/syscall.S
+++ b/libc/sysdeps/linux/ia64/syscall.S
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include "sysdep.h"
diff --git a/libc/sysdeps/linux/ia64/sysdep.h b/libc/sysdeps/linux/ia64/sysdep.h
index d10020ac1..3e7e4674a 100644
--- a/libc/sysdeps/linux/ia64/sysdep.h
+++ b/libc/sysdeps/linux/ia64/sysdep.h
@@ -14,13 +14,13 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _LINUX_IA64_SYSDEP_H
#define _LINUX_IA64_SYSDEP_H 1
+#include <common/sysdep.h>
#include <features.h>
#include <asm/unistd.h>
@@ -49,6 +49,15 @@
C_LABEL(name) \
CALL_MCOUNT
+#define HIDDEN_ENTRY(name) \
+ .text; \
+ .align 32; \
+ .proc C_SYMBOL_NAME(name); \
+ .global C_SYMBOL_NAME(name); \
+ .hidden C_SYMBOL_NAME(name); \
+ C_LABEL(name) \
+ CALL_MCOUNT
+
#define LEAF(name) \
.text; \
.align 32; \
@@ -161,7 +170,6 @@
#define ret br.ret.sptk.few b0
#define ret_NOERRNO ret
-#define ret_ERRVAL ret
#endif /* not __ASSEMBLER__ */
diff --git a/libc/sysdeps/linux/ia64/vfork.S b/libc/sysdeps/linux/ia64/vfork.S
index f233b05e2..40f9f1933 100644
--- a/libc/sysdeps/linux/ia64/vfork.S
+++ b/libc/sysdeps/linux/ia64/vfork.S
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include "sysdep.h"
@@ -29,7 +28,7 @@
/* pid_t vfork(void); */
/* Implemented as __clone_syscall(CLONE_VFORK | CLONE_VM | SIGCHLD, 0) */
-ENTRY(__vfork)
+HIDDEN_ENTRY(__vfork)
alloc r2=ar.pfs,0,0,2,0
mov out0=CLONE_VM+CLONE_VFORK+SIGCHLD
mov out1=0 /* Standard sp value. */
@@ -41,4 +40,4 @@ ENTRY(__vfork)
PSEUDO_END(__vfork)
weak_alias(__vfork,vfork)
-libc_hidden_weak(vfork)
+libc_hidden_def(vfork)
diff --git a/libc/sysdeps/linux/nios/Makefile b/libc/sysdeps/linux/lm32/Makefile
index 3970f6263..633c91f3e 100644
--- a/libc/sysdeps/linux/nios/Makefile
+++ b/libc/sysdeps/linux/lm32/Makefile
@@ -1,6 +1,6 @@
# Makefile for uClibc
#
-# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
diff --git a/libc/sysdeps/linux/lm32/Makefile.arch b/libc/sysdeps/linux/lm32/Makefile.arch
new file mode 100644
index 000000000..1442a40b4
--- /dev/null
+++ b/libc/sysdeps/linux/lm32/Makefile.arch
@@ -0,0 +1,9 @@
+# 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-y :=
+SSRC-y := clone.S setjmp.S __longjmp.S vfork.S
diff --git a/libc/sysdeps/linux/lm32/__longjmp.S b/libc/sysdeps/linux/lm32/__longjmp.S
new file mode 100644
index 000000000..cbb55f01f
--- /dev/null
+++ b/libc/sysdeps/linux/lm32/__longjmp.S
@@ -0,0 +1,40 @@
+#define _SETJMP_H
+#define _ASM
+#include <bits/setjmp.h>
+
+#include <libc-symbols.h>
+
+.text
+.global C_SYMBOL_NAME(__longjmp)
+.type C_SYMBOL_NAME(__longjmp),@function
+.align 4
+
+C_SYMBOL_NAME(__longjmp):
+ /* load registers relative from r5 (arg0) */
+ lw r11, (r1+0)
+ lw r12, (r1+4)
+ lw r13, (r1+8)
+ lw r14, (r1+12)
+ lw r15, (r1+16)
+ lw r16, (r1+20)
+ lw r17, (r1+24)
+ lw r18, (r1+28)
+ lw r19, (r1+32)
+ lw r20, (r1+36)
+ lw r21, (r1+40)
+ lw r22, (r1+44)
+ lw r23, (r1+48)
+ lw r24, (r1+52)
+ lw r25, (r1+56)
+ lw gp, (r1+60)
+ lw fp, (r1+64)
+ lw sp, (r1+68)
+ lw ra, (r1+72)
+
+ mv r1, r2 /* copy val */
+ bne r1, r0, 1f
+ mvi r1, 1 /* val was zero, set it to 1 */
+1:
+ ret
+
+libc_hidden_def(__longjmp)
diff --git a/libc/sysdeps/linux/i960/bits/endian.h b/libc/sysdeps/linux/lm32/bits/endian.h
index e2b13161c..1acee1892 100644
--- a/libc/sysdeps/linux/i960/bits/endian.h
+++ b/libc/sysdeps/linux/lm32/bits/endian.h
@@ -10,6 +10,4 @@
# error "Never use <bits/endian.h> directly; include <endian.h> instead."
#endif
-#define __BYTE_ORDER __LITTLE_ENDIAN
-
-
+#define __BYTE_ORDER __BIG_ENDIAN
diff --git a/libc/sysdeps/linux/v850/bits/fcntl.h b/libc/sysdeps/linux/lm32/bits/fcntl.h
index 87d193923..5f40957f8 100644
--- a/libc/sysdeps/linux/v850/bits/fcntl.h
+++ b/libc/sysdeps/linux/lm32/bits/fcntl.h
@@ -23,6 +23,9 @@
#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 */
@@ -42,10 +45,12 @@
#define O_ASYNC 020000
#ifdef __USE_GNU
-# define O_DIRECTORY 040000 /* Must be a directory. */
-# define O_NOFOLLOW 0100000 /* Do not follow links. */
-# define O_DIRECT 0200000 /* Direct disk access. */
-# define O_STREAMING 04000000/* streaming access */
+# define O_DIRECTORY 0200000 /* Must be a directory. */
+# define O_NOFOLLOW 0400000 /* Do not follow links. */
+# define O_DIRECT 040000 /* Direct disk access. */
+# define O_NOATIME 01000000 /* Do not set atime. */
+# define O_CLOEXEC 02000000 /* set close_on_exec */
+# define O_PATH 010000000 /* Resolve pathname but do not open file. */
#endif
/* For now Linux has synchronisity options for data and read operations.
@@ -57,7 +62,7 @@
#endif
#ifdef __USE_LARGEFILE64
-# define O_LARGEFILE 0400000
+# define O_LARGEFILE 0100000
#endif
/* Values for the second argument to `fcntl'. */
@@ -95,6 +100,8 @@
# define F_NOTIFY 1026 /* Request notfications on a directory. */
# define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with
close-on-exit set on new fd. */
+# define F_SETPIPE_SZ 1031 /* Set of pipe page size array */
+# define F_GETPIPE_SZ 1032 /* Get of pipe page size array */
#endif
/* For F_[GET|SET]FL. */
@@ -182,7 +189,7 @@ struct flock64
#endif
-#ifdef __USE_GNU
+#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
@@ -205,7 +212,7 @@ struct flock64
__BEGIN_DECLS
-#ifdef __USE_GNU
+#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)
diff --git a/libc/sysdeps/linux/lm32/bits/kernel_stat.h b/libc/sysdeps/linux/lm32/bits/kernel_stat.h
new file mode 100644
index 000000000..c998b56c7
--- /dev/null
+++ b/libc/sysdeps/linux/lm32/bits/kernel_stat.h
@@ -0,0 +1,50 @@
+#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. */
+ 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; /* Time of last access. */
+ struct timespec st_mtim; /* Time of last modification. */
+ struct timespec st_ctim; /* Time of last status change. */
+ 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; /* Time of last access. */
+ struct timespec st_mtim; /* Time of last modification. */
+ struct timespec st_ctim; /* Time of last status change. */
+ unsigned int __unused4;
+ unsigned int __unused5;
+};
+
+#endif /* _BITS_STAT_STRUCT_H */
diff --git a/libc/sysdeps/linux/lm32/bits/kernel_types.h b/libc/sysdeps/linux/lm32/bits/kernel_types.h
new file mode 100644
index 000000000..fc2a13ffc
--- /dev/null
+++ b/libc/sysdeps/linux/lm32/bits/kernel_types.h
@@ -0,0 +1,39 @@
+#ifndef __ASM_GENERIC_POSIX_TYPES_H
+#define __ASM_GENERIC_POSIX_TYPES_H
+
+typedef unsigned long __kernel_ino_t;
+typedef unsigned int __kernel_mode_t;
+typedef unsigned long __kernel_nlink_t;
+typedef long __kernel_off_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 unsigned int __kernel_size_t;
+typedef int __kernel_ssize_t;
+typedef int __kernel_ptrdiff_t;
+typedef long __kernel_time_t;
+typedef long __kernel_suseconds_t;
+typedef long __kernel_clock_t;
+typedef int __kernel_timer_t;
+typedef int __kernel_clockid_t;
+typedef int __kernel_daddr_t;
+typedef char * __kernel_caddr_t;
+typedef unsigned short __kernel_uid16_t;
+typedef unsigned short __kernel_gid16_t;
+typedef __kernel_uid_t __kernel_uid32_t;
+typedef __kernel_gid_t __kernel_gid32_t;
+
+typedef __kernel_uid_t __kernel_old_uid_t;
+typedef __kernel_gid_t __kernel_old_gid_t;
+typedef unsigned int __kernel_old_dev_t;
+
+typedef long long __kernel_loff_t;
+typedef long __kernel_long_t;
+typedef unsigned long __kernel_ulong_t;
+
+typedef struct {
+ int val[2];
+} __kernel_fsid_t;
+
+#endif /* __ASM_GENERIC_POSIX_TYPES_H */
diff --git a/libc/sysdeps/linux/lm32/bits/setjmp.h b/libc/sysdeps/linux/lm32/bits/setjmp.h
new file mode 100644
index 000000000..6798083bd
--- /dev/null
+++ b/libc/sysdeps/linux/lm32/bits/setjmp.h
@@ -0,0 +1,24 @@
+#ifndef _BITS_SETJMP_H
+#define _BITS_SETJMP_H 1
+
+#if !defined _SETJMP_H && !defined _PTHREAD_H
+# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
+#endif
+
+#ifndef _ASM
+typedef struct
+ {
+ int __regs[15]; /* callee-saved registers r11-r25 */
+ void *__gp; /* global pointer */
+ void *__fp; /* frame pointer */
+ void *__sp; /* stack pointer */
+ void *__ra; /* return address */
+ } __jmp_buf[1];
+#endif
+
+/* Test if longjmp to JMPBUF would unwind the frame
+ containing a local variable at ADDRESS. */
+#define _JMPBUF_UNWINDS(jmpbuf, address) \
+ ((void *) (address) < (void *) (jmpbuf)[0].__sp)
+
+#endif
diff --git a/libc/sysdeps/linux/lm32/bits/stackinfo.h b/libc/sysdeps/linux/lm32/bits/stackinfo.h
new file mode 100644
index 000000000..695616e86
--- /dev/null
+++ b/libc/sysdeps/linux/lm32/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. Since there is no general truth we can't say
+ anything here. */
+
+#ifndef _STACKINFO_H
+#define _STACKINFO_H 1
+
+#define _STACK_GROWS_DOWN 1
+
+#endif /* stackinfo.h */
diff --git a/libc/sysdeps/linux/lm32/bits/syscalls.h b/libc/sysdeps/linux/lm32/bits/syscalls.h
new file mode 100644
index 000000000..29569545b
--- /dev/null
+++ b/libc/sysdeps/linux/lm32/bits/syscalls.h
@@ -0,0 +1,59 @@
+#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__
+
+#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+ ({ \
+ LOAD_ARGS_##nr (args); \
+ register int __ret __asm__("r1"); \
+ register int _scno __asm__("r8") = name; \
+ __asm__ __volatile__("scall" \
+ : "=r" (__ret) \
+ : "r"(_scno) ASM_ARGS_##nr \
+ : __SYSCALL_CLOBBERS ); \
+ __ret; \
+ })
+
+/* original port had ret >= -125 ?! */
+#define LOAD_ARGS_0() do { } while(0)
+#define ASM_ARGS_0
+#define LOAD_ARGS_1(a1) \
+ int _a1 = (int)(a1); \
+ LOAD_ARGS_0(); \
+ register int __a1 __asm__("r1") = _a1
+#define ASM_ARGS_1 ASM_ARGS_0, "0"(__a1)
+#define LOAD_ARGS_2(a1, a2) \
+ int _a2 = (int)(a2); \
+ LOAD_ARGS_1(a1); \
+ register int __a2 __asm__("r2") = _a2
+#define ASM_ARGS_2 ASM_ARGS_1, "r"(__a2)
+#define LOAD_ARGS_3(a1, a2, a3) \
+ int _a3 = (int)(a3); \
+ LOAD_ARGS_2(a1, a2); \
+ register int __a3 __asm__("r3") = _a3
+#define ASM_ARGS_3 ASM_ARGS_2, "r"(__a3)
+#define LOAD_ARGS_4(a1, a2, a3, a4) \
+ int _a4 = (int)(a4); \
+ LOAD_ARGS_3(a1, a2, a3); \
+ register int __a4 __asm__("r4") = _a4
+#define ASM_ARGS_4 ASM_ARGS_3, "r"(__a4)
+#define LOAD_ARGS_5(a1, a2, a3, a4, a5) \
+ int _a5 = (int)(a5); \
+ LOAD_ARGS_4(a1, a2, a3, a4); \
+ register int __a5 __asm__("r5") = _a5
+#define ASM_ARGS_5 ASM_ARGS_4, "r"(__a5)
+#define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6) \
+ int _a6 = (int)(a6); \
+ LOAD_ARGS_5(a1, a2, a3, a4, a5); \
+ register int __a6 __asm__("r6") = _a6
+#define ASM_ARGS_6 ASM_ARGS_5, "r"(__a6)
+
+#define __SYSCALL_CLOBBERS
+
+#endif /* __ASSEMBLER__ */
+#endif /* _BITS_SYSCALLS_H */
diff --git a/libc/sysdeps/linux/e1/bits/uClibc_arch_features.h b/libc/sysdeps/linux/lm32/bits/uClibc_arch_features.h
index f4adaf5ad..a64f65351 100644
--- a/libc/sysdeps/linux/e1/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/lm32/bits/uClibc_arch_features.h
@@ -10,7 +10,7 @@
#undef __UCLIBC_ABORT_INSTRUCTION__
/* can your target use syscall6() for mmap ? */
-#undef __UCLIBC_MMAP_HAS_6_ARGS__
+#define __UCLIBC_MMAP_HAS_6_ARGS__
/* does your target use syscall4() for truncate64 ? (32bit arches only) */
#undef __UCLIBC_TRUNCATE64_HAS_4_ARGS__
@@ -18,22 +18,25 @@
/* 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 */
+#undef __UCLIBC_ASM_LINE_SEP__
+
#endif /* _BITS_UCLIBC_ARCH_FEATURES_H */
diff --git a/libc/sysdeps/linux/nios2/bits/uClibc_page.h b/libc/sysdeps/linux/lm32/bits/uClibc_page.h
index 311dd40ab..a2d7ea2c8 100644
--- a/libc/sysdeps/linux/nios2/bits/uClibc_page.h
+++ b/libc/sysdeps/linux/lm32/bits/uClibc_page.h
@@ -16,13 +16,10 @@
* 02111-1307 USA.
*/
-/* Supply an architecture specific value for PAGE_SIZE and friends. */
-
#ifndef _UCLIBC_PAGE_H
#define _UCLIBC_PAGE_H
-/* PAGE_SHIFT determines the page size -- in this case 4096 */
-#define PAGE_SHIFT (12)
+#define PAGE_SHIFT 12
#define PAGE_SIZE (1UL << PAGE_SHIFT)
#define PAGE_MASK (~(PAGE_SIZE-1))
diff --git a/libc/sysdeps/linux/lm32/bits/wordsize.h b/libc/sysdeps/linux/lm32/bits/wordsize.h
new file mode 100644
index 000000000..b47eee944
--- /dev/null
+++ b/libc/sysdeps/linux/lm32/bits/wordsize.h
@@ -0,0 +1 @@
+#define __WORDSIZE 32
diff --git a/libc/sysdeps/linux/lm32/clone.S b/libc/sysdeps/linux/lm32/clone.S
new file mode 100644
index 000000000..adc8b1a36
--- /dev/null
+++ b/libc/sysdeps/linux/lm32/clone.S
@@ -0,0 +1,52 @@
+#include <features.h>
+#include <sys/syscall.h>
+#define _ERRNO_H 1
+#include <bits/errno.h>
+
+#ifdef __NR_clone
+
+.text
+.global clone
+.type clone,@function
+.align 4
+
+clone:
+ be r1, r0, 2f
+ be r2, r0, 2f
+
+ mvi r8, __NR_clone
+ scall
+
+ mvi r3, -4095
+ bgeu r1, r3, 1f
+
+ be r1, r0, __thread_start
+
+ ret
+
+__thread_start:
+ mvi fp, 0
+ call r2
+
+ calli HIDDEN_JUMPTARGET(_exit)
+
+ /* Stop the unstoppable. */
+9:
+ bi 9b
+
+2:
+ mvi r1, -EINVAL
+1:
+ addi sp, sp, -8
+ sw (sp+4), ra
+ sw (sp+8), r1
+ calli __errno_location
+ lw r2, (sp+8)
+ lw ra, (sp+4)
+ sub r2, r0, r2
+ sw (r1+0), r2
+ mvi r1, -1
+ addi sp, sp, 8
+ ret
+
+#endif /* __NR_clone */
diff --git a/libc/sysdeps/linux/lm32/crt1.S b/libc/sysdeps/linux/lm32/crt1.S
new file mode 100644
index 000000000..661a1595f
--- /dev/null
+++ b/libc/sysdeps/linux/lm32/crt1.S
@@ -0,0 +1,21 @@
+.text
+.globl _start
+.type _start,@function
+.type main,@function
+.type __uClibc_main,@function
+
+_start:
+ mvi fp, 0 /* clear fp */
+ mvhi r1, hi(main) /* main */
+ ori r1, r1, lo(main)
+ lw r2, (sp+0) /* argc */
+ addi r3, sp, 4 /* argv */
+ mvhi r4, hi(_init) /* app_init */
+ ori r4, r4, lo(_init)
+ mvhi r5, hi(_fini) /* app_fini */
+ ori r5, r5, lo(_fini)
+ mvi r6, 0 /* rtld_fini */
+ mv r7, sp /* stack_end */
+
+ calli __uClibc_main
+
diff --git a/libc/sysdeps/linux/lm32/crti.S b/libc/sysdeps/linux/lm32/crti.S
new file mode 100644
index 000000000..8ceb15be9
--- /dev/null
+++ b/libc/sysdeps/linux/lm32/crti.S
@@ -0,0 +1,17 @@
+.section .init
+.global _init
+.type _init,@function
+.align 4
+
+_init:
+ addi sp, sp, -4
+ sw (sp+4), ra
+
+.section .fini
+.global _fini
+.type _fini,@function
+.align 4
+
+_fini:
+ addi sp, sp, -4
+ sw (sp+4), ra
diff --git a/libc/sysdeps/linux/lm32/crtn.S b/libc/sysdeps/linux/lm32/crtn.S
new file mode 100644
index 000000000..93643ac43
--- /dev/null
+++ b/libc/sysdeps/linux/lm32/crtn.S
@@ -0,0 +1,11 @@
+.section .init
+
+ lw ra, (sp+4)
+ addi sp, sp, 4
+ ret
+
+.section .fini
+
+ lw ra, (sp+4)
+ addi sp, sp, 4
+ ret
diff --git a/libc/sysdeps/linux/lm32/setjmp.S b/libc/sysdeps/linux/lm32/setjmp.S
new file mode 100644
index 000000000..6badd8099
--- /dev/null
+++ b/libc/sysdeps/linux/lm32/setjmp.S
@@ -0,0 +1,53 @@
+#define _SETJMP_H
+#define _ASM
+#include <bits/setjmp.h>
+
+#include <libc-symbols.h>
+
+.text
+.global C_SYMBOL_NAME(setjmp)
+.type C_SYMBOL_NAME(setjmp),@function
+.align 4
+
+C_SYMBOL_NAME(setjmp):
+ mvi r2, 1 /* save the signal mask */
+ bi C_SYMBOL_NAME(__sigsetjmp)
+
+.text
+.global C_SYMBOL_NAME(_setjmp)
+.type C_SYMBOL_NAME(_setjmp),@function
+.align 4
+
+C_SYMBOL_NAME(_setjmp):
+ mvi r2, 0 /* don't save the signal mask */
+ bi C_SYMBOL_NAME(__sigsetjmp)
+
+.text
+.global C_SYMBOL_NAME(__sigsetjmp)
+.type C_SYMBOL_NAME(__sigsetjmp),@function
+.align 4
+
+C_SYMBOL_NAME(__sigsetjmp):
+ /* save registers relative to r1 (arg0) */
+ sw (r1+0), r11
+ sw (r1+4), r12
+ sw (r1+8), r13
+ sw (r1+12), r14
+ sw (r1+16), r15
+ sw (r1+20), r16
+ sw (r1+24), r17
+ sw (r1+28), r18
+ sw (r1+32), r19
+ sw (r1+36), r20
+ sw (r1+40), r21
+ sw (r1+44), r22
+ sw (r1+48), r23
+ sw (r1+52), r24
+ sw (r1+56), r25
+ sw (r1+60), gp
+ sw (r1+64), fp
+ sw (r1+68), sp
+ sw (r1+72), ra
+
+ /* make a tail call to __sigjmp_save; it takes the same args */
+ bi C_SYMBOL_NAME(__sigjmp_save)
diff --git a/libc/sysdeps/linux/v850/sys/procfs.h b/libc/sysdeps/linux/lm32/sys/procfs.h
index 67acb3cce..c545fe78e 100644
--- a/libc/sysdeps/linux/v850/sys/procfs.h
+++ b/libc/sysdeps/linux/lm32/sys/procfs.h
@@ -34,31 +34,23 @@
/* Type for a general-purpose register. */
+#ifndef ELF_GREG_T
+#define ELF_GREG_T
typedef unsigned long elf_greg_t;
+#endif
-/* This is exactly the same as `struct pt_regs' in the kernel. */
-struct elf_gregset
-{
- /* General purpose registers. */
- elf_greg_t gpr[32];
-
- elf_greg_t pc; /* program counter */
- elf_greg_t psw; /* program status word */
-
- /* Registers used by `callt' instruction: */
- elf_greg_t ctpc; /* saved program counter */
- elf_greg_t ctpsw; /* saved psw */
- elf_greg_t ctbp; /* base pointer for callt table */
+#define ELF_NGREG 32
- char kernel_mode; /* 1 if in `kernel mode', 0 if user mode */
-};
-
-#define ELF_NGREG (sizeof (struct elf_gregset) / sizeof(elf_greg_t))
+#ifndef ELF_GREGSET_T
+#define ELF_GREGSET_T
typedef elf_greg_t elf_gregset_t[ELF_NGREG];
+#endif
/* Register set for the floating-point registers. */
-typedef void elf_fpregset_t;
-
+#ifndef ELF_FPREGSET_T
+#define ELF_FPREGSET_T
+typedef elf_greg_t elf_fpregset_t;
+#endif
struct elf_siginfo
{
diff --git a/libc/sysdeps/linux/v850/sys/ucontext.h b/libc/sysdeps/linux/lm32/sys/ucontext.h
index 07f0933ff..366158f86 100644
--- a/libc/sysdeps/linux/v850/sys/ucontext.h
+++ b/libc/sysdeps/linux/lm32/sys/ucontext.h
@@ -31,7 +31,7 @@ typedef struct sigcontext mcontext_t;
/* Userlevel context. */
typedef struct ucontext
{
- unsigned long int uc_flags;
+ unsigned long uc_flags;
struct ucontext *uc_link;
stack_t uc_stack;
mcontext_t uc_mcontext;
diff --git a/libc/sysdeps/linux/nios/brk.c b/libc/sysdeps/linux/lm32/sys/user.h
index ea2e45765..e8a8aaa95 100644
--- a/libc/sysdeps/linux/nios/brk.c
+++ b/libc/sysdeps/linux/lm32/sys/user.h
@@ -1,5 +1,4 @@
-/* brk system call for Linux/Nios2.
- Copyright (C) 1995, 1996, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1998 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
@@ -17,29 +16,25 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#include <unistd.h>
-#include <sys/syscall.h>
-#include <errno.h>
+#ifndef _SYS_USER_H
-/* This must be initialized data because commons can't have aliases. */
-void *__curbrk attribute_hidden = 0;
+#define _SYS_USER_H 1
+#include <features.h>
-libc_hidden_proto(brk)
-int brk (void *addr)
-{
- void *newbrk;
- register int g1 __asm__("%g1") = __NR_brk;
- register void *o0 __asm__("%o0") = addr;
+#include <asm/ptrace.h>
- __asm__ __volatile__ ("trap 63\n\t" : "=r"(newbrk) : "0"(o0), "r"(g1));
+struct user {
+ struct pt_regs regs; /* entire machine state */
+ size_t u_tsize; /* text size (pages) */
+ size_t u_dsize; /* data size (pages) */
+ size_t u_ssize; /* stack size (pages) */
+ unsigned long start_code; /* text starting address */
+ unsigned long start_data; /* data starting address */
+ unsigned long start_stack; /* stack starting address */
+ long int signal; /* signal causing core dump */
+ struct regs * u_ar0; /* help gdb find registers */
+ unsigned long magic; /* identifies a core file */
+ char u_comm[32]; /* user command name */
+};
- __curbrk = newbrk;
-
- if (newbrk < addr) {
- __set_errno (ENOMEM);
- return -1;
- }
-
- return 0;
-}
-libc_hidden_def(brk)
+#endif /* sys/user.h */
diff --git a/libc/sysdeps/linux/lm32/vfork.S b/libc/sysdeps/linux/lm32/vfork.S
new file mode 100644
index 000000000..f651ba6f8
--- /dev/null
+++ b/libc/sysdeps/linux/lm32/vfork.S
@@ -0,0 +1,42 @@
+#include <features.h>
+
+#define _ERRNO_H
+#include <bits/errno.h>
+#include <asm/unistd.h>
+#define _SIGNAL_H
+#include <bits/signum.h>
+
+#define CLONE_VM 0x00000100 /* set if VM shared between processes */
+#define CLONE_VFORK 0x00004000 /* set if the parent wants the child to */
+
+.text
+.global __vfork
+.hidden __vfork
+.type __vfork,%function
+.align 4
+
+__vfork:
+ mvi r2, 0
+ mvi r3, CLONE_VFORK | CLONE_VM | SIGCHLD
+ mvi r8, __NR_clone
+ scall
+
+ mvi r2, -4096
+ bgeu r2, r1, 1f
+
+ addi sp, sp, -8
+ sw (sp+4), ra
+ sw (sp+8), r1
+ calli __errno_location
+ lw r2, (sp+8)
+ lw ra, (sp+4)
+ sub r2, r0, r2
+ sw (r1+0), r2
+ addi sp, sp, 8
+ mvi r1, -1
+1:
+ ret
+
+.size __vfork,.-__vfork
+weak_alias(__vfork,vfork)
+libc_hidden_weak(vfork)
diff --git a/libc/sysdeps/linux/m68k/Makefile.arch b/libc/sysdeps/linux/m68k/Makefile.arch
index 14ce2e30a..88caa116f 100644
--- a/libc/sysdeps/linux/m68k/Makefile.arch
+++ b/libc/sysdeps/linux/m68k/Makefile.arch
@@ -5,8 +5,6 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-CSRC := brk.c __syscall_error.c syscall.c
+CSRC-y := brk.c __syscall_error.c
-SSRC := __longjmp.S bsd-_setjmp.S bsd-setjmp.S clone.S setjmp.S vfork.S
-
-include $(top_srcdir)libc/sysdeps/linux/Makefile.commonarch
+SSRC-y := __longjmp.S bsd-_setjmp.S bsd-setjmp.S clone.S setjmp.S vfork.S
diff --git a/libc/sysdeps/linux/m68k/README.m68k b/libc/sysdeps/linux/m68k/README.m68k
index a6bb17e4c..c1c1b4b5d 100644
--- a/libc/sysdeps/linux/m68k/README.m68k
+++ b/libc/sysdeps/linux/m68k/README.m68k
@@ -16,9 +16,9 @@ Configuration:
Read and edit the Config file, carefully.
TARGET_ARCH=m68k
- CROSS = m68k-pic-coff-
- CC = $(CROSS)gcc
- STRIPTOOL = $(CROSS)strip
+ CROSS_COMPILE = m68k-pic-coff-
+ CC = $(CROSS_COMPILE)gcc
+ STRIPTOOL = $(CROSS_COMPILE)strip
KERNEL_SOURCE=/opt/uClinux/linux
HAS_MMU = false
HAS_FLOATS = false
diff --git a/libc/sysdeps/linux/m68k/__longjmp.S b/libc/sysdeps/linux/m68k/__longjmp.S
index 5db9e4362..a93d92bff 100644
--- a/libc/sysdeps/linux/m68k/__longjmp.S
+++ b/libc/sysdeps/linux/m68k/__longjmp.S
@@ -2,10 +2,8 @@
/* Copyright (C) 2002, David McCullough <davidm@snapgear.com> */
/* This file is released under the LGPL, any version you like */
-#define _ASM
-#define _SETJMP_H
#include <features.h>
-#include <bits/setjmp.h>
+#include <jmpbuf-offsets.h>
.globl __longjmp
.type __longjmp,@function
@@ -17,7 +15,9 @@ __longjmp:
movel #1, %d0
1:
moveml %a0@(JB_REGS), %d2-%d7/%a2-%a7
-#if defined(__HAVE_68881__) || defined(__HAVE_FPU__)
+#if defined __mcffpu__ && defined __UCLIBC_HAS_FPU__
+ fmovem %a0@(JB_FPREGS), %fp2-%fp7
+#elif defined __HAVE_68881__ || defined __UCLIBC_HAS_FPU__
fmovemx %a0@(JB_FPREGS), %fp2-%fp7
#endif
movel %a0@(JB_PC), %sp@
diff --git a/libc/sysdeps/linux/m68k/bits/byteswap.h b/libc/sysdeps/linux/m68k/bits/byteswap.h
index f5ec91682..840a8cae6 100644
--- a/libc/sysdeps/linux/m68k/bits/byteswap.h
+++ b/libc/sysdeps/linux/m68k/bits/byteswap.h
@@ -13,55 +13,24 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
-#if !defined _BYTESWAP_H && !defined _NETINET_IN_H
-# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
-#endif
-
-#ifndef _BITS_BYTESWAP_H
-#define _BITS_BYTESWAP_H 1
-
-/* Swap bytes in 16 bit value. We don't provide an assembler version
- because GCC is smart enough to generate optimal assembler output, and
- this allows for better cse. */
-#define __bswap_16(x) \
- ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))
-
-/* Swap bytes in 32 bit value. */
-#define __bswap_constant_32(x) \
- ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
- (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
+#ifndef _ASM_BITS_BYTESWAP_H
+#define _ASM_BITS_BYTESWAP_H 1
-#if defined __GNUC__ && __GNUC__ >= 2 && !defined __mcoldfire__
-# define __bswap_32(x) \
+#if !defined __mcoldfire__
+# define __bswap_non_constant_32(x) \
__extension__ \
({ unsigned int __bswap_32_v; \
- if (__builtin_constant_p (x)) \
- __bswap_32_v = __bswap_constant_32 (x); \
- else \
- __asm__ __volatile__ ("ror%.w %#8, %0;" \
- "swap %0;" \
- "ror%.w %#8, %0" \
- : "=d" (__bswap_32_v) \
- : "0" ((unsigned int) (x))); \
+ __asm__ __volatile__ ("ror%.w %#8, %0;" \
+ "swap %0;" \
+ "ror%.w %#8, %0" \
+ : "=d" (__bswap_32_v) \
+ : "0" ((unsigned int) (x))); \
__bswap_32_v; })
-#else
-# define __bswap_32(x) __bswap_constant_32 (x)
#endif
-#if defined __GNUC__ && __GNUC__ >= 2
-/* Swap bytes in 64 bit value. */
-# define __bswap_64(x) \
- __extension__ \
- ({ union { unsigned long long int __ll; \
- unsigned long int __l[2]; } __bswap_64_v, __bswap_64_r; \
- __bswap_64_v.__ll = (x); \
- __bswap_64_r.__l[0] = __bswap_32 (__bswap_64_v.__l[1]); \
- __bswap_64_r.__l[1] = __bswap_32 (__bswap_64_v.__l[0]); \
- __bswap_64_r.__ll; })
#endif
-#endif /* _BITS_BYTESWAP_H */
+#include <bits/byteswap-common.h>
diff --git a/libc/sysdeps/linux/m68k/bits/fcntl.h b/libc/sysdeps/linux/m68k/bits/fcntl.h
index 37e99f9e0..636934d5f 100644
--- a/libc/sysdeps/linux/m68k/bits/fcntl.h
+++ b/libc/sysdeps/linux/m68k/bits/fcntl.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FCNTL_H
# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
@@ -49,6 +48,8 @@
# define O_NOFOLLOW 0100000 /* Do not follow links. */
# define O_DIRECT 0200000 /* Direct disk access. */
# define O_NOATIME 01000000 /* Do not set atime. */
+# define O_CLOEXEC 02000000 /* set close_on_exec */
+# define O_PATH 010000000 /* Resolve pathname but do not open file. */
#endif
/* For now Linux has synchronisity options for data and read operations.
@@ -98,6 +99,8 @@
# define F_NOTIFY 1026 /* Request notfications on a directory. */
# define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with
close-on-exit set on new fd. */
+# define F_SETPIPE_SZ 1031 /* Set pipe page size array. */
+# define F_GETPIPE_SZ 1032 /* Get pipe page size array. */
#endif
/* For F_[GET|SET]FL. */
@@ -185,7 +188,7 @@ struct flock64
#endif
-#ifdef __USE_GNU
+#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
@@ -208,7 +211,7 @@ struct flock64
__BEGIN_DECLS
-#ifdef __USE_GNU
+#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)
diff --git a/libc/sysdeps/linux/m68k/bits/fenv.h b/libc/sysdeps/linux/m68k/bits/fenv.h
index 7c0bcb669..b07f0ab51 100644
--- a/libc/sysdeps/linux/m68k/bits/fenv.h
+++ b/libc/sysdeps/linux/m68k/bits/fenv.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FENV_H
# error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
@@ -71,9 +70,9 @@ typedef struct
fenv_t;
/* If the default argument is used we use this value. */
-#define FE_DFL_ENV ((__const fenv_t *) -1)
+#define FE_DFL_ENV ((const fenv_t *) -1)
#ifdef __USE_GNU
/* Floating-point environment where none of the exceptions are masked. */
-# define FE_NOMASK_ENV ((__const fenv_t *) -2)
+# define FE_NOMASK_ENV ((const fenv_t *) -2)
#endif
diff --git a/libc/sysdeps/linux/m68k/bits/huge_vall.h b/libc/sysdeps/linux/m68k/bits/huge_vall.h
new file mode 100644
index 000000000..674b46d25
--- /dev/null
+++ b/libc/sysdeps/linux/m68k/bits/huge_vall.h
@@ -0,0 +1,42 @@
+/* `HUGE_VALL' constant for m68k (where it is infinity).
+ Used by <stdlib.h> and <math.h> functions for overflow.
+ Copyright (C) 1992, 1995, 1996, 1997, 1999, 2000, 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.
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _MATH_H
+# error "Never use <bits/huge_val.h> directly; include <math.h> instead."
+#endif
+
+#if __GNUC_PREREQ(3,3)
+# define HUGE_VALL (__builtin_huge_vall ())
+#elif __GNUC_PREREQ(2,96)
+# define HUGE_VALL (__extension__ 0x1.0p32767L)
+#elif defined __GNUC__
+
+# define HUGE_VALL \
+ (__extension__ \
+ ((union { unsigned long __l[3]; long double __ld; }) \
+ { __l: { 0x7fff0000UL, 0x80000000UL, 0UL } }).__ld)
+
+#else /* not GCC */
+
+static union { unsigned char __c[12]; long double __ld; } __huge_vall =
+ { { 0x7f, 0xff, 0, 0, 0x80, 0, 0, 0, 0, 0, 0, 0 } };
+# define HUGE_VALL (__huge_vall.__ld)
+
+#endif /* GCC 2.95. */
diff --git a/libc/sysdeps/linux/m68k/bits/kernel_stat.h b/libc/sysdeps/linux/m68k/bits/kernel_stat.h
index e60362b54..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... */
@@ -22,12 +18,9 @@ struct kernel_stat {
unsigned long st_size;
unsigned long st_blksize;
unsigned long st_blocks;
- unsigned long st_atime;
- unsigned long __unused1;
- unsigned long st_mtime;
- unsigned long __unused2;
- unsigned long st_ctime;
- unsigned long __unused3;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
unsigned long __unused4;
unsigned long __unused5;
};
@@ -49,12 +42,9 @@ struct kernel_stat64 {
unsigned long st_blksize;
unsigned long __pad4; /* future possible st_blocks high bits */
unsigned long st_blocks; /* Number 512-byte blocks allocated. */
- unsigned long st_atime;
- unsigned long __pad5;
- unsigned long st_mtime;
- unsigned long __pad6;
- unsigned long st_ctime;
- unsigned long __pad7; /* will be high 32 bits of ctime someday */
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
unsigned long long st_ino;
};
diff --git a/libc/sysdeps/linux/m68k/bits/kernel_types.h b/libc/sysdeps/linux/m68k/bits/kernel_types.h
index 0a77a8f46..176b96853 100644
--- a/libc/sysdeps/linux/m68k/bits/kernel_types.h
+++ b/libc/sysdeps/linux/m68k/bits/kernel_types.h
@@ -32,6 +32,8 @@ typedef unsigned short __kernel_old_uid_t;
typedef unsigned short __kernel_old_gid_t;
typedef long long __kernel_loff_t;
typedef __kernel_dev_t __kernel_old_dev_t;
+typedef long __kernel_long_t;
+typedef unsigned long __kernel_ulong_t;
typedef struct {
#ifdef __USE_ALL
diff --git a/libc/sysdeps/linux/m68k/bits/mathdef.h b/libc/sysdeps/linux/m68k/bits/mathdef.h
index a69e93089..b2d2d31e4 100644
--- a/libc/sysdeps/linux/m68k/bits/mathdef.h
+++ b/libc/sysdeps/linux/m68k/bits/mathdef.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#if !defined _MATH_H && !defined _COMPLEX_H
# error "Never use <bits/mathdef.h> directly; include <math.h> instead"
diff --git a/libc/sysdeps/linux/m68k/bits/mathinline.h b/libc/sysdeps/linux/m68k/bits/mathinline.h
index f3166000d..0a5c802a7 100644
--- a/libc/sysdeps/linux/m68k/bits/mathinline.h
+++ b/libc/sysdeps/linux/m68k/bits/mathinline.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifdef __GNUC__
@@ -92,7 +91,7 @@
# ifdef __cplusplus
# define __m81_inline __inline
# else
-# define __m81_inline extern __inline
+# define __m81_inline __extern_inline
# endif
# define __M81_MATH_INLINES 1
#endif
@@ -351,14 +350,14 @@ __inline_functions (long double,l)
/* Note that there must be no whitespace before the argument passed for
NAME, to make token pasting work correctly with -traditional. */
# define __inline_forward_c(rettype, name, args1, args2) \
-extern __inline rettype __attribute__((__const__)) \
+__extern_inline rettype __attribute__((__const__)) \
name args1 \
{ \
return __CONCAT(__,name) args2; \
}
# define __inline_forward(rettype, name, args1, args2) \
-extern __inline rettype name args1 \
+__extern_inline rettype name args1 \
{ \
return __CONCAT(__,name) args2; \
}
diff --git a/libc/sysdeps/linux/m68k/bits/mman.h b/libc/sysdeps/linux/m68k/bits/mman.h
deleted file mode 100644
index fbec1a03f..000000000
--- a/libc/sysdeps/linux/m68k/bits/mman.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/* Definitions for POSIX memory map interface. Linux/m68k version.
- Copyright (C) 1997, 2000, 2003, 2005 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- 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_MMAN_H
-# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
-#endif
-
-/* The following definitions basically come from the kernel headers.
- But the kernel header is not namespace clean. */
-
-
-/* Protections are chosen from these bits, OR'd together. The
- implementation does not necessarily support PROT_EXEC or PROT_WRITE
- without PROT_READ. The only guarantees are that no writing will be
- allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
-
-#define PROT_READ 0x1 /* Page can be read. */
-#define PROT_WRITE 0x2 /* Page can be written. */
-#define PROT_EXEC 0x4 /* Page can be executed. */
-#define PROT_NONE 0x0 /* Page can not be accessed. */
-#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of
- growsdown vma (mprotect only). */
-#define PROT_GROWSUP 0x02000000 /* Extend change to start of
- growsup vma (mprotect only). */
-
-/* Sharing types (must choose one and only one of these). */
-#define MAP_SHARED 0x01 /* Share changes. */
-#define MAP_PRIVATE 0x02 /* Changes are private. */
-#ifdef __USE_MISC
-# define MAP_TYPE 0x0f /* Mask for type of mapping. */
-#endif
-
-/* Other flags. */
-#define MAP_FIXED 0x10 /* Interpret addr exactly. */
-#ifdef __USE_MISC
-# define MAP_FILE 0
-# define MAP_ANONYMOUS 0x20 /* Don't use a file. */
-# define MAP_ANON MAP_ANONYMOUS
-#endif
-
-/* These are Linux-specific. */
-#ifdef __USE_MISC
-# define MAP_GROWSDOWN 0x00100 /* Stack-like segment. */
-# define MAP_DENYWRITE 0x00800 /* ETXTBSY */
-# define MAP_EXECUTABLE 0x01000 /* Mark it as an executable. */
-# define MAP_LOCKED 0x02000 /* Lock the mapping. */
-# define MAP_NORESERVE 0x04000 /* Don't check for reservations. */
-# define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */
-# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */
-#endif
-
-/* Flags to `msync'. */
-#define MS_ASYNC 1 /* Sync memory asynchronously. */
-#define MS_SYNC 4 /* Synchronous memory sync. */
-#define MS_INVALIDATE 2 /* Invalidate the caches. */
-
-/* Flags for `mlockall'. */
-#define MCL_CURRENT 1 /* Lock all currently mapped pages. */
-#define MCL_FUTURE 2 /* Lock all additions to address
- space. */
-
-/* Flags for `mremap'. */
-#ifdef __USE_GNU
-# define MREMAP_MAYMOVE 1
-# define MREMAP_FIXED 2
-#endif
-
-/* Advice to `madvise'. */
-#ifdef __USE_BSD
-# define MADV_NORMAL 0 /* No further special treatment. */
-# define MADV_RANDOM 1 /* Expect random page references. */
-# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
-# define MADV_WILLNEED 3 /* Will need these pages. */
-# define MADV_DONTNEED 4 /* Don't need these pages. */
-# define MADV_DONTFORK 10 /* Do not inherit across fork. */
-# define MADV_DOFORK 11 /* Do inherit across fork. */
-#endif
-
-/* The POSIX people had to invent similar names for the same things. */
-#ifdef __USE_XOPEN2K
-# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
-# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
-# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
-# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
-# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
-#endif
diff --git a/libc/sysdeps/linux/m68k/bits/poll.h b/libc/sysdeps/linux/m68k/bits/poll.h
index f7a739315..1d845ebd2 100644
--- a/libc/sysdeps/linux/m68k/bits/poll.h
+++ b/libc/sysdeps/linux/m68k/bits/poll.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_POLL_H
# error "Never use <bits/poll.h> directly; include <sys/poll.h> instead."
diff --git a/libc/sysdeps/linux/m68k/bits/setjmp.h b/libc/sysdeps/linux/m68k/bits/setjmp.h
index a6b0ed0f1..94853f7e5 100644
--- a/libc/sysdeps/linux/m68k/bits/setjmp.h
+++ b/libc/sysdeps/linux/m68k/bits/setjmp.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* Define the machine-dependent type `jmp_buf'. m68k version. */
#ifndef _BITS_SETJMP_H
@@ -25,7 +24,7 @@
# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
#endif
-#ifndef _ASM
+#include <features.h>
typedef struct
{
@@ -37,7 +36,7 @@ typedef struct
int *__fp;
int *__sp;
-#if defined __HAVE_68881__ || defined __HAVE_FPU__
+#if defined __HAVE_68881__ || defined __UCLIBC_HAS_FPU__
/* There are eight floating point registers which
are saved in IEEE 96-bit extended format. */
char __fpregs[8 * (96 / 8)];
@@ -45,24 +44,4 @@ typedef struct
} __jmp_buf[1];
-#endif
-
-#define JB_REGS 0
-#define JB_DREGS 0
-#define JB_AREGS 24
-#define JB_PC 48
-#define JB_FPREGS 52
-
-#if defined __HAVE_68881__ || defined __HAVE_FPU__
-# define JB_SIZE 76
-#else
-# define JB_SIZE 52
-#endif
-
-
-/* Test if longjmp to JMPBUF would unwind the frame
- containing a local variable at ADDRESS. */
-#define _JMPBUF_UNWINDS(jmpbuf, address) \
- ((void *) (address) < (void *) (jmpbuf)->__aregs[5])
-
#endif /* bits/setjmp.h */
diff --git a/libc/sysdeps/linux/m68k/bits/sigcontextinfo.h b/libc/sysdeps/linux/m68k/bits/sigcontextinfo.h
index b7e08cfc9..851c21d04 100644
--- a/libc/sysdeps/linux/m68k/bits/sigcontextinfo.h
+++ b/libc/sysdeps/linux/m68k/bits/sigcontextinfo.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#define SIGCONTEXT int _code, struct sigcontext *
#define SIGCONTEXT_EXTRA_ARGS _code,
diff --git a/libc/sysdeps/linux/m68k/bits/stackinfo.h b/libc/sysdeps/linux/m68k/bits/stackinfo.h
index 66e5a17fb..5a31c610c 100644
--- a/libc/sysdeps/linux/m68k/bits/stackinfo.h
+++ b/libc/sysdeps/linux/m68k/bits/stackinfo.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* This file contains a bit of information about the stack allocation
of the processor. */
diff --git a/libc/sysdeps/linux/m68k/bits/stat.h b/libc/sysdeps/linux/m68k/bits/stat.h
index a0fefbe2b..d71670db8 100644
--- a/libc/sysdeps/linux/m68k/bits/stat.h
+++ b/libc/sysdeps/linux/m68k/bits/stat.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992,95,96,97,98,99,2000,2001,2002
+/* Copyright (C) 1992,95,96,97,98,99,2000,2001,2002,2008,2009
Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_STAT_H
# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
@@ -61,7 +60,7 @@ struct stat
#else
__blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
#endif
-#if 0 /*def __USE_MISC*/
+#ifdef __USE_MISC
/* Nanosecond resolution timestamps are stored in a format
equivalent to 'struct timespec'. This is the type used
whenever possible but the Unix namespace rules do not allow the
@@ -107,7 +106,7 @@ struct stat64
__blksize_t st_blksize; /* Optimal block size for I/O. */
__blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
-#if 0 /*def __USE_MISC*/
+#ifdef __USE_MISC
/* Nanosecond resolution timestamps are stored in a format
equivalent to 'struct timespec'. This is the type used
whenever possible but the Unix namespace rules do not allow the
@@ -162,3 +161,8 @@ struct stat64
#define __S_IREAD 0400 /* Read by owner. */
#define __S_IWRITE 0200 /* Write by owner. */
#define __S_IEXEC 0100 /* Execute by owner. */
+
+#ifdef __USE_ATFILE
+# define UTIME_NOW ((1l << 30) - 1l)
+# define UTIME_OMIT ((1l << 30) - 2l)
+#endif
diff --git a/libc/sysdeps/linux/m68k/bits/syscalls.h b/libc/sysdeps/linux/m68k/bits/syscalls.h
index d1ade8036..17966ed06 100644
--- a/libc/sysdeps/linux/m68k/bits/syscalls.h
+++ b/libc/sysdeps/linux/m68k/bits/syscalls.h
@@ -13,8 +13,6 @@
#ifndef __ASSEMBLER__
-#include <errno.h>
-
/* Linux takes system call arguments in registers:
syscall number %d0 call-clobbered
@@ -23,9 +21,11 @@
arg 3 %d3 call-saved
arg 4 %d4 call-saved
arg 5 %d5 call-saved
+ arg 6 %a0 call-clobbered
The stack layout upon entering the function is:
+ 24(%sp) Arg# 6
20(%sp) Arg# 5
16(%sp) Arg# 4
12(%sp) Arg# 3
@@ -40,160 +40,74 @@
speed is more important, we don't use movem. Since %a0 and %a1 are
scratch registers, we can use them for saving as well. */
-#define __syscall_return(type, res) \
-do { \
- if ((unsigned long)(res) >= (unsigned long)(-125)) { \
- /* avoid using res which is declared to be in register d0; \
- errno might expand to a function call and clobber it. */ \
- int __err = -(res); \
- __set_errno(__err); \
- res = -1; \
- } \
- return (type) (res); \
-} while (0)
-
-#define _syscall0(type, name) \
-type name(void) \
-{ \
- long __res; \
- __asm__ __volatile__ ( \
- "movel %1, %%d0\n\t" \
- "trap #0\n\t" \
- "movel %%d0, %0" \
- : "=g" (__res) \
- : "i" (__NR_##name) \
- : "memory", "cc", "%d0"); \
- __syscall_return(type, __res); \
-}
-
-#define _syscall1(type, name, atype, a) \
-type name(atype a) \
-{ \
- long __res; \
- __asm__ __volatile__ ( \
- "movel %2, %%d1\n\t" \
- "movel %1, %%d0\n\t" \
- "trap #0\n\t" \
- "movel %%d0, %0" \
- : "=g" (__res) \
- : "i" (__NR_##name), \
- "g" ((long)a) \
- : "memory", "cc", "%d0", "%d1"); \
- __syscall_return(type, __res); \
-}
-
-#define _syscall2(type, name, atype, a, btype, b) \
-type name(atype a, btype b) \
-{ \
- long __res; \
- __asm__ __volatile__ ( \
- "movel %3, %%d2\n\t" \
- "movel %2, %%d1\n\t" \
- "movel %1, %%d0\n\t" \
- "trap #0\n\t" \
- "movel %%d0, %0" \
- : "=g" (__res) \
- : "i" (__NR_##name), \
- "a" ((long)a), \
- "g" ((long)b) \
- : "memory", "cc", "%d0", "%d1", "%d2"); \
- __syscall_return(type, __res); \
-}
-
-#define _syscall3(type, name, atype, a, btype, b, ctype, c) \
-type name(atype a, btype b, ctype c) \
-{ \
- long __res; \
- __asm__ __volatile__ ( \
- "movel %4, %%d3\n\t" \
- "movel %3, %%d2\n\t" \
- "movel %2, %%d1\n\t" \
- "movel %1, %%d0\n\t" \
- "trap #0\n\t" \
- "movel %%d0, %0" \
- : "=g" (__res) \
- : "i" (__NR_##name), \
- "a" ((long)a), \
- "a" ((long)b), \
- "g" ((long)c) \
- : "memory", "cc", "%d0", "%d1", "%d2", "%d3"); \
- __syscall_return(type, __res); \
-}
-
-#define _syscall4(type, name, atype, a, btype, b, ctype, c, dtype, d) \
-type name(atype a, btype b, ctype c, dtype d) \
-{ \
- long __res; \
- __asm__ __volatile__ ( \
- "movel %5, %%d4\n\t" \
- "movel %4, %%d3\n\t" \
- "movel %3, %%d2\n\t" \
- "movel %2, %%d1\n\t" \
- "movel %1, %%d0\n\t" \
- "trap #0\n\t" \
- "movel %%d0, %0" \
- : "=g" (__res) \
- : "i" (__NR_##name), \
- "a" ((long)a), \
- "a" ((long)b), \
- "a" ((long)c), \
- "g" ((long)d) \
- : "memory", "cc", "%d0", "%d1", "%d2", "%d3", \
- "%d4"); \
- __syscall_return(type, __res); \
-}
-
-#define _syscall5(type, name, atype, a, btype, b, ctype, c, dtype, d, etype, e) \
-type name(atype a, btype b, ctype c, dtype d, etype e) \
-{ \
- long __res; \
- __asm__ __volatile__ ( \
- "movel %6, %%d5\n\t" \
- "movel %5, %%d4\n\t" \
- "movel %4, %%d3\n\t" \
- "movel %3, %%d2\n\t" \
- "movel %2, %%d1\n\t" \
- "movel %1, %%d0\n\t" \
- "trap #0\n\t" \
- "movel %%d0, %0" \
- : "=g" (__res) \
- : "i" (__NR_##name), \
- "a" ((long)a), \
- "a" ((long)b), \
- "a" ((long)c), \
- "a" ((long)d), \
- "g" ((long)e) \
- : "memory", "cc", "%d0", "%d1", "%d2", "%d3", \
- "%d4", "%d5"); \
- __syscall_return(type, __res); \
-}
-
-#define _syscall6(type, name, atype, a, btype, b, ctype, c, dtype, d, etype, e, ftype, f) \
-type name(atype a, btype b, ctype c, dtype d, etype e, ftype f) \
-{ \
- long __res; \
- __asm__ __volatile__ ( \
- "movel %7, %%a0\n\t" \
- "movel %6, %%d5\n\t" \
- "movel %5, %%d4\n\t" \
- "movel %4, %%d3\n\t" \
- "movel %3, %%d2\n\t" \
- "movel %2, %%d1\n\t" \
- "movel %1, %%d0\n\t" \
- "trap #0\n\t" \
- "movel %%d0, %0" \
- : "=g" (__res) \
- : "i" (__NR_##name), \
- "a" ((long)a), \
- "a" ((long)b), \
- "a" ((long)c), \
- "a" ((long)d), \
- "g" ((long)e), \
- "g" ((long)f) \
- : "memory", "cc", "%d0", "%d1", "%d2", "%d3", \
- "%d4", "%d5", "%a0"); \
- __syscall_return(type, __res); \
-}
+/* Define a macro which expands inline into the wrapper code for a system
+ call. This use is for internal calls that do not need to handle errors
+ normally. It will never touch errno. This returns just what the kernel
+ gave back. */
+#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+(__extension__ \
+ ({ unsigned int _sys_result; \
+ { \
+ /* Load argument values in temporary variables
+ to perform side effects like function calls
+ before the call used registers are set. */ \
+ LOAD_ARGS_##nr (args) \
+ LOAD_REGS_##nr \
+ register int _d0 __asm__ ("%d0") = name; \
+ __asm__ __volatile__ ("trap #0" \
+ : "=d" (_d0) \
+ : "0" (_d0) ASM_ARGS_##nr \
+ : "memory"); \
+ _sys_result = _d0; \
+ } \
+ (int) _sys_result; \
+ }) \
+)
+#define LOAD_ARGS_0()
+#define LOAD_REGS_0
+#define ASM_ARGS_0
+#define LOAD_ARGS_1(a1) \
+ LOAD_ARGS_0 () \
+ int __arg1 = (int) (a1);
+#define LOAD_REGS_1 \
+ register int _d1 __asm__ ("d1") = __arg1; \
+ LOAD_REGS_0
+#define ASM_ARGS_1 ASM_ARGS_0, "d" (_d1)
+#define LOAD_ARGS_2(a1, a2) \
+ LOAD_ARGS_1 (a1) \
+ int __arg2 = (int) (a2);
+#define LOAD_REGS_2 \
+ register int _d2 __asm__ ("d2") = __arg2; \
+ LOAD_REGS_1
+#define ASM_ARGS_2 ASM_ARGS_1, "d" (_d2)
+#define LOAD_ARGS_3(a1, a2, a3) \
+ LOAD_ARGS_2 (a1, a2) \
+ int __arg3 = (int) (a3);
+#define LOAD_REGS_3 \
+ register int _d3 __asm__ ("d3") = __arg3; \
+ LOAD_REGS_2
+#define ASM_ARGS_3 ASM_ARGS_2, "d" (_d3)
+#define LOAD_ARGS_4(a1, a2, a3, a4) \
+ LOAD_ARGS_3 (a1, a2, a3) \
+ int __arg4 = (int) (a4);
+#define LOAD_REGS_4 \
+ register int _d4 __asm__ ("d4") = __arg4; \
+ LOAD_REGS_3
+#define ASM_ARGS_4 ASM_ARGS_3, "d" (_d4)
+#define LOAD_ARGS_5(a1, a2, a3, a4, a5) \
+ LOAD_ARGS_4 (a1, a2, a3, a4) \
+ int __arg5 = (int) (a5);
+#define LOAD_REGS_5 \
+ register int _d5 __asm__ ("d5") = __arg5; \
+ LOAD_REGS_4
+#define ASM_ARGS_5 ASM_ARGS_4, "d" (_d5)
+#define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6) \
+ LOAD_ARGS_5 (a1, a2, a3, a4, a5) \
+ int __arg6 = (int) (a6);
+#define LOAD_REGS_6 \
+ register int _a0 __asm__ ("a0") = __arg6; \
+ LOAD_REGS_5
+#define ASM_ARGS_6 ASM_ARGS_5, "a" (_a0)
#endif /* __ASSEMBLER__ */
#endif /* _BITS_SYSCALLS_H */
diff --git a/libc/sysdeps/linux/m68k/bits/uClibc_arch_features.h b/libc/sysdeps/linux/m68k/bits/uClibc_arch_features.h
index b5ef48f4b..5cfaa4343 100644
--- a/libc/sysdeps/linux/m68k/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/m68k/bits/uClibc_arch_features.h
@@ -15,8 +15,8 @@
/* can your target use syscall6() for mmap ? */
#undef __UCLIBC_MMAP_HAS_6_ARGS__
-/* does your target use syscall4() for truncate64 ? (32bit arches only) */
-#undef __UCLIBC_TRUNCATE64_HAS_4_ARGS__
+/* does your target align 64bit values in register pairs ? (32bit arches only) */
+#undef __UCLIBC_SYSCALL_ALIGN_64BIT__
/* does your target have a broken create_module() ? */
#define __UCLIBC_BROKEN_CREATE_MODULE__
@@ -27,19 +27,19 @@
/* 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 */
+#undef __UCLIBC_ASM_LINE_SEP__
+
#endif /* _BITS_UCLIBC_ARCH_FEATURES_H */
diff --git a/libc/sysdeps/linux/m68k/bits/uClibc_page.h b/libc/sysdeps/linux/m68k/bits/uClibc_page.h
index 51c6f1446..6a202b1d2 100644
--- a/libc/sysdeps/linux/m68k/bits/uClibc_page.h
+++ b/libc/sysdeps/linux/m68k/bits/uClibc_page.h
@@ -11,8 +11,8 @@
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * License along with this library; if not, see
+ * <http://www.gnu.org/licenses/>.
*/
/* Supply an architecture specific value for PAGE_SIZE and friends. */
diff --git a/libc/sysdeps/linux/m68k/bits/wordsize.h b/libc/sysdeps/linux/m68k/bits/wordsize.h
index ba643b60a..ca82fd7d4 100644
--- a/libc/sysdeps/linux/m68k/bits/wordsize.h
+++ b/libc/sysdeps/linux/m68k/bits/wordsize.h
@@ -12,8 +12,7 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#define __WORDSIZE 32
diff --git a/libc/sysdeps/linux/m68k/brk.c b/libc/sysdeps/linux/m68k/brk.c
index 7daf1bd76..40ebf4fc7 100644
--- a/libc/sysdeps/linux/m68k/brk.c
+++ b/libc/sysdeps/linux/m68k/brk.c
@@ -9,7 +9,6 @@
#include <sys/syscall.h>
#include <errno.h>
-libc_hidden_proto(brk)
/* This must be initialized data because commons can't have aliases. */
void * __curbrk = 0;
diff --git a/libc/sysdeps/linux/m68k/bsd-_setjmp.S b/libc/sysdeps/linux/m68k/bsd-_setjmp.S
index 0380c3dee..c963cccf5 100644
--- a/libc/sysdeps/linux/m68k/bsd-_setjmp.S
+++ b/libc/sysdeps/linux/m68k/bsd-_setjmp.S
@@ -2,9 +2,8 @@
/* Copyright (C) 2002, David McCullough <davidm@snapgear.com> */
/* This file is released under the LGPL, any version you like */
-#define _ASM
-#define _SETJMP_H
-#include <bits/setjmp.h>
+#include <features.h>
+#include <jmpbuf-offsets.h>
.globl _setjmp;
.type _setjmp,@function
@@ -14,7 +13,7 @@ _setjmp:
moveal %sp@(4), %a0
movel %sp@(0), %a0@(JB_PC)
moveml %d2-%d7/%a2-%a7, %a0@(JB_REGS)
-#if defined(__HAVE_68881__) || defined(__HAVE_FPU__)
+#if defined __HAVE_68881__ || defined __UCLIBC_HAS_FPU__
fmovemx %fp2-%fp7, %a0@(JB_FPREGS)
#endif
clrl %d0
diff --git a/libc/sysdeps/linux/m68k/bsd-setjmp.S b/libc/sysdeps/linux/m68k/bsd-setjmp.S
index fdd7540a6..9daf27713 100644
--- a/libc/sysdeps/linux/m68k/bsd-setjmp.S
+++ b/libc/sysdeps/linux/m68k/bsd-setjmp.S
@@ -2,9 +2,8 @@
/* Copyright (C) 2002, David McCullough <davidm@snapgear.com> */
/* This file is released under the LGPL, any version you like */
-#define _ASM
-#define _SETJMP_H
-#include <bits/setjmp.h>
+#include <features.h>
+#include <jmpbuf-offsets.h>
#include "m68k_pic.S"
.globl setjmp;
@@ -15,7 +14,7 @@ setjmp:
moveal %sp@(4), %a0
movel %sp@(0), %a0@(JB_PC)
moveml %d2-%d7/%a2-%a7, %a0@(JB_REGS)
-#if defined(__HAVE_68881__) || defined(__HAVE_FPU__)
+#if defined __HAVE_68881__ || defined __UCLIBC_HAS_FPU__
fmovemx %fp2-%fp7, %a0@(JB_FPREGS)
#endif
clrl %d0
diff --git a/libc/sysdeps/linux/m68k/crt1.S b/libc/sysdeps/linux/m68k/crt1.S
index a9cf00193..815a6076f 100644
--- a/libc/sysdeps/linux/m68k/crt1.S
+++ b/libc/sysdeps/linux/m68k/crt1.S
@@ -30,9 +30,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <features.h>
#include "m68k_pic.S"
diff --git a/libc/sysdeps/linux/m68k/fpu_control.h b/libc/sysdeps/linux/m68k/fpu_control.h
index 040e62c94..35ad95e6d 100644
--- a/libc/sysdeps/linux/m68k/fpu_control.h
+++ b/libc/sysdeps/linux/m68k/fpu_control.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FPU_CONTROL_H
#define _FPU_CONTROL_H
diff --git a/libc/sysdeps/linux/m68k/jmpbuf-offsets.h b/libc/sysdeps/linux/m68k/jmpbuf-offsets.h
new file mode 100644
index 000000000..fdd365d12
--- /dev/null
+++ b/libc/sysdeps/linux/m68k/jmpbuf-offsets.h
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <features.h>
+
+#define JB_REGS 0
+#define JB_DREGS 0
+#define JB_AREGS 24
+#define JB_PC 48
+#define JB_FPREGS 52
+
+#if defined __HAVE_68881__ || defined __UCLIBC_HAS_FPU__
+# define JB_SIZE 76
+#else
+# define JB_SIZE 52
+#endif
diff --git a/libc/sysdeps/linux/m68k/jmpbuf-unwind.h b/libc/sysdeps/linux/m68k/jmpbuf-unwind.h
new file mode 100644
index 000000000..d87ace333
--- /dev/null
+++ b/libc/sysdeps/linux/m68k/jmpbuf-unwind.h
@@ -0,0 +1,11 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+#include <setjmp.h>
+
+/* Test if longjmp to JMPBUF would unwind the frame
+ containing a local variable at ADDRESS. */
+#define _JMPBUF_UNWINDS(jmpbuf, address) \
+ ((void *) (address) < (void *) (jmpbuf)->__aregs[5])
diff --git a/libc/sysdeps/linux/m68k/setjmp.S b/libc/sysdeps/linux/m68k/setjmp.S
index 4adda0af5..5f05b8591 100644
--- a/libc/sysdeps/linux/m68k/setjmp.S
+++ b/libc/sysdeps/linux/m68k/setjmp.S
@@ -2,9 +2,8 @@
/* Copyright (C) 2002, David McCullough <davidm@snapgear.com> */
/* This file is released under the LGPL, any version you like */
-#define _ASM
-#define _SETJMP_H
-#include <bits/setjmp.h>
+#include <features.h>
+#include <jmpbuf-offsets.h>
#include "m68k_pic.S"
.globl __sigsetjmp;
@@ -15,7 +14,7 @@ __sigsetjmp:
moveal %sp@(4), %a0
movel %sp@(0), %a0@(JB_PC)
moveml %d2-%d7/%a2-%a7, %a0@(JB_REGS)
-#if defined(__HAVE_68881__) || defined(__HAVE_FPU__)
+#if defined __HAVE_68881__ || defined __UCLIBC_HAS_FPU__
fmovemx %fp2-%fp7, %a0@(JB_FPREGS)
#endif
clrl %d0
diff --git a/libc/sysdeps/linux/m68k/sys/procfs.h b/libc/sysdeps/linux/m68k/sys/procfs.h
index 27abf8ef5..1722bf0f2 100644
--- a/libc/sysdeps/linux/m68k/sys/procfs.h
+++ b/libc/sysdeps/linux/m68k/sys/procfs.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_PROCFS_H
#define _SYS_PROCFS_H 1
diff --git a/libc/sysdeps/linux/m68k/sys/reg.h b/libc/sysdeps/linux/m68k/sys/reg.h
deleted file mode 100644
index 418f8323f..000000000
--- a/libc/sysdeps/linux/m68k/sys/reg.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/* Copyright (C) 1998 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_REG_H
-#define _SYS_REG_H 1
-
-/* Index into an array of 4 byte integers returned from ptrace for
- location of the users' stored general purpose registers. */
-
-enum
-{
- PT_D1 = 0,
-#define PT_D1 PT_D1
- PT_D2 = 1,
-#define PT_D2 PT_D2
- PT_D3 = 2,
-#define PT_D3 PT_D3
- PT_D4 = 3,
-#define PT_D4 PT_D4
- PT_D5 = 4,
-#define PT_D5 PT_D5
- PT_D6 = 5,
-#define PT_D6 PT_D6
- PT_D7 = 6,
-#define PT_D7 PT_D7
- PT_A0 = 7,
-#define PT_A0 PT_A0
- PT_A1 = 8,
-#define PT_A1 PT_A1
- PT_A2 = 9,
-#define PT_A2 PT_A2
- PT_A3 = 10,
-#define PT_A3 PT_A3
- PT_A4 = 11,
-#define PT_A4 PT_A4
- PT_A5 = 12,
-#define PT_A5 PT_A5
- PT_A6 = 13,
-#define PT_A6 PT_A6
- PT_D0 = 14,
-#define PT_D0 PT_D0
- PT_USP = 15,
-#define PT_USP PT_USP
- PT_ORIG_D0 = 16,
-#define PT_ORIG_D0 PT_ORIG_D0
- PT_SR = 17,
-#define PT_SR PT_SR
- PT_PC = 18,
-#define PT_PC PT_PC
- PT_FP0 = 21,
-#define PT_FP0 PT_FP0
- PT_FP1 = 24,
-#define PT_FP1 PT_FP1
- PT_FP2 = 27,
-#define PT_FP2 PT_FP2
- PT_FP3 = 30,
-#define PT_FP3 PT_FP3
- PT_FP4 = 33,
-#define PT_FP4 PT_FP4
- PT_FP5 = 36,
-#define PT_FP5 PT_FP5
- PT_FP6 = 39,
-#define PT_FP6 PT_FP6
- PT_FP7 = 42,
-#define PT_FP7 PT_FP7
- PT_FPCR = 45,
-#define PT_FPCR PT_FPCR
- PT_FPSR = 46,
-#define PT_FPSR PT_FPSR
- PT_FPIAR = 47
-#define PT_FPIAR PT_FPIAR
-};
-
-#endif /* _SYS_REG_H */
diff --git a/libc/sysdeps/linux/m68k/sys/ucontext.h b/libc/sysdeps/linux/m68k/sys/ucontext.h
index 3c441dc5c..85d2dd90e 100644
--- a/libc/sysdeps/linux/m68k/sys/ucontext.h
+++ b/libc/sysdeps/linux/m68k/sys/ucontext.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* System V/m68k ABI compliant context switching support. */
diff --git a/libc/sysdeps/linux/m68k/sys/user.h b/libc/sysdeps/linux/m68k/sys/user.h
new file mode 100644
index 000000000..8114a2bd3
--- /dev/null
+++ b/libc/sysdeps/linux/m68k/sys/user.h
@@ -0,0 +1,90 @@
+#ifndef _M68K_USER_H
+#define _M68K_USER_H
+/*
+ This file was taken verbatim from linux-2.6.26.5.
+ The linux kernel is Copyright (C) Linus Torvalds et al.
+ and is licensed under the GNU General Public License, version 2.
+*/
+/* Core file format: The core file is written in such a way that gdb
+ can understand it and provide useful information to the user (under
+ linux we use the 'trad-core' bfd). There are quite a number of
+ obstacles to being able to view the contents of the floating point
+ registers, and until these are solved you will not be able to view the
+ contents of them. Actually, you can read in the core file and look at
+ the contents of the user struct to find out what the floating point
+ registers contain.
+ The actual file contents are as follows:
+ UPAGE: 1 page consisting of a user struct that tells gdb what is present
+ in the file. Directly after this is a copy of the task_struct, which
+ is currently not used by gdb, but it may come in useful at some point.
+ All of the registers are stored as part of the upage. The upage should
+ always be only one page.
+ DATA: The data area is stored. We use current->end_text to
+ current->brk to pick up all of the user variables, plus any memory
+ that may have been malloced. No attempt is made to determine if a page
+ is demand-zero or if a page is totally unused, we just cover the entire
+ range. All of the addresses are rounded in such a way that an integral
+ number of pages is written.
+ STACK: We need the stack information in order to get a meaningful
+ backtrace. We need to write the data from (esp) to
+ current->start_stack, so we round each of these off in order to be able
+ to write an integer number of pages.
+ The minimum core file size is 3 pages, or 12288 bytes.
+*/
+
+struct user_m68kfp_struct {
+ unsigned long fpregs[8*3]; /* fp0-fp7 registers */
+ unsigned long fpcntl[3]; /* fp control regs */
+};
+
+/* This is the old layout of "struct pt_regs" as of Linux 1.x, and
+ is still the layout used by user (the new pt_regs doesn't have
+ all registers). */
+struct user_regs_struct {
+ long d1,d2,d3,d4,d5,d6,d7;
+ long a0,a1,a2,a3,a4,a5,a6;
+ long d0;
+ long usp;
+ long orig_d0;
+ short stkadj;
+ short sr;
+ long pc;
+ short fmtvec;
+ short __fill;
+};
+
+
+/* When the kernel dumps core, it starts by dumping the user struct -
+ this will be used by gdb to figure out where the data and stack segments
+ are within the file, and what virtual addresses to use. */
+struct user{
+/* We start with the registers, to mimic the way that "memory" is returned
+ from the ptrace(3,...) function. */
+ struct user_regs_struct regs; /* Where the registers are actually stored */
+/* ptrace does not yet supply these. Someday.... */
+ int u_fpvalid; /* True if math co-processor being used. */
+ /* for this mess. Not yet used. */
+ struct user_m68kfp_struct m68kfp; /* Math Co-processor registers. */
+/* The rest of this junk is to help gdb figure out what goes where */
+ unsigned long int u_tsize; /* Text segment size (pages). */
+ unsigned long int u_dsize; /* Data segment size (pages). */
+ unsigned long int u_ssize; /* Stack segment size (pages). */
+ unsigned long start_code; /* Starting virtual address of text. */
+ unsigned long start_stack; /* Starting virtual address of stack area.
+ This is actually the bottom of the stack,
+ the top of the stack is always found in the
+ esp register. */
+ long int signal; /* Signal that caused the core dump. */
+ int reserved; /* No longer used */
+ unsigned long u_ar0; /* Used by gdb to help find the values for */
+ /* the registers. */
+ struct user_m68kfp_struct* u_fpstate; /* Math Co-processor pointer. */
+ unsigned long magic; /* To uniquely identify a core file */
+ char u_comm[32]; /* User command that was responsible */
+};
+#define NBPG 4096
+#define UPAGES 1
+#define HOST_TEXT_START_ADDR (u.start_code)
+#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
+
+#endif
diff --git a/libc/sysdeps/linux/m68k/syscall.c b/libc/sysdeps/linux/m68k/syscall.c
deleted file mode 100644
index 5b13ea695..000000000
--- a/libc/sysdeps/linux/m68k/syscall.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/* syscall for m68k/uClibc
- *
- * Copyright (C) 2005-2006 by Christian Magnusson <mag@mag.cx>
- * Copyright (C) 2005-2006 Erik Andersen <andersen@uclibc.org>
- *
- * 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 <features.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/syscall.h>
-
-long syscall(long sysnum, long a, long b, long c, long d, long e, long f);
-long syscall(long sysnum, long a, long b, long c, long d, long e, long f)
-{
- long __res;
- __asm__ __volatile__ (
- "movel %7, %%a0\n\t"
- "movel %6, %%d5\n\t"
- "movel %5, %%d4\n\t"
- "movel %4, %%d3\n\t"
- "movel %3, %%d2\n\t"
- "movel %2, %%d1\n\t"
- "movel %1, %%d0\n\t"
- "trap #0\n\t"
- "movel %%d0, %0"
- : "=g" (__res)
- : "g" (sysnum),
- "g" ((long)a), "g" ((long)b), "g" ((long)c),
- "g" ((long)d), "g" ((long)e), "g" ((long)f)
- : "memory", "cc", "%d0", "%d1", "%d2", "%d3",
- "%d4", "%d5", "%a0");
- __syscall_return(long,__res);
-}
diff --git a/libc/sysdeps/linux/m68k/vfork.S b/libc/sysdeps/linux/m68k/vfork.S
index 56d57f73c..bde9d5a3a 100644
--- a/libc/sysdeps/linux/m68k/vfork.S
+++ b/libc/sysdeps/linux/m68k/vfork.S
@@ -4,9 +4,7 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#include <features.h>
-
-#include <asm/unistd.h>
+#include <sys/syscall.h>
#ifndef __NR_vfork
#define __NR_vfork __NR_fork /* uClinux-2.0 only has fork which is vfork */
@@ -16,7 +14,6 @@
.text
.align 2
- .globl errno
.globl __vfork
.hidden __vfork
.type __vfork,@function
@@ -25,21 +22,24 @@ __vfork:
movl %sp@+, %a1 /* save the return address for later */
movl IMM __NR_vfork,%d0
trap #0
- movl IMM -4097, %d1
- cmpl %d0, %d1
- bcs fix_errno
- jmp %a1@ /* don't return, just jmp directly */
-fix_errno:
- negl %d0
+ movl %a1, -(%sp)
+
+ cmpil #-4096,%d0
+ blss 1f
+
+ neg.l %d0
#ifndef __PIC__ /* needs handling as the other archs */
movl errno, %a0
#else
movl errno@GOT(%a5), %a0
#endif
movl %d0, %a0@
- movl IMM -1, %d0
- jmp %a1@ /* don't return, just jmp directly */
+ move.l #-1, %d0
+
+1:
+ move.l %d0, %a0
+ rts
.size __vfork,.-__vfork
weak_alias(__vfork,vfork)
-libc_hidden_weak(vfork)
+libc_hidden_def(vfork)
diff --git a/libc/sysdeps/linux/metag/Makefile b/libc/sysdeps/linux/metag/Makefile
new file mode 100644
index 000000000..94b43e117
--- /dev/null
+++ b/libc/sysdeps/linux/metag/Makefile
@@ -0,0 +1,13 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+#
+# Licensed under the LGPL v2.1 or later, 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/metag/Makefile.arch b/libc/sysdeps/linux/metag/Makefile.arch
new file mode 100644
index 000000000..3f11d6da8
--- /dev/null
+++ b/libc/sysdeps/linux/metag/Makefile.arch
@@ -0,0 +1,12 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2013 Imagination Technologies Ltd.
+#
+# Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+#
+
+CSRC-y := brk.c syscall.c metag.c __syscall_error.c
+
+SSRC-y := _longjmp.S clone.S setjmp.S vfork.S
+
+SSRC-$(UCLIBC_HAS_THREADS_NATIVE) += libc-metag_load_tp.S
diff --git a/libc/sysdeps/linux/metag/__syscall_error.c b/libc/sysdeps/linux/metag/__syscall_error.c
new file mode 100644
index 000000000..f97cd0126
--- /dev/null
+++ b/libc/sysdeps/linux/metag/__syscall_error.c
@@ -0,0 +1,18 @@
+/* Wrapper for setting errno.
+ *
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <errno.h>
+#include <features.h>
+
+/* This routine is jumped to by all the syscall handlers, to stash
+ * an error number into errno. */
+int __syscall_error(int err_no) attribute_hidden;
+int __syscall_error(int err_no)
+{
+ __set_errno(-err_no);
+ return -1;
+}
diff --git a/libc/sysdeps/linux/metag/_longjmp.S b/libc/sysdeps/linux/metag/_longjmp.S
new file mode 100644
index 000000000..54bc71c36
--- /dev/null
+++ b/libc/sysdeps/linux/metag/_longjmp.S
@@ -0,0 +1,25 @@
+! Copyright (C) 2013 Imagination Technologies Ltd.
+
+! Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+
+
+ .text
+ .global ___longjmp
+ .type ___longjmp,function
+
+___longjmp:
+ !! If val is 0, set it to 1
+ CMP D0Ar2,#0
+ ADDZ D0Ar2,D0Ar2,#1
+
+ !! Restore A0/A1 regs
+ MGETL A0.0,A0.1,[D1Ar1++]
+ !! Restore D0/D1 regs
+ MOV A0.3,D1Ar1
+ MGETL D0FrT,D0.5,D0.6,D0.7,[A0.3++]
+ !! Move 2nd argument to return value
+ MOV D0Re0,D0Ar2
+ MOV PC,D1RtP
+ .size ___longjmp,.-___longjmp
+
+libc_hidden_def(__longjmp)
diff --git a/libc/sysdeps/linux/metag/bits/atomic.h b/libc/sysdeps/linux/metag/bits/atomic.h
new file mode 100644
index 000000000..64aa50bc4
--- /dev/null
+++ b/libc/sysdeps/linux/metag/bits/atomic.h
@@ -0,0 +1,66 @@
+/*
+ * Copyrith (C) 2013 Imagination Technologies Ltd.
+ *
+ * Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ *
+ */
+
+#include <stdint.h>
+#include <sysdep.h>
+
+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;
+
+void __metag_link_error (void);
+
+#define atomic_full_barrier() \
+ __asm__ __volatile__("": : :"memory")
+
+/* Atomic compare and exchange. This sequence relies on the kernel to
+ provide a compare and exchange operation which is atomic. */
+
+#define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
+ ({ __metag_link_error (); oldval; })
+
+#define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \
+ ({ __metag_link_error (); oldval; })
+
+/* This code uses the kernel helper to do cmpxchg. It relies on the fact
+ the helper code only clobbers D0Re0. */
+#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
+ ({ register __typeof (oldval) a_current __asm__ ("D1Ar1"); \
+ register __typeof (oldval) a_newval __asm__ ("D0Ar2") = (newval); \
+ register __typeof (mem) a_ptr __asm__ ("D1Ar3") = (mem); \
+ register __typeof (oldval) a_oldval __asm__ ("D0Ar4") = (oldval); \
+ __asm__ __volatile__ \
+ ("0:\n\t" \
+ "GETD %[cur], [%[ptr]]\n\t" \
+ "CMP %[cur], %[old]\n\t" \
+ "BNE 1f\n\t" \
+ "MOVT D1RtP, #0x6fff\n\t" \
+ "ADD D1RtP, D1RtP, #0xf040\n\t" \
+ "SWAP D1RtP, PC\n\t" \
+ "MOV %[cur], %[old]\n\t" \
+ "CMP D0Re0, #0\n\t" \
+ "BNE 0b\n\t" \
+ "1:" \
+ : [cur] "=&r" (a_current) \
+ : [new] "r" (a_newval), [ptr] "r" (a_ptr), \
+ [old] "r" (a_oldval) \
+ : "D0Re0", "D1RtP", "cc", "memory"); \
+ a_current; })
+
+#define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
+ ({ __metag_link_error (); oldval; })
diff --git a/libc/sysdeps/linux/metag/bits/endian.h b/libc/sysdeps/linux/metag/bits/endian.h
new file mode 100644
index 000000000..af99901a7
--- /dev/null
+++ b/libc/sysdeps/linux/metag/bits/endian.h
@@ -0,0 +1,12 @@
+/* Meta is little endian
+ *
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#ifndef _ENDIAN_H
+# error "Never use <bits/endian.h> directly; include <endian.h> instead."
+#endif
+
+#define __BYTE_ORDER __LITTLE_ENDIAN
diff --git a/libc/sysdeps/linux/e1/bits/fcntl.h b/libc/sysdeps/linux/metag/bits/fcntl.h
index 87d193923..8142a8307 100644
--- a/libc/sysdeps/linux/e1/bits/fcntl.h
+++ b/libc/sysdeps/linux/metag/bits/fcntl.h
@@ -1,5 +1,6 @@
/* O_*, F_*, FD_* bit values for Linux.
- Copyright (C) 2000 Free Software Foundation, Inc.
+ Copyright (C) 1995-1998, 2000, 2004, 2006, 2007, 2008
+ Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -21,8 +22,11 @@
# 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 */
@@ -42,10 +46,12 @@
#define O_ASYNC 020000
#ifdef __USE_GNU
-# define O_DIRECTORY 040000 /* Must be a directory. */
-# define O_NOFOLLOW 0100000 /* Do not follow links. */
-# define O_DIRECT 0200000 /* Direct disk access. */
-# define O_STREAMING 04000000/* streaming access */
+# define O_DIRECT 040000 /* Direct disk access. */
+# define O_DIRECTORY 0200000 /* Must be a directory. */
+# define O_NOFOLLOW 0400000 /* Do not follow links. */
+# define O_NOATIME 01000000 /* Do not set atime. */
+# define O_CLOEXEC 02000000 /* Set close_on_exec. */
+# define O_PATH 010000000 /* Resolve pathname but do not open file. */
#endif
/* For now Linux has synchronisity options for data and read operations.
@@ -57,7 +63,7 @@
#endif
#ifdef __USE_LARGEFILE64
-# define O_LARGEFILE 0400000
+# define O_LARGEFILE 0100000
#endif
/* Values for the second argument to `fcntl'. */
@@ -79,7 +85,7 @@
#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
+#if defined __USE_BSD || defined __USE_UNIX98
# define F_SETOWN 8 /* Get owner of socket (receiver of SIGIO). */
# define F_GETOWN 9 /* Set owner of socket (receiver of SIGIO). */
#endif
@@ -95,9 +101,11 @@
# define F_NOTIFY 1026 /* Request notfications on a directory. */
# define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with
close-on-exit set on new fd. */
+# define F_SETPIPE_SZ 1031 /* Set pipe page size array. */
+# define F_GETPIPE_SZ 1032 /* Get pipe page size array. */
#endif
-/* For F_[GET|SET]FL. */
+/* For F_[GET|SET]FD. */
#define FD_CLOEXEC 1 /* actually anything with low bit set goes */
/* For posix fcntl() and `l_type' field of a `struct flock' for lockf(). */
@@ -182,7 +190,7 @@ struct flock64
#endif
-#ifdef __USE_GNU
+#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
@@ -205,13 +213,12 @@ struct flock64
__BEGIN_DECLS
-#ifdef __USE_GNU
+#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);
diff --git a/libc/sysdeps/linux/e1/bits/fenv.h b/libc/sysdeps/linux/metag/bits/fenv.h
index beeea3d51..279440504 100644
--- a/libc/sysdeps/linux/e1/bits/fenv.h
+++ b/libc/sysdeps/linux/metag/bits/fenv.h
@@ -1,8 +1,5 @@
-
-/* Copyright (C) 2002-2003, George Thanos <george.thanos@gdt.gr>
- Yannis Mitsos <yannis.mitsos@gdt.gr>
-
- Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 2013 Imagination Technologies Ltd.
+ 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
@@ -24,38 +21,38 @@
#endif
-/* Define bits representing the exception. We use the bit positions of
- the appropriate bits in the SR. */
+/* Define bits representing the exception. We use the bit positions
+ of the appropriate bits in TXDEFR. */
enum
{
- FE_INEXACT = (1 << 8),
+ FE_INEXACT = 0x1,
#define FE_INEXACT FE_INEXACT
- FE_UNDERFLOW = (1 << 9),
+ FE_UNDERFLOW = 0x2,
#define FE_UNDERFLOW FE_UNDERFLOW
- FE_OVERFLOW = (1 << 10),
+ FE_OVERFLOW = 0x4,
#define FE_OVERFLOW FE_OVERFLOW
- FE_DIVBYZERO = (1 << 11),
+ FE_DIVBYZERO = 0x8,
#define FE_DIVBYZERO FE_DIVBYZERO
- FE_INVALID = (1 << 12)
+ FE_INVALID = 0x10,
#define FE_INVALID FE_INVALID
};
#define FE_ALL_EXCEPT \
(FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)
-/* We support all of the four defined rounding modes. We use
- the bit positions in the FPCR Mode Control Byte as the values for the
- appropriate macros. */
+/* The Meta FPU supports all of the four defined rounding modes. We
+ use the values of the rounding mode bits in TXMODE as the values
+ for the appropriate macros. */
enum
{
- FE_TONEAREST = 0,
+ FE_TONEAREST = 0x0,
#define FE_TONEAREST FE_TONEAREST
- FE_TOWARDZERO = 1 << 13 ,
+ FE_TOWARDZERO = 0x1,
#define FE_TOWARDZERO FE_TOWARDZERO
- FE_DOWNWARD = 2 << 13,
-#define FE_DOWNWARD FE_DOWNWARD
- FE_UPWARD = 3 << 13
+ FE_UPWARD = 0x2,
#define FE_UPWARD FE_UPWARD
+ FE_DOWNWARD = 0x3
+#define FE_DOWNWARD FE_DOWNWARD
};
@@ -63,26 +60,18 @@ enum
typedef unsigned int fexcept_t;
-/* Type representing floating-point environment.*/
+/* Type representing floating-point environment. */
typedef struct
-{
- unsigned int round_mode;
- unsigned int trap_enabled;
- unsigned int accrued_except;
- unsigned int actual_except;
-} fenv_t;
+ {
+ unsigned int txdefr;
+ unsigned int txmode;
+ }
+fenv_t;
-#if 0
/* If the default argument is used we use this value. */
-const fenv FE_DFL_ENV_OBJ = {0, 0x1C00, 0}
-#define FE_DFL_ENV (&FE_DFL_ENV_OBJ)
+#define FE_DFL_ENV ((__const fenv_t *) -1)
#ifdef __USE_GNU
-/* Floating-point environment where none of the exceptions are masked. */
-const fenv_t FE_NOMASK_ENV_OBJ = { 0, 0x1F00, 0 };
-# define FE_NOMASK_ENV (&FE_NOMASK_ENV_OBJ)
-#endif
-
+/* Floating-point environment where none of the exception is masked. */
+# define FE_NOMASK_ENV ((__const fenv_t *) -2)
#endif
-
-#include <bits/fenvinline.h>
diff --git a/libc/sysdeps/linux/metag/bits/ipc.h b/libc/sysdeps/linux/metag/bits/ipc.h
new file mode 100644
index 000000000..4852ade32
--- /dev/null
+++ b/libc/sysdeps/linux/metag/bits/ipc.h
@@ -0,0 +1,55 @@
+/* Copyright (C) 1995-1999, 2000, 2005, 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., 51 Franklin Street - Fifth Floor,
+ Boston, MA 02110-1301, USA. */
+
+#ifndef _SYS_IPC_H
+# error "Never use <bits/ipc.h> directly; include <sys/ipc.h> instead."
+#endif
+
+#include <bits/types.h>
+
+/* Mode bits for `msgget', `semget', and `shmget'. */
+#define IPC_CREAT 01000 /* Create key if key does not exist. */
+#define IPC_EXCL 02000 /* Fail if key exists. */
+#define IPC_NOWAIT 04000 /* Return error on wait. */
+
+/* Control commands for `msgctl', `semctl', and `shmctl'. */
+#define IPC_RMID 0 /* Remove identifier. */
+#define IPC_SET 1 /* Set `ipc_perm' options. */
+#define IPC_STAT 2 /* Get `ipc_perm' options. */
+#ifdef __USE_GNU
+# define IPC_INFO 3 /* See ipcs. */
+#endif
+
+/* Special key values. */
+#define IPC_PRIVATE ((__key_t) 0) /* Private key. */
+
+
+/* Data structure used to pass permission information to IPC operations. */
+struct ipc_perm
+ {
+ __key_t __key; /* Key. */
+ __uid_t uid; /* Owner's user ID. */
+ __gid_t gid; /* Owner's group ID. */
+ __uid_t cuid; /* Creator's user ID. */
+ __gid_t cgid; /* Creator's group ID. */
+ unsigned int mode; /* Read/write permission. */
+ unsigned short __seq; /* Sequence number. */
+ unsigned short __pad1;
+ unsigned long __unused1;
+ unsigned long __unused2;
+ };
diff --git a/libc/sysdeps/linux/e1/bits/kernel_types.h b/libc/sysdeps/linux/metag/bits/kernel_types.h
index 8017d8578..08d46a07a 100644
--- a/libc/sysdeps/linux/e1/bits/kernel_types.h
+++ b/libc/sysdeps/linux/metag/bits/kernel_types.h
@@ -3,44 +3,45 @@
* with the posix_types.h kernel header, and will ensure that
* our private content, and not the kernel header, will win.
* -Erik
+ *
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
*/
-#ifndef __ARCH_E1_POSIX_TYPES_H
-#define __ARCH_E1_POSIX_TYPES_H
-typedef unsigned short __kernel_dev_t;
-typedef unsigned long __kernel_ino_t;
-typedef unsigned short __kernel_mode_t;
-typedef unsigned short __kernel_nlink_t;
+#ifndef __ASM_GENERIC_POSIX_TYPES_H
+#define __ASM_GENERIC_POSIX_TYPES_H
+
+typedef unsigned int __kernel_dev_t;
+typedef unsigned int __kernel_ino_t;
+typedef unsigned int __kernel_mode_t;
+typedef unsigned long __kernel_nlink_t;
typedef long __kernel_off_t;
typedef int __kernel_pid_t;
-typedef unsigned short __kernel_ipc_pid_t;
-typedef unsigned short __kernel_uid_t;
-typedef unsigned short __kernel_gid_t;
+typedef unsigned int __kernel_uid_t;
+typedef unsigned int __kernel_gid_t;
typedef unsigned int __kernel_size_t;
typedef int __kernel_ssize_t;
-typedef int __kernel_ptrdiff_t;
+typedef long __kernel_ptrdiff_t;
typedef long __kernel_time_t;
typedef long __kernel_suseconds_t;
typedef long __kernel_clock_t;
typedef int __kernel_daddr_t;
typedef char * __kernel_caddr_t;
+typedef int __kernel_ipc_pid_t;
typedef unsigned short __kernel_uid16_t;
typedef unsigned short __kernel_gid16_t;
typedef unsigned int __kernel_uid32_t;
typedef unsigned int __kernel_gid32_t;
-typedef unsigned short __kernel_old_uid_t;
-typedef unsigned short __kernel_old_gid_t;
+typedef unsigned int __kernel_old_uid_t;
+typedef unsigned int __kernel_old_gid_t;
typedef __kernel_dev_t __kernel_old_dev_t;
typedef long long __kernel_loff_t;
+typedef long __kernel_long_t;
+typedef unsigned long __kernel_ulong_t;
-/*
typedef struct {
-#ifdef __USE_ALL
int val[2];
-#else
- int __val[2];
-#endif
} __kernel_fsid_t;
-*/
-#endif /* __ARCH_E1_POSIX_TYPES_H */
+#endif /* __ASM_GENERIC_POSIX_TYPES_H */
diff --git a/libc/sysdeps/linux/metag/bits/profil-counter.h b/libc/sysdeps/linux/metag/bits/profil-counter.h
new file mode 100644
index 000000000..66ba78141
--- /dev/null
+++ b/libc/sysdeps/linux/metag/bits/profil-counter.h
@@ -0,0 +1,17 @@
+/*
+ * Low-level statistical profiling support function. Linux/Meta version.
+ *
+ * Copyright (C) 2013, Imagination Technologies Ltd.
+ *
+ * Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ *
+ * Based on the SH version from the GNU C Library.
+ */
+
+#include <signal.h>
+
+static void
+profil_counter (int signo, struct sigcontext sc)
+{
+ profil_count (sc.cbuf.ctx.CurrPC);
+}
diff --git a/libc/sysdeps/linux/metag/bits/setjmp.h b/libc/sysdeps/linux/metag/bits/setjmp.h
new file mode 100644
index 000000000..8ad4b12d2
--- /dev/null
+++ b/libc/sysdeps/linux/metag/bits/setjmp.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2013, Imagination Technologies Ltd.
+ *
+ * Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+/* Define the machine-dependent type `jmp_buf' */
+#ifndef _BITS_SETJMP_H
+#define _BITS_SETJMP_H 1
+
+#if !defined _SETJMP_H && !defined _PTHREAD_H
+# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
+#endif
+
+/*
+ jmp_buf[0] - A0StP
+ jmp_buf[1] - A1GbP
+ jmp_buf[2] - A0FrP
+ jmp_buf[3] - A1LbP
+ jmp_buf[4] - D0FrT
+ jmp_buf[5] - D1RtP
+ jmp_buf[6] - D0.5
+ jmp_buf[7] - D1.5
+ jmp_buf[8] - D0.6
+ jmp_buf[9] - D1.6
+ jmp_buf[10] - D0.7
+ jmp_buf[11] - D1.7
+ */
+
+#define _JBLEN 24
+#if defined (__USE_MISC) || defined (_ASM)
+#define JB_SP 0
+#endif
+
+#ifndef _ASM
+typedef int __jmp_buf[_JBLEN] __attribute__((aligned (8)));
+#endif
+
+/* Test if longjmp to JMPBUF would unwind the frame
+ containing a local variable at ADDRESS. */
+#define _JMPBUF_UNWINDS(jmpbuf, address) \
+ ((void *) (address) > (void *) (jmpbuf)[JB_SP])
+
+#endif /* bits/setjmp.h */
diff --git a/libc/sysdeps/linux/metag/bits/sigcontextinfo.h b/libc/sysdeps/linux/metag/bits/sigcontextinfo.h
new file mode 100644
index 000000000..06c566b42
--- /dev/null
+++ b/libc/sysdeps/linux/metag/bits/sigcontextinfo.h
@@ -0,0 +1,14 @@
+/*
+ * Copyright (C) 2013, Imagination Technologies Ltd.
+ *
+ * Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ *
+ */
+
+#define SIGCONTEXT struct sigcontext
+#define SIGCONTEXT_EXTRA_ARGS
+#define GET_PC(ctx) ((void *) ctx.cbuf.ctx.CurrPC)
+#define GET_FRAME(ctx) ((void *) ctx.cbuf.ctx.AX[1].U0)
+#define GET_STACK(ctx) ((void *) ctx.cbuf.ctx.AX[0].U0)
+#define CALL_SIGHANDLER(handler, signo, ctx) \
+ (handler)((signo), SIGCONTEXT_EXTRA_ARGS (ctx))
diff --git a/libc/sysdeps/linux/sh64/bits/stackinfo.h b/libc/sysdeps/linux/metag/bits/stackinfo.h
index e65338f25..55a61219d 100644
--- a/libc/sysdeps/linux/sh64/bits/stackinfo.h
+++ b/libc/sysdeps/linux/metag/bits/stackinfo.h
@@ -22,7 +22,7 @@
#ifndef _STACKINFO_H
#define _STACKINFO_H 1
-/* On SH the stack grows down. */
-#define _STACK_GROWS_DOWN 1
+/* On Meta the stack grows up. */
+#define _STACK_GROWS_UP 1
#endif /* stackinfo.h */
diff --git a/libc/sysdeps/linux/metag/bits/syscalls.h b/libc/sysdeps/linux/metag/bits/syscalls.h
new file mode 100644
index 000000000..7ea09c2c3
--- /dev/null
+++ b/libc/sysdeps/linux/metag/bits/syscalls.h
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2013 Imagination Technologies Ltd.
+ *
+ * Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ *
+ */
+
+#ifndef _BITS_SYSCALLS_H
+#define _BITS_SYSCALLS_H
+#ifndef _SYSCALL_H
+# error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
+#endif
+
+/*
+ Meta version adapted from the ARM version.
+*/
+
+#define SYS_ify(syscall_name) (__NR_##syscall_name)
+
+#ifdef __ASSEMBLER__
+
+/* Call a given syscall, with arguments loaded. */
+#undef DO_CALL
+#define DO_CALL(syscall_name, args) \
+ MOV D1Re0, #SYS_ify (syscall_name); \
+ SWITCH #0x440001
+
+#else
+
+#include <errno.h>
+
+#undef INLINE_SYSCALL_NCS
+#define INLINE_SYSCALL_NCS(name, nr, args...) \
+(__extension__ \
+ ({ unsigned int _inline_sys_result = INTERNAL_SYSCALL_NCS (name, , nr, args); \
+ if (unlikely(INTERNAL_SYSCALL_ERROR_P (_inline_sys_result, ))) \
+ { \
+ __set_errno (INTERNAL_SYSCALL_ERRNO (_inline_sys_result, )); \
+ _inline_sys_result = (unsigned int) -1; \
+ } \
+ (int) _inline_sys_result; }) \
+)
+
+#undef INTERNAL_SYSCALL_DECL
+#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
+
+#undef INTERNAL_SYSCALL_NCS
+#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+(__extension__ \
+ ({unsigned int __sys_result; \
+ { \
+ PREP_ARGS_##nr (args); \
+ register int _result __asm__ ("D0Re0"), _nr __asm__ ("D1Re0"); \
+ LOAD_ARGS_##nr; \
+ _nr = (name); \
+ __asm__ volatile ("SWITCH #0x440001 ! syscall " #name \
+ : "=r" (_result) \
+ : "d" (_nr) ASM_ARGS_##nr \
+ : "memory"); \
+ __sys_result = _result; \
+ } \
+ (int) __sys_result; }) \
+)
+
+#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))
+
+#define PREP_ARGS_0()
+#define PREP_ARGS_1(a1) \
+ int _t1 = (int) (a1); \
+ PREP_ARGS_0 ()
+#define PREP_ARGS_2(a1, a2) \
+ int _t2 = (int) (a2); \
+ PREP_ARGS_1 (a1)
+#define PREP_ARGS_3(a1, a2, a3) \
+ int _t3 = (int) (a3); \
+ PREP_ARGS_2 (a1, a2)
+#define PREP_ARGS_4(a1, a2, a3, a4) \
+ int _t4 = (int) (a4); \
+ PREP_ARGS_3 (a1, a2, a3)
+#define PREP_ARGS_5(a1, a2, a3, a4, a5) \
+ int _t5 = (int) (a5); \
+ PREP_ARGS_4 (a1, a2, a3, a4)
+#define PREP_ARGS_6(a1, a2, a3, a4, a5, a6) \
+ int _t6 = (int) (a6); \
+ PREP_ARGS_5 (a1, a2, a3, a4, a5)
+
+#define LOAD_ARGS_0
+#define ASM_ARGS_0
+#define LOAD_ARGS_1 \
+ register int _a1 __asm__ ("D1Ar1") = (int) (_t1); \
+ LOAD_ARGS_0
+#define ASM_ARGS_1 ASM_ARGS_0, "d" (_a1)
+#define LOAD_ARGS_2 \
+ register int _a2 __asm__ ("D0Ar2") = (int) (_t2); \
+ LOAD_ARGS_1
+#define ASM_ARGS_2 ASM_ARGS_1, "d" (_a2)
+#define LOAD_ARGS_3 \
+ register int _a3 __asm__ ("D1Ar3") = (int) (_t3); \
+ LOAD_ARGS_2
+#define ASM_ARGS_3 ASM_ARGS_2, "d" (_a3)
+#define LOAD_ARGS_4 \
+ register int _a4 __asm__ ("D0Ar4") = (int) (_t4); \
+ LOAD_ARGS_3
+#define ASM_ARGS_4 ASM_ARGS_3, "d" (_a4)
+#define LOAD_ARGS_5 \
+ register int _a5 __asm__ ("D1Ar5") = (int) (_t5); \
+ LOAD_ARGS_4
+#define ASM_ARGS_5 ASM_ARGS_4, "d" (_a5)
+#define LOAD_ARGS_6 \
+ register int _a6 __asm__ ("D0Ar6") = (int) (_t6); \
+ LOAD_ARGS_5
+#define ASM_ARGS_6 ASM_ARGS_5, "d" (_a6)
+
+#endif /* __ASSEMBLER__ */
+#endif /* _BITS_SYSCALLS_H */
diff --git a/libc/sysdeps/linux/v850/bits/uClibc_arch_features.h b/libc/sysdeps/linux/metag/bits/uClibc_arch_features.h
index f4adaf5ad..1433c588c 100644
--- a/libc/sysdeps/linux/v850/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/metag/bits/uClibc_arch_features.h
@@ -1,5 +1,9 @@
/*
* Track misc arch-specific features that aren't config options
+ *
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
*/
#ifndef _BITS_UCLIBC_ARCH_FEATURES_H
@@ -10,29 +14,26 @@
#undef __UCLIBC_ABORT_INSTRUCTION__
/* can your target use syscall6() for mmap ? */
-#undef __UCLIBC_MMAP_HAS_6_ARGS__
+#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 align 64bit values in register pairs ? (32bit arches only) */
+#undef __UCLIBC_SYSCALL_ALIGN_64BIT__
/* 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 IEEE signed zero floats */
#define __UCLIBC_HAVE_SIGNED_ZERO__
diff --git a/libc/sysdeps/linux/i960/bits/wordsize.h b/libc/sysdeps/linux/metag/bits/wordsize.h
index ba643b60a..ba643b60a 100644
--- a/libc/sysdeps/linux/i960/bits/wordsize.h
+++ b/libc/sysdeps/linux/metag/bits/wordsize.h
diff --git a/libc/sysdeps/linux/metag/brk.c b/libc/sysdeps/linux/metag/brk.c
new file mode 100644
index 000000000..355e88fc7
--- /dev/null
+++ b/libc/sysdeps/linux/metag/brk.c
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2013 Imagination Technologies Ltd.
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <errno.h>
+#include <unistd.h>
+#include <sys/syscall.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__ ("MOV D1Re0,%2\n\t"
+ "MOV D1Ar1,%1\n\t"
+ "SWITCH #0x440001\n\t"
+ "MOV %0,D0Re0"
+ : "=r" (newbrk)
+ : "r" (addr), "K" (__NR_brk)
+ : "D0Re0", "D1Re0", "D1Ar1");
+
+ __curbrk = newbrk;
+
+ if (newbrk < addr)
+ {
+ __set_errno (ENOMEM);
+ return -1;
+ }
+
+ return 0;
+}
+libc_hidden_def(brk)
diff --git a/libc/sysdeps/linux/metag/clone.S b/libc/sysdeps/linux/metag/clone.S
new file mode 100644
index 000000000..d9d836338
--- /dev/null
+++ b/libc/sysdeps/linux/metag/clone.S
@@ -0,0 +1,101 @@
+! Copyright (C) 2013 Imagination Technologies Ltd.
+
+! Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+
+! clone() is even more special than fork() as it mucks with stacks
+! and invokes a function in the right context after its all over.
+
+#include <asm/errno.h>
+#include <asm/unistd.h>
+
+#define CLONE_VM 0x00000100
+#define CLONE_THREAD 0x00010000
+
+#ifdef __PIC__
+#define __CLONE_METAG_LOAD_TP ___metag_load_tp@PLT
+#else
+#define __CLONE_METAG_LOAD_TP ___metag_load_tp
+#endif
+
+/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg,
+ pid_t *ptid, struct user_desc *tls, pid_t *ctid); */
+
+ .text
+ .global __clone
+ .type __clone,function
+__clone:
+ ! sanity check args
+ MOV D0Re0, #-EINVAL
+ CMP D1Ar1, #0
+ BEQ ___error
+ CMP D0Ar2, #0
+ BEQ ___error
+
+ ! save function pointer
+ MOV D0FrT, D1Ar1
+
+ ! do the system call
+ MOV D1Ar1, D1Ar3
+ MOV D1Ar3, D1Ar5
+ MOV D1Ar5, D0Ar6
+ MOV D0Ar6, D0Ar4
+ GETD D0Ar4, [A0StP+#-4]
+
+ ! new sp is already in D0Ar2
+ MOV D1Re0, #__NR_clone
+ SWITCH #0x440001
+ CMP D0Re0,#0
+ ! Error on -1
+ BLT ___error
+ ! If non-zero we are the parent
+ MOVNE PC, D1RtP
+ ! BRKPNT
+
+ ! We are the child
+#ifdef RESET_PID
+ SETL [A0StP++], D0FrT, D1RtP
+ MOVT D0FrT, #HI(CLONE_THREAD)
+ ADD D0FrT, D0FrT, #LO(CLONE_THREAD)
+ ANDS D0FrT, D0FrT, D1Ar1
+ BNZ 3f
+ MOVT D0FrT, #HI(CLONE_VM)
+ ADD D0FrT, D0FrT, #LO(CLONE_VM)
+ ANDS D0FrT, D0FrT, D1Ar1
+ BZ 1f
+ MOV D1Ar1, #-1
+ BA 2f
+1: MOV D1Re0, #__NR_getpid
+ SWITCH #0x440001
+ MOV D1Ar1, D0Re0
+2: CALLR D1RtP, __CLONE_METAG_LOAD_TP
+ SUB D0Re0, D0Re0, #TLS_PRE_TCB_SIZE
+ SETD [D0Re0 + #PID], D1Ar1
+ SETD [D0Re0 + #TID], D1Ar1
+3: GETL D0FrT, D1RtP, [--A0StP]
+#endif
+ ! Rearrange the function arg and call address from registers
+ MOV D0Ar2, D0FrT
+ MOV D1Ar1, D0Ar6
+ MOV D1RtP, PC
+ ADD D1RtP, D1RtP, #8
+ MOV PC, D0Ar2
+
+ ! and we are done, passing the return value D0Re0 through D1Ar1
+ MOV D1Ar1, D0Re0
+#ifdef __PIC__
+ B _exit@PLT
+#else
+ B _exit
+#endif
+
+___error:
+ MOV D1Ar1, D0Re0
+#ifdef __PIC__
+ B ___syscall_error@PLT
+#else
+ B ___syscall_error
+#endif
+ .size __clone, .-__clone
+
+.weak _clone
+_clone = __clone
diff --git a/libc/sysdeps/linux/metag/crt1.S b/libc/sysdeps/linux/metag/crt1.S
new file mode 100644
index 000000000..e8561a46b
--- /dev/null
+++ b/libc/sysdeps/linux/metag/crt1.S
@@ -0,0 +1,75 @@
+! Copyright (C) 2013 Imagination Technologies Ltd.
+
+! Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+
+
+#include <asm/unistd.h>
+
+ .text
+ .global __start
+ .type __start,function
+__start:
+ MOV D0FrT,A0StP
+ MOV A0FrP,A0StP
+
+ MOV A0.2,#0
+ MOV A0.3,#0
+
+ MOV A1.1,#0
+ MOV A1.2,#0
+ MOV A1.3,#0
+
+ MOV D0.5,#0
+ MOV D0.6,#0
+ MOV D0.7,#0
+
+ MOV D1.5,#0
+ MOV D1.6,#0
+ MOV D1.7,#0
+
+ MOV D1Ar3,D0Ar2 ! argv
+ MOV D0Ar2,D1Ar1 ! argc
+ MOV D0Ar6,D0Ar4 ! rtld_fini
+
+#ifdef __PIC__
+ ADDT A1LbP,CPC1,#HI(__GLOBAL_OFFSET_TABLE__)
+ ADD A1LbP,A1LbP,#LO(__GLOBAL_OFFSET_TABLE__+4)
+
+ MOV D1Ar1,A1LbP
+ ADDT D1Ar1,D1Ar1,#HI(_main@GOTOFF)
+ ADD D1Ar1,D1Ar1,#LO(_main@GOTOFF)
+
+ MOV D0Ar4,A1LbP
+ ADDT D0Ar4,D0Ar4,#HI(__init@GOTOFF)
+ ADD D0Ar4,D0Ar4,#LO(__init@GOTOFF)
+
+ MOV D1Ar5,A1LbP
+ ADDT D1Ar5,D1Ar5,#HI(__fini@GOTOFF)
+ ADD D1Ar5,D1Ar5,#LO(__fini@GOTOFF)
+#else
+ MOVT D1Ar1,#HI(_main)
+ ADD D1Ar1,D1Ar1,#LO(_main)
+ MOVT D0Ar4,#HI(__init)
+ ADD D0Ar4,D0Ar4,#LO(__init)
+ MOVT D1Ar5,#HI(__fini)
+ ADD D1Ar5,D1Ar5,#LO(__fini)
+#endif
+
+ MOVT D1Re0,#0x80
+
+ SETL [A0StP++],D0Re0,D1Re0 ! stack_end (8Mb)
+
+ MOV D1Re0,#0
+ MOV D0Re0,#0
+
+#ifdef __PIC__
+ CALLR D1RtP, ___uClibc_main@PLT
+#else
+ CALLR D1RtP, ___uClibc_main
+#endif
+
+ MOV D1Re0,#__NR_exit
+ MOV D1Ar1,#0x1
+ SWITCH #0x440001 ! exit syscall
+
+ .size __start,.-__start
diff --git a/libc/sysdeps/linux/metag/crti.S b/libc/sysdeps/linux/metag/crti.S
new file mode 100644
index 000000000..f7fca542d
--- /dev/null
+++ b/libc/sysdeps/linux/metag/crti.S
@@ -0,0 +1,19 @@
+! Copyright (C) 2013 Imagination Technologies Ltd.
+
+! Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+
+ .section .init
+ .global __init
+ .type __init,function
+__init:
+ MOV D0FrT, A0FrP
+ ADD A0FrP, A0StP, #0
+ SETL [A0StP++], D0.4, D1RtP
+
+ .section .fini
+ .global __fini
+ .type __fini,function
+__fini:
+ MOV D0FrT, A0FrP
+ ADD A0FrP, A0StP, #0
+ SETL [A0StP++], D0.4, D1RtP
diff --git a/libc/sysdeps/linux/metag/crtn.S b/libc/sysdeps/linux/metag/crtn.S
new file mode 100644
index 000000000..c885e5373
--- /dev/null
+++ b/libc/sysdeps/linux/metag/crtn.S
@@ -0,0 +1,19 @@
+! Copyright (C) 2013 Imagination Technologies Ltd.
+
+! Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+
+ .section .init
+ .global __init
+ .type __init,function
+ GETL D0.4, D1RtP, [A0FrP+#8++]
+ SUB A0StP, A0FrP, #8
+ MOV A0FrP, D0.4
+ MOV PC, D1RtP
+
+ .section .fini
+ .global __fini
+ .type __fini,function
+ GETL D0.4, D1RtP, [A0FrP+#8++]
+ SUB A0StP, A0FrP, #8
+ MOV A0FrP, D0.4
+ MOV PC, D1RtP
diff --git a/libc/sysdeps/linux/metag/jmpbuf-unwind.h b/libc/sysdeps/linux/metag/jmpbuf-unwind.h
new file mode 100644
index 000000000..175cd7ab0
--- /dev/null
+++ b/libc/sysdeps/linux/metag/jmpbuf-unwind.h
@@ -0,0 +1,22 @@
+/*
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <setjmp.h>
+
+/* Test if longjmp to JMPBUF would unwind the frame
+ containing a local variable at ADDRESS. */
+#undef _JMPBUF_UNWINDS
+#define _JMPBUF_UNWINDS(jmpbuf, address, demangle) \
+ ((void *) (address) > (void *) demangle (jmpbuf[JB_SP]))
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <stdint.h>
+#include <unwind.h>
+
+#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
+ _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
+
+#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
+ ((uintptr_t) (_address) - (_adj) > (uintptr_t) (_jmpbuf)[JB_SP] - (_adj))
+#endif
diff --git a/libc/sysdeps/linux/metag/libc-metag_load_tp.S b/libc/sysdeps/linux/metag/libc-metag_load_tp.S
new file mode 100644
index 000000000..a91f162ec
--- /dev/null
+++ b/libc/sysdeps/linux/metag/libc-metag_load_tp.S
@@ -0,0 +1,7 @@
+/*
+ * Copyright (C) 2013 Imagination Technologies Ltd.
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <ldso/ldso/metag/metag_load_tp.S>
diff --git a/libc/sysdeps/linux/metag/metag.c b/libc/sysdeps/linux/metag/metag.c
new file mode 100644
index 000000000..bf2be68c8
--- /dev/null
+++ b/libc/sysdeps/linux/metag/metag.c
@@ -0,0 +1,11 @@
+/*
+ * Copyright (C) 2013 Imagination Technologies Ltd.
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <errno.h>
+#include <sys/syscall.h>
+
+_syscall2(int,metag_setglobalbit,char *,addr,int,mask)
+_syscall1(void,metag_set_fpu_flags,unsigned int,flags)
diff --git a/libc/sysdeps/linux/metag/setjmp.S b/libc/sysdeps/linux/metag/setjmp.S
new file mode 100644
index 000000000..f00b4a841
--- /dev/null
+++ b/libc/sysdeps/linux/metag/setjmp.S
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2013 Imagination Technologies Ltd.
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+!!! setjmp and variants
+ .text
+
+!! int _setjmp (jmp_buf __env)
+!! Store the calling environment in ENV, not saving the signal mask.
+!! Return 0. */
+ .global __setjmp
+ .type __setjmp,function
+__setjmp:
+ MOV D0Ar2,#0
+ B ___sigsetjmp1
+ .size __setjmp,.-__setjmp
+
+!! int setjmp (jmp_buf __env)
+!! Store the calling environment in ENV, also saving the signal mask.
+!! Return 0. */
+ .global _setjmp
+ .type _setjmp,function
+_setjmp:
+ MOV D0Ar2,#1
+ !! fall through to __sigsetjmp
+ .size _setjmp,.-_setjmp
+
+!! int __sigsetjmp (jmp_buf __env, int __savemask)
+!! Store the calling environment in ENV, also saving the
+!! signal mask if SAVEMASK is nonzero. Return 0.
+!! This is the internal name for `sigsetjmp'.
+ .global ___sigsetjmp
+ .type ___sigsetjmp,function
+___sigsetjmp:
+___sigsetjmp1:
+ !! Save A0/A1 regs
+ MSETL [D1Ar1++],A0.0,A0.1
+ !! Use A0.3 as temp
+ MOV A0.3,D1Ar1
+ !! Rewind D1Ar1 that was modified above
+ SUB D1Ar1,D1Ar1,#(2*8)
+ !! Save D0/D1 regs
+ MSETL [A0.3++],D0FrT,D0.5,D0.6,D0.7
+ !! Tail call __sigjmp_save
+#ifdef __PIC__
+ B ___sigjmp_save@PLT
+#else
+ B ___sigjmp_save
+#endif
+ .size ___sigsetjmp,.-___sigsetjmp
diff --git a/libc/sysdeps/linux/metag/sys/io.h b/libc/sysdeps/linux/metag/sys/io.h
new file mode 100644
index 000000000..6fdc44ff8
--- /dev/null
+++ b/libc/sysdeps/linux/metag/sys/io.h
@@ -0,0 +1,48 @@
+/* Copyright (C) 1996, 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. */
+
+#ifndef _SYS_IO_H
+
+#define _SYS_IO_H 1
+#include <features.h>
+
+__BEGIN_DECLS
+
+/* If TURN_ON is TRUE, request for permission to do direct i/o on the
+ port numbers in the range [FROM,FROM+NUM-1]. Otherwise, turn I/O
+ permission off for that range. This call requires root privileges. */
+extern int ioperm (unsigned long int __from, unsigned long int __num,
+ int __turn_on) __THROW;
+
+/* Set the I/O privilege level to LEVEL. If LEVEL is nonzero,
+ permission to access any I/O port is granted. This call requires
+ root privileges. */
+extern int iopl (int __level) __THROW;
+
+/* The functions that actually perform reads and writes. */
+extern unsigned char inb (unsigned long int port) __THROW;
+extern unsigned short int inw (unsigned long int port) __THROW;
+extern unsigned long int inl (unsigned long int port) __THROW;
+
+extern void outb (unsigned char value, unsigned long int port) __THROW;
+extern void outw (unsigned short value, unsigned long int port) __THROW;
+extern void outl (unsigned long value, unsigned long int port) __THROW;
+
+__END_DECLS
+
+#endif /* _SYS_IO_H */
diff --git a/libc/sysdeps/linux/vax/sys/procfs.h b/libc/sysdeps/linux/metag/sys/procfs.h
index 9c233508f..4a4ca7672 100644
--- a/libc/sysdeps/linux/vax/sys/procfs.h
+++ b/libc/sysdeps/linux/metag/sys/procfs.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 1999, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1999, 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
@@ -13,8 +13,8 @@
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. */
+ Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
+ Boston, MA 02110-1301, USA. */
#ifndef _SYS_PROCFS_H
#define _SYS_PROCFS_H 1
@@ -38,15 +38,13 @@ __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' 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 (sizeof (struct user_regs_struct) / sizeof(elf_greg_t))
+#define ELF_NGREG 30
typedef elf_greg_t elf_gregset_t[ELF_NGREG];
/* Register set for the floating-point registers. */
-typedef struct user_regs_struct elf_fpregset_t;
+#define ELF_NFPREG 18
+typedef unsigned long elf_fpreg_t;
+typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
/* Signal info. */
struct elf_siginfo
diff --git a/libc/sysdeps/linux/i960/sys/ucontext.h b/libc/sysdeps/linux/metag/sys/ucontext.h
index 8c55ea45b..899c20035 100644
--- a/libc/sysdeps/linux/i960/sys/ucontext.h
+++ b/libc/sysdeps/linux/metag/sys/ucontext.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 1999, 2001, 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
@@ -16,57 +16,77 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-/* Don't rely on this, the interface is currently messed up and may need to
- be broken to be fixed. */
+/* Meta ABI compliant context switching support. */
+
#ifndef _SYS_UCONTEXT_H
#define _SYS_UCONTEXT_H 1
#include <features.h>
#include <signal.h>
+#include <sys/procfs.h>
/* We need the signal context definitions even if they are not used
included in <signal.h>. */
#include <bits/sigcontext.h>
-
-/* Type for general register. */
-typedef unsigned long int greg_t;
+typedef int greg_t;
/* Number of general registers. */
-#define NGREG 32 /* 16 global and 16 local */
+#define NGREG 18
/* Container for all general registers. */
-/* gregset_t must be an array. The below declared array corresponds to:
-typedef struct gregset {
- greg_t g_regs[32];
- greg_t g_hi;
- greg_t g_lo;
- greg_t g_pad[3];
-} gregset_t; */
-typedef greg_t gregset_t[NGREG];
-
-/* Container for all FPU registers. */
-typedef struct fpregset {
- /* No floating point registers on most i960 */
-
- /* Otherwise, signal the missing implementation */
-#if defined(__i960SB) || defined(__i960KB)
-#error Floating point support is not yet implemented for the i960 platform.
-#endif
-} fpregset_t;
-
-
-/* Context to describe whole processor state. */
-typedef struct
- {
- gregset_t gregs;
- fpregset_t fpregs;
- } mcontext_t;
+typedef elf_gregset_t gregset_t;
+
+/* Number of each register is the `gregset_t' array. */
+enum
+{
+ R0 = 0,
+#define R0 R0
+ R1 = 1,
+#define R1 R1
+ R2 = 2,
+#define R2 R2
+ R3 = 3,
+#define R3 R3
+ R4 = 4,
+#define R4 R4
+ R5 = 5,
+#define R5 R5
+ R6 = 6,
+#define R6 R6
+ R7 = 7,
+#define R7 R7
+ R8 = 8,
+#define R8 R8
+ R9 = 9,
+#define R9 R9
+ R10 = 10,
+#define R10 R10
+ R11 = 11,
+#define R11 R11
+ R12 = 12,
+#define R12 R12
+ R13 = 13,
+#define R13 R13
+ R14 = 14,
+#define R14 R14
+ R15 = 15
+#define R15 R15
+};
+
+/* Structure to describe FPU registers. */
+typedef elf_fpregset_t fpregset_t;
+
+/* Context to describe whole processor state. This only describes
+ the core registers; coprocessor registers get saved elsewhere
+ (e.g. in uc_regspace, or somewhere unspecified on the stack
+ during non-RT signal handlers). */
+typedef struct sigcontext mcontext_t;
/* Userlevel context. */
typedef struct ucontext
{
- unsigned long int uc_flags;
+ unsigned long uc_flags;
struct ucontext *uc_link;
stack_t uc_stack;
mcontext_t uc_mcontext;
diff --git a/libc/sysdeps/linux/metag/sys/user.h b/libc/sysdeps/linux/metag/sys/user.h
new file mode 100644
index 000000000..3d282d9be
--- /dev/null
+++ b/libc/sysdeps/linux/metag/sys/user.h
@@ -0,0 +1,7 @@
+/*
+ * This file is not needed, but in practice gdb might try to include it.
+ *
+ * Copyright (C) 2013 Imagination Technologies Ltd.
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
diff --git a/libc/sysdeps/linux/metag/syscall.c b/libc/sysdeps/linux/metag/syscall.c
new file mode 100644
index 000000000..93aabf3e0
--- /dev/null
+++ b/libc/sysdeps/linux/metag/syscall.c
@@ -0,0 +1,40 @@
+/* syscall for META/uClibc
+ *
+ * Copyright (C) 2013 Imagination Technologies
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <features.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/syscall.h>
+
+long syscall(long sysnum,
+ long arg1, long arg2, long arg3,
+ long arg4, long arg5, long arg6)
+{
+
+ register long __call __asm__ ("D1Re0") = sysnum;
+ register long __res __asm__ ("D0Re0");
+ register long __a __asm__ ("D1Ar1") = arg1;
+ register long __b __asm__ ("D0Ar2") = arg2;
+ register long __c __asm__ ("D1Ar3") = arg3;
+ register long __d __asm__ ("D0Ar4") = arg4;
+ register long __e __asm__ ("D1Ar5") = arg5;
+ register long __f __asm__ ("D0Ar6") = arg6;
+
+
+ __asm__ __volatile__ ("SWITCH #0x440001"
+ : "=d" (__res)
+ : "d" (__call), "d" (__a), "d" (__b),
+ "d" (__c), "d" (__d), "d" (__e) , "d" (__f)
+ : "memory");
+
+ if(__res >= (unsigned long) -4095) {
+ long err = __res;
+ (*__errno_location()) = (-err);
+ __res = (unsigned long) -1;
+ }
+ return (long) __res;
+}
diff --git a/libc/sysdeps/linux/metag/sysdep.h b/libc/sysdeps/linux/metag/sysdep.h
new file mode 100644
index 000000000..a12f393ce
--- /dev/null
+++ b/libc/sysdeps/linux/metag/sysdep.h
@@ -0,0 +1,59 @@
+/*
+ * Assembler macros for Meta.
+ *
+ * Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <common/sysdep.h>
+
+#include <features.h>
+#include <libc-internal.h>
+
+#ifdef __ASSEMBLER__
+
+#ifdef SHARED
+#define PLTJMP(_x) _x##@PLT
+#else
+#define PLTJMP(_x) _x
+#endif
+
+#undef PSEUDO_END
+#define PSEUDO_END(name) \
+ SYSCALL_ERROR_HANDLER \
+ END (name)
+
+#if defined NOT_IN_libc
+# define SYSCALL_ERROR __local_syscall_error
+# ifdef RTLD_PRIVATE_ERRNO
+# define SYSCALL_ERROR_HANDLER \
+__local_syscall_error: \
+ NEG D0Re0, D0Re0; \
+ ADDT D1Re0, CPC1, #HI(_rtld_errno); \
+ ADD D1Re0, D1Re0, #LO(_rtld_errno) + 4; \
+ SETD [D1Re0], D0Re0; \
+ NEG D0Re0, #0x1; \
+ MOV PC, D1RtP;
+# else
+# define SYSCALL_ERROR_HANDLER \
+__local_syscall_error: \
+ MOV D1Re0, D1RtP; \
+ SETL [A0StP++], D0Re0, D1Re0; \
+ CALLR D1RtP, PLTJMP(___errno_location); \
+ GETD D1Re0, [A0StP+#-8]; \
+ NEG D1Re0, D1Re0; \
+ SETD [D0Re0], D1Re0; \
+ NEG D0Re0, #0x1; \
+ GETD D1RtP, [A0StP+#-4]; \
+ SUB A0StP, A0StP, #0x8; \
+ MOV PC, D1RtP;
+# endif
+#else
+# define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */
+# define SYSCALL_ERROR ___syscall_error
+#endif
+
+#endif /* __ASSEMBLER __*/
+
+/* Pointer mangling is not yet supported for META. */
+#define PTR_MANGLE(var) (void) (var)
+#define PTR_DEMANGLE(var) (void) (var)
diff --git a/libc/sysdeps/linux/metag/vfork.S b/libc/sysdeps/linux/metag/vfork.S
new file mode 100644
index 000000000..8573dedd3
--- /dev/null
+++ b/libc/sysdeps/linux/metag/vfork.S
@@ -0,0 +1,67 @@
+! Copyright (C) 2013 Imagination Technologies Ltd.
+
+! Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+
+#include <asm/unistd.h>
+
+#define _ERRNO_H
+#include <bits/errno.h>
+#include <sys/syscall.h>
+
+#ifndef SAVE_PID
+#define SAVE_PID
+#endif
+
+#ifndef RESTORE_PID
+#define RESTORE_PID
+#endif
+
+#ifdef __NR_vfork
+#define __VFORK_NR __NR_vfork
+#else
+#define __VFORK_NR __NR_fork
+#endif
+
+/* Clone the calling process, but without copying the whole address space.
+ The calling process is suspended until the new process exits or is
+ replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
+ and the process ID of the new process to the old process. */
+
+ .balign 4
+ .global ___vfork
+ .hidden ___vfork
+ .type ___vfork, @function
+___vfork:
+
+ SAVE_PID
+
+ MOV D1Ar1, #0x4111 /* CLONE_VM | CLONE_VFORK | SIGCHLD */
+ MOV D0Ar2, #0
+ MOV D1Ar3, #0
+ MOV D0Ar4, #0
+ MOV D1Ar5, #0
+ MOV D0Ar6, #0
+ MOV D1Re0, #__NR_clone
+ SWITCH #0x440001
+
+ RESTORE_PID
+
+ MOVT D1Re0, #HI(-4096)
+ ADD D1Re0, D1Re0, #LO(-4096)
+ CMP D1Re0, D0Re0
+ BCS error
+
+ /* Syscall worked. Return to child/parent */
+ MOV PC, D1RtP
+
+error:
+ MOV D1Ar1, D0Re0
+#ifdef __PIC__
+ B ___syscall_error@PLT
+#else
+ B ___syscall_error
+#endif
+ .size ___vfork,.-___vfork
+
+weak_alias(__vfork,vfork)
+libc_hidden_weak(vfork)
diff --git a/libc/sysdeps/linux/microblaze/Makefile b/libc/sysdeps/linux/microblaze/Makefile
index a7a832b24..4fa4bb107 100644
--- a/libc/sysdeps/linux/microblaze/Makefile
+++ b/libc/sysdeps/linux/microblaze/Makefile
@@ -1,67 +1,24 @@
# Makefile for uClibc
#
-# Copyright (C) 2001,2002 NEC Corporation
-# Copyright (C) 2001,2002 Miles Bader <miles@gnu.org>
+# Copyright (C) 2000-2003 Erik Andersen <andersen@uclibc.org>
#
-# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-
-TOPDIR=../../../../
-include $(TOPDIR)Rules.mak
-
-#FIXME -- this arch should include its own crti.S and crtn.S
-UCLIBC_CTOR_DTOR=n
-
-CFLAGS += -I..
-ASFLAGS += -I.. -D__ASSEMBLER -DASM_GLOBAL_DIRECTIVE=.globl
-
-TARGET_MACHINE_TYPE=$(shell $(CC) -dumpmachine)
-
-CRT_SRC := crt0.S
-CRT_OBJ := crt0.o crt1.o
-CTOR_TARGETS := $(TOPDIR)lib/crti.o $(TOPDIR)lib/crtn.o
-
-SSRC := setjmp.S __longjmp.S vfork.S
-SOBJ := $(patsubst %.S,%.o, $(SSRC))
-
-CSRC := mmap.c syscall.c clone.c
-COBJ := $(patsubst %.c,%.o, $(CSRC))
-
-OBJS := $(SOBJ) $(COBJ)
-
-OBJ_LIST := ../../../obj.sysdeps.$(TARGET_ARCH)
-
-all: $(OBJ_LIST) $(CTOR_TARGETS)
-
-$(OBJ_LIST): $(OBJS) $(CRT_OBJ)
- $(STRIPTOOL) -x -R .note -R .comment $^
- $(INSTALL) -d $(TOPDIR)lib/
- cp $(CRT_OBJ) $(TOPDIR)lib/
- echo $(patsubst %, sysdeps/linux/$(TARGET_ARCH)/%, $(OBJS)) > $@
-
-$(CRT_OBJ): $(CRT_SRC)
- $(CC) $(ASFLAGS) -DL_$* $< -c -o $*.o
-
-$(SOBJ): %.o : %.S
- $(CC) $(ASFLAGS) -c $< -o $@
-
-$(COBJ): %.o : %.c
- $(CC) $(CFLAGS) -c $< -o $@
-
-ifeq ($(UCLIBC_CTOR_DTOR),y)
-$(TOPDIR)lib/crti.o: crti.S
- $(INSTALL) -d $(TOPDIR)lib/
- $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c $< -o $@
-
-$(TOPDIR)lib/crtn.o: crtn.S
- $(INSTALL) -d $(TOPDIR)lib/
- $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c $< -o $@
-else
-$(CTOR_TARGETS):
- $(INSTALL) -d $(TOPDIR)lib/
- $(AR) $(ARFLAGS) $@
-endif
+# 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, see <http://www.gnu.org/licenses/>.
-headers:
+top_srcdir=../../../../
+top_builddir=../../../../
+all: objs
-clean:
- $(RM) *.o *~ core
+include $(top_builddir)Rules.mak
+include Makefile.arch
+include $(top_srcdir)Makerules
diff --git a/libc/sysdeps/linux/microblaze/Makefile.arch b/libc/sysdeps/linux/microblaze/Makefile.arch
new file mode 100644
index 000000000..8f14fb94f
--- /dev/null
+++ b/libc/sysdeps/linux/microblaze/Makefile.arch
@@ -0,0 +1,12 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2001,2002 NEC Corporation
+# Copyright (C) 2001,2002 Miles Bader <miles@gnu.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+CSRC-y := clone.c fixdfsi.c
+
+SSRC-y := setjmp.S __longjmp.S vfork.S
+
+ARCH_HEADERS := floatlib.h
diff --git a/libc/sysdeps/linux/microblaze/__longjmp.S b/libc/sysdeps/linux/microblaze/__longjmp.S
index fba1e9fbf..c7fce3435 100644
--- a/libc/sysdeps/linux/microblaze/__longjmp.S
+++ b/libc/sysdeps/linux/microblaze/__longjmp.S
@@ -8,38 +8,38 @@
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License. See the file COPYING.LIB in the main
* directory of this archive for more details.
- *
+ *
* Written by Miles Bader <miles@gnu.org>
*/
-#define _SETJMP_H
-#define _ASM
-#include <bits/setjmp.h>
-
-#include <clinkage.h>
+#include <libc-symbols.h>
.text
-C_ENTRY(__longjmp):
- /* load registers from memory to r5 (arg0)*/
+ .globl C_SYMBOL_NAME(__longjmp)
+ .align 4
+C_SYMBOL_NAME(__longjmp):
+ /* load registers from memory to r5 (arg0) */
lwi r1, r5, 0
lwi r15, r5, 4
- lwi r18, r5, 8
- lwi r19, r5, 12
- lwi r20, r5, 16
- lwi r21, r5, 20
- lwi r22, r5, 24
- lwi r23, r5, 28
- lwi r24, r5, 32
- lwi r25, r5, 36
- lwi r26, r5, 40
- lwi r27, r5, 44
- lwi r28, r5, 48
- lwi r29, r5, 52
- lwi r30, r5, 56
-
- addi r3, r0, 1 // return val
- rtsd r15, 8 // normal return
+ lwi r2, r5, 8
+ lwi r13, r5, 12
+ lwi r18, r5, 16
+ lwi r19, r5, 20
+ lwi r20, r5, 24
+ lwi r21, r5, 28
+ lwi r22, r5, 32
+ lwi r23, r5, 36
+ lwi r24, r5, 40
+ lwi r25, r5, 44
+ lwi r26, r5, 48
+ lwi r27, r5, 52
+ lwi r28, r5, 56
+ lwi r29, r5, 60
+ lwi r30, r5, 64
+ lwi r31, r5, 68
+
+ addi r3, r0, 1 /* return val */
+ rtsd r15, 8 /* normal return */
nop
-C_END(__longjmp)
libc_hidden_def(__longjmp)
diff --git a/libc/sysdeps/linux/microblaze/bits/byteswap.h b/libc/sysdeps/linux/microblaze/bits/byteswap.h
deleted file mode 100644
index 9b6a5d722..000000000
--- a/libc/sysdeps/linux/microblaze/bits/byteswap.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * libc/sysdeps/linux/microblaze/bits/byteswap.h -- Macros to swap the order
- * of bytes in integer values
- *
- * Copyright (C) 2001 NEC Corporation
- * Copyright (C) 2001 Miles Bader <miles@gnu.org>
- * Copyright (C) 1997,1998,2001 Free Software Foundation, Inc.
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- */
-
-#if !defined _BYTESWAP_H && !defined _NETINET_IN_H
-# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
-#endif
-
-/* Swap bytes in 16 bit value. */
-#define __bswap_constant_16(x) \
- ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))
-
-# define __bswap_16(x) __bswap_constant_16 (x)
-
-/* Swap bytes in 32 bit value. */
-#define __bswap_constant_32(x) \
- ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
- (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
-
-# define __bswap_32(x) __bswap_constant_32 (x)
-
-#if defined __GNUC__ && __GNUC__ >= 2
-/* Swap bytes in 64 bit value. */
-# define __bswap_64(x) \
- (__extension__ \
- ({ union { unsigned long long int __ll; \
- unsigned long int __l[2]; } __bswap_64_v, __bswap_64_r; \
- __bswap_64_v.__ll = (x); \
- __bswap_64_r.__l[0] = __bswap_32 (__bswap_64_v.__l[1]); \
- __bswap_64_r.__l[1] = __bswap_32 (__bswap_64_v.__l[0]); \
- __bswap_64_r.__ll; }))
-#endif
diff --git a/libc/sysdeps/linux/microblaze/bits/endian.h b/libc/sysdeps/linux/microblaze/bits/endian.h
index 8a4f6efcc..56fcd5dd9 100644
--- a/libc/sysdeps/linux/microblaze/bits/endian.h
+++ b/libc/sysdeps/linux/microblaze/bits/endian.h
@@ -17,4 +17,11 @@
# error "Never use <bits/endian.h> directly; include <endian.h> instead."
#endif
-#define __BYTE_ORDER __BIG_ENDIAN
+/* Note: Toolchain supplies _BIG_ENDIAN or _LITTLE_ENDIAN */
+#if defined(_BIG_ENDIAN)
+# define __BYTE_ORDER __BIG_ENDIAN
+#elif defined(_LITTLE_ENDIAN)
+# define __BYTE_ORDER __LITTLE_ENDIAN
+#else
+# error "Endianness is unknown"
+#endif
diff --git a/libc/sysdeps/linux/microblaze/bits/fcntl.h b/libc/sysdeps/linux/microblaze/bits/fcntl.h
index 87d193923..ee300a293 100644
--- a/libc/sysdeps/linux/microblaze/bits/fcntl.h
+++ b/libc/sysdeps/linux/microblaze/bits/fcntl.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FCNTL_H
# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
@@ -23,6 +22,9 @@
#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 */
@@ -42,10 +44,12 @@
#define O_ASYNC 020000
#ifdef __USE_GNU
-# define O_DIRECTORY 040000 /* Must be a directory. */
-# define O_NOFOLLOW 0100000 /* Do not follow links. */
-# define O_DIRECT 0200000 /* Direct disk access. */
-# define O_STREAMING 04000000/* streaming access */
+# define O_DIRECTORY 0200000 /* Must be a directory. */
+# define O_NOFOLLOW 0400000 /* Do not follow links. */
+# define O_DIRECT 040000 /* Direct disk access. */
+# define O_NOATIME 01000000 /* Do not set atime. */
+# define O_CLOEXEC 02000000 /* set close_on_exec */
+# define O_PATH 010000000 /* Resolve pathname but do not open file. */
#endif
/* For now Linux has synchronisity options for data and read operations.
@@ -57,7 +61,7 @@
#endif
#ifdef __USE_LARGEFILE64
-# define O_LARGEFILE 0400000
+# define O_LARGEFILE 0100000
#endif
/* Values for the second argument to `fcntl'. */
@@ -95,6 +99,8 @@
# define F_NOTIFY 1026 /* Request notfications on a directory. */
# define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with
close-on-exit set on new fd. */
+# define F_SETPIPE_SZ 1031 /* Set pipe page size array. */
+# define F_GETPIPE_SZ 1032 /* Get pipe page size array. */
#endif
/* For F_[GET|SET]FL. */
@@ -182,7 +188,7 @@ struct flock64
#endif
-#ifdef __USE_GNU
+#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
@@ -205,7 +211,7 @@ struct flock64
__BEGIN_DECLS
-#ifdef __USE_GNU
+#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)
diff --git a/libc/sysdeps/linux/microblaze/bits/kernel_stat.h b/libc/sysdeps/linux/microblaze/bits/kernel_stat.h
index 248345e8b..c2695098d 100644
--- a/libc/sysdeps/linux/microblaze/bits/kernel_stat.h
+++ b/libc/sysdeps/linux/microblaze/bits/kernel_stat.h
@@ -3,64 +3,46 @@
#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;
- __kernel_ino_t st_ino;
- __kernel_mode_t st_mode;
- __kernel_nlink_t st_nlink;
- __kernel_uid_t st_uid;
- __kernel_gid_t st_gid;
- __kernel_dev_t st_rdev;
- __kernel_off_t st_size;
- unsigned long st_blksize;
- unsigned long st_blocks;
- unsigned long st_atime;
- unsigned long __unused1;
- unsigned long st_mtime;
- unsigned long __unused2;
- unsigned long st_ctime;
- unsigned long __unused3;
- unsigned long __unused4;
- unsigned long __unused5;
+ 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
{
- __kernel_dev_t st_dev;
- unsigned long __unused0;
- unsigned long __unused1;
-
- __kernel_ino64_t st_ino;
-
- __kernel_mode_t st_mode;
- __kernel_nlink_t st_nlink;
-
- __kernel_uid_t st_uid;
- __kernel_gid_t st_gid;
-
- __kernel_dev_t st_rdev;
- unsigned long __unused2;
- unsigned long __unused3;
-
- __kernel_loff_t st_size;
- unsigned long st_blksize;
-
- unsigned long __unused4; /* future possible st_blocks high bits */
- unsigned long st_blocks; /* Number 512-byte blocks allocated. */
-
- unsigned long st_atime;
- unsigned long __unused5;
-
- unsigned long st_mtime;
- unsigned long __unused6;
-
- unsigned long st_ctime;
- unsigned long __unused7; /* high 32 bits of ctime someday */
+ 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/microblaze/bits/kernel_types.h b/libc/sysdeps/linux/microblaze/bits/kernel_types.h
index 1ca2dae30..a9f736b2e 100644
--- a/libc/sysdeps/linux/microblaze/bits/kernel_types.h
+++ b/libc/sysdeps/linux/microblaze/bits/kernel_types.h
@@ -13,18 +13,17 @@
* Microblaze port by John Williams
*/
-#ifndef __MICROBLAZE_POSIX_TYPES_H__
-#define __MICROBLAZE_POSIX_TYPES_H__
+#ifndef _ASM_MICROBLAZE_POSIX_TYPES_H
+#define _ASM_MICROBLAZE_POSIX_TYPES_H
-typedef unsigned int __kernel_dev_t;
+typedef unsigned long __kernel_dev_t;
typedef unsigned long __kernel_ino_t;
-typedef unsigned long long __kernel_ino64_t;
-typedef unsigned int __kernel_mode_t;
-typedef unsigned int __kernel_nlink_t;
+//typedef unsigned long long __kernel_ino64_t;
+typedef unsigned short __kernel_mode_t;
+typedef unsigned long __kernel_nlink_t;
typedef long __kernel_off_t;
-typedef long long __kernel_loff_t;
typedef int __kernel_pid_t;
-typedef unsigned short __kernel_ipc_pid_t;
+typedef int __kernel_ipc_pid_t;
typedef unsigned int __kernel_uid_t;
typedef unsigned int __kernel_gid_t;
typedef unsigned int __kernel_size_t;
@@ -33,6 +32,8 @@ typedef int __kernel_ptrdiff_t;
typedef long __kernel_time_t;
typedef long __kernel_suseconds_t;
typedef long __kernel_clock_t;
+typedef int __kernel_timer_t;
+typedef int __kernel_clockid_t;
typedef int __kernel_daddr_t;
typedef char * __kernel_caddr_t;
typedef unsigned short __kernel_uid16_t;
@@ -40,9 +41,15 @@ typedef unsigned short __kernel_gid16_t;
typedef unsigned int __kernel_uid32_t;
typedef unsigned int __kernel_gid32_t;
-typedef unsigned short __kernel_old_uid_t;
-typedef unsigned short __kernel_old_gid_t;
-typedef __kernel_dev_t __kernel_old_dev_t;
+typedef unsigned int __kernel_old_uid_t;
+typedef unsigned int __kernel_old_gid_t;
+typedef unsigned int __kernel_old_dev_t;
+typedef long __kernel_long_t;
+typedef unsigned long __kernel_ulong_t;
+
+#ifdef __GNUC__
+typedef long long __kernel_loff_t;
+#endif
typedef struct {
#ifdef __USE_ALL
@@ -52,4 +59,4 @@ typedef struct {
#endif
} __kernel_fsid_t;
-#endif /* __MICROBLAZE_POSIX_TYPES_H__ */
+#endif /* _ASM_MICROBLAZE_POSIX_TYPES_H */
diff --git a/libc/sysdeps/linux/microblaze/bits/mman.h b/libc/sysdeps/linux/microblaze/bits/mman.h
deleted file mode 100644
index d051c8fa7..000000000
--- a/libc/sysdeps/linux/microblaze/bits/mman.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* Definitions for POSIX memory map interface. Linux/microblaze version.
- Copyright (C) 1997, 1999, 2001, 2002 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- 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. */
-
-/* These are the bits used by 4.4 BSD and its derivatives. On systems
- (such as GNU) where these facilities are not system services but can be
- emulated in the C library, these are the definitions we emulate. */
-
-#ifndef _SYS_MMAN_H
-# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
-#endif
-
-/* The following definitions basically come from the kernel headers.
- But the kernel header is not namespace clean. */
-
-
-/* Protections are chosen from these bits, OR'd together. The
- implementation does not necessarily support PROT_EXEC or PROT_WRITE
- without PROT_READ. The only guarantees are that no writing will be
- allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
-
-#define PROT_READ 0x1 /* Page can be read. */
-#define PROT_WRITE 0x2 /* Page can be written. */
-#define PROT_EXEC 0x4 /* Page can be executed. */
-#define PROT_NONE 0x0 /* Page can not be accessed. */
-
-/* Sharing types (must choose one and only one of these). */
-#define MAP_SHARED 0x01 /* Share changes. */
-#define MAP_PRIVATE 0x02 /* Changes are private. */
-#ifdef __USE_MISC
-# define MAP_TYPE 0x0f /* Mask for type of mapping. */
-#endif
-
-/* Other flags. */
-#define MAP_FIXED 0x10 /* Interpret addr exactly. */
-#ifdef __USE_MISC
-# define MAP_FILE 0
-# define MAP_ANONYMOUS 0x20 /* Don't use a file. */
-# define MAP_ANON MAP_ANONYMOUS
-#endif
-
-/* These are Linux-specific. */
-#ifdef __USE_MISC
-# define MAP_GROWSDOWN 0x0100 /* Stack-like segment. */
-# define MAP_DENYWRITE 0x0800 /* ETXTBSY */
-# define MAP_EXECUTABLE 0x1000 /* Mark it as an executable. */
-# define MAP_LOCKED 0x2000 /* Lock the mapping. */
-# define MAP_NORESERVE 0x4000 /* Don't check for reservations. */
-#endif
-
-/* Flags to `msync'. */
-#define MS_ASYNC 1 /* Sync memory asynchronously. */
-#define MS_SYNC 4 /* Synchronous memory sync. */
-#define MS_INVALIDATE 2 /* Invalidate the caches. */
-
-/* Advice to `madvise'. */
-#ifdef __USE_BSD
-# define MADV_NORMAL 0 /* No further special treatment. */
-# define MADV_RANDOM 1 /* Expect random page references. */
-# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
-# define MADV_WILLNEED 3 /* Will need these pages. */
-# define MADV_DONTNEED 4 /* Don't need these pages. */
-#endif
-
-/* The POSIX people had to invent similar names for the same things. */
-#ifdef __USE_XOPEN2K
-# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
-# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
-# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
-# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
-# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
-#endif
-
-
-/* Flags for `mlockall' (can be OR'd together). */
-#define MCL_CURRENT 1 /* Lock all currently mapped pages. */
-#define MCL_FUTURE 2 /* Lock all additions to address
- space. */
-
-/* Flags for `mremap'. */
-#ifdef __USE_GNU
-# define MREMAP_MAYMOVE 1
-# define MREMAP_FIXED 2
-#endif
diff --git a/libc/sysdeps/linux/microblaze/bits/poll.h b/libc/sysdeps/linux/microblaze/bits/poll.h
index f7a739315..9b284c857 100644
--- a/libc/sysdeps/linux/microblaze/bits/poll.h
+++ b/libc/sysdeps/linux/microblaze/bits/poll.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_POLL_H
# error "Never use <bits/poll.h> directly; include <sys/poll.h> instead."
@@ -29,10 +28,10 @@
#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. */
+# define POLLRDNORM 0x0040 /* Normal data may be read. */
+# define POLLRDBAND 0x0080 /* Priority data may be read. */
+# define POLLWRNORM 0x0100 /* Writing now will not block. */
+# define POLLWRBAND 0x0200 /* Priority data may be written. */
#endif
/* Event types always implicitly polled for. These bits need not be set in
diff --git a/libc/sysdeps/linux/microblaze/bits/select.h b/libc/sysdeps/linux/microblaze/bits/select.h
deleted file mode 100644
index 7c787b324..000000000
--- a/libc/sysdeps/linux/microblaze/bits/select.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * include/bits/select.h -- fd_set operations
- *
- * Copyright (C) 2003 John Williams <jwilliams@itee.uq.edu.au>
- * Copyright (C) 2001 NEC Corporation
- * Copyright (C) 2001 Miles Bader <miles@gnu.org>
- * Copyright (C) 1997, 1998 Free Software Foundation, Inc.
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- */
-
-#ifndef _SYS_SELECT_H
-# error "Never use <bits/select.h> directly; include <sys/select.h> instead."
-#endif
-
-#ifdef __GNUC__
-
-/* We don't use `memset' because this would require a prototype and
- the array isn't too big. */
-#define __FD_ZERO(s) \
- do { \
- unsigned int __i; \
- fd_set *__arr = (s); \
- for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) \
- __FDS_BITS (__arr)[__i] = 0; \
- } while (0)
-
-#define __FD_SET(fd, s) \
- do { \
- int __fd = (fd); \
- unsigned int *__addr = (unsigned int *)&__FDS_BITS (s); \
- *__addr |= (1 << __fd); \
- } while (0)
-
-#define __FD_CLR(fd, s) \
- do { \
- int __fd = (fd); \
- unsigned int *__addr = (unsigned int *)&__FDS_BITS (s); \
- *__addr &= ~(1 << __fd); \
- } while (0)
-
-#define __FD_ISSET(fd, s) \
- ({ \
- int __fd = (fd); \
- unsigned int *__addr = (unsigned int *)&__FDS_BITS (s); \
- int res; \
- res = (*__addr & (1 << fd)) ? 1 : 0; \
- })
-
-#else /* !__GNUC__ */
-
-#define __FD_SET(d, s) (__FDS_BITS (s)[__FDELT(d)] |= __FDMASK(d))
-#define __FD_CLR(d, s) (__FDS_BITS (s)[__FDELT(d)] &= ~__FDMASK(d))
-#define __FD_ISSET(d, s) ((__FDS_BITS (s)[__FDELT(d)] & __FDMASK(d)) != 0)
-
-#endif /* __GNUC__ */
diff --git a/libc/sysdeps/linux/microblaze/bits/setjmp.h b/libc/sysdeps/linux/microblaze/bits/setjmp.h
index d966efd2b..b384878de 100644
--- a/libc/sysdeps/linux/microblaze/bits/setjmp.h
+++ b/libc/sysdeps/linux/microblaze/bits/setjmp.h
@@ -19,7 +19,6 @@
# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
#endif
-#ifndef _ASM
typedef struct
{
/* Stack pointer. */
@@ -28,16 +27,12 @@ typedef struct
/* Link pointer. */
void *__lp;
- /* Callee-saved registers r18-r30. */
- int __regs[13];
- } __jmp_buf[1];
-#endif
+ /* SDA pointers */
+ void *__SDA;
+ void *__SDA2;
-#define JB_SIZE (4 * 15)
-
-/* Test if longjmp to JMPBUF would unwind the frame
- containing a local variable at ADDRESS. */
-#define _JMPBUF_UNWINDS(jmpbuf, address) \
- ((void *) (address) < (void *) (jmpbuf)[0].__sp)
+ /* Callee-saved registers r18-r31. */
+ int __regs[14];
+ } __jmp_buf[1];
#endif /* bits/setjmp.h */
diff --git a/libc/sysdeps/linux/microblaze/bits/stackinfo.h b/libc/sysdeps/linux/microblaze/bits/stackinfo.h
new file mode 100644
index 000000000..f45982e8d
--- /dev/null
+++ b/libc/sysdeps/linux/microblaze/bits/stackinfo.h
@@ -0,0 +1,27 @@
+/* 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, see
+ <http://www.gnu.org/licenses/>. */
+
+/* This file contains a bit of information about the stack allocation
+ of the processor. */
+
+#ifndef _STACKINFO_H
+#define _STACKINFO_H 1
+
+/* On microblaze the stack grows down. */
+#define _STACK_GROWS_DOWN 1
+
+#endif /* stackinfo.h */
diff --git a/libc/sysdeps/linux/microblaze/bits/syscalls.h b/libc/sysdeps/linux/microblaze/bits/syscalls.h
index b21851333..535502b86 100644
--- a/libc/sysdeps/linux/microblaze/bits/syscalls.h
+++ b/libc/sysdeps/linux/microblaze/bits/syscalls.h
@@ -4,12 +4,55 @@
# error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
#endif
-#include <features.h>
-/* Do something very evil for now. Until we create our own syscall
- * macros, short circuit bits/sysnum.h and use asm/unistd.h instead */
-#warning "fixme -- add arch specific syscall macros.h"
-#include <asm/unistd.h>
+#ifndef __ASSEMBLER__
-#endif /* _BITS_SYSCALLS_H */
+#include <errno.h>
+
+#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+(__extension__ \
+ ({ \
+ register int __ret __asm__("r3"); \
+ register int _scno __asm__("r12") = name; \
+ LOAD_ARGS_##nr (args); \
+ __asm__ __volatile__("brki r14, 0x8" \
+ : "=r" (__ret) \
+ : "r"(_scno) ASM_ARGS_##nr \
+ : __SYSCALL_CLOBBERS ); \
+ __ret; \
+ }) \
+)
+#define INTERNAL_SYSCALL_ERROR_P(val, err) \
+ ((unsigned int)(val) >= 0xfffff001U)
+
+#define LOAD_ARGS_0() do { } while(0)
+#define ASM_ARGS_0
+#define LOAD_ARGS_1(a1) \
+ register int _a1 __asm__("r5") = (int)(a1); \
+ LOAD_ARGS_0()
+#define ASM_ARGS_1 ASM_ARGS_0, "r"(_a1)
+#define LOAD_ARGS_2(a1, a2) \
+ register int _a2 __asm__("r6") = (int)(a2); \
+ LOAD_ARGS_1(a1)
+#define ASM_ARGS_2 ASM_ARGS_1, "r"(_a2)
+#define LOAD_ARGS_3(a1, a2, a3) \
+ register int _a3 __asm__("r7") = (int)(a3); \
+ LOAD_ARGS_2(a1, a2)
+#define ASM_ARGS_3 ASM_ARGS_2, "r"(_a3)
+#define LOAD_ARGS_4(a1, a2, a3, a4) \
+ register int _a4 __asm__("r8") = (int)(a4); \
+ LOAD_ARGS_3(a1, a2, a3)
+#define ASM_ARGS_4 ASM_ARGS_3, "r"(_a4)
+#define LOAD_ARGS_5(a1, a2, a3, a4, a5) \
+ register int _a5 __asm__("r9") = (int)(a5); \
+ LOAD_ARGS_4(a1, a2, a3, a4)
+#define ASM_ARGS_5 ASM_ARGS_4, "r"(_a5)
+#define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6) \
+ register int _a6 __asm__("r10") = (int)(a6); \
+ LOAD_ARGS_5(a1, a2, a3, a4, a5)
+#define ASM_ARGS_6 ASM_ARGS_5, "r"(_a6)
+#define __SYSCALL_CLOBBERS "r4", "r14", "cc", "memory"
+
+#endif /* __ASSEMBLER__ */
+#endif /* _BITS_SYSCALLS_H */
diff --git a/libc/sysdeps/linux/microblaze/bits/uClibc_arch_features.h b/libc/sysdeps/linux/microblaze/bits/uClibc_arch_features.h
index f4adaf5ad..ea767abbf 100644
--- a/libc/sysdeps/linux/microblaze/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/microblaze/bits/uClibc_arch_features.h
@@ -10,19 +10,19 @@
#undef __UCLIBC_ABORT_INSTRUCTION__
/* can your target use syscall6() for mmap ? */
-#undef __UCLIBC_MMAP_HAS_6_ARGS__
+#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 align 64bit values in register pairs ? (32bit arches only) */
+#undef __UCLIBC_SYSCALL_ALIGN_64BIT__
/* does your target have a broken create_module() ? */
#undef __UCLIBC_BROKEN_CREATE_MODULE__
-/* does your target have an asm .set ? */
-#define __UCLIBC_HAVE_ASM_SET_DIRECTIVE__
+/* does your target have to worry about older [gs]etrlimit() ? */
+#undef __UCLIBC_HANDLE_OLDER_RLIMIT__
-/* define if target doesn't like .global */
-#undef __UCLIBC_ASM_GLOBAL_DIRECTIVE__
+/* does your target have an asm .set ? */
+#undef __UCLIBC_HAVE_ASM_SET_DIRECTIVE__
/* define if target supports .weak */
#define __UCLIBC_HAVE_ASM_WEAK_DIRECTIVE__
@@ -30,10 +30,13 @@
/* 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 */
+#undef __UCLIBC_ASM_LINE_SEP__
+
#endif /* _BITS_UCLIBC_ARCH_FEATURES_H */
diff --git a/libc/sysdeps/linux/microblaze/bits/uClibc_page.h b/libc/sysdeps/linux/microblaze/bits/uClibc_page.h
new file mode 100644
index 000000000..580ca1368
--- /dev/null
+++ b/libc/sysdeps/linux/microblaze/bits/uClibc_page.h
@@ -0,0 +1,27 @@
+/* Copyright (C) 2004 Erik Andersen
+ *
+ * This 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.
+ *
+ * This 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 this library; if not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+/* Supply an architecture specific value for PAGE_SIZE and friends. */
+
+#ifndef _UCLIBC_PAGE_H
+#define _UCLIBC_PAGE_H
+
+#define PAGE_SHIFT 12
+#define PAGE_SIZE (1UL << PAGE_SHIFT)
+#define PAGE_MASK (~(PAGE_SIZE-1))
+
+#endif /* _UCLIBC_PAGE_H */
diff --git a/libc/sysdeps/linux/microblaze/bits/wordsize.h b/libc/sysdeps/linux/microblaze/bits/wordsize.h
index ba643b60a..ca82fd7d4 100644
--- a/libc/sysdeps/linux/microblaze/bits/wordsize.h
+++ b/libc/sysdeps/linux/microblaze/bits/wordsize.h
@@ -12,8 +12,7 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#define __WORDSIZE 32
diff --git a/libc/sysdeps/linux/microblaze/clinkage.h b/libc/sysdeps/linux/microblaze/clinkage.h
deleted file mode 100644
index a9beffc96..000000000
--- a/libc/sysdeps/linux/microblaze/clinkage.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * libc/sysdeps/linux/microblaze/clinkage.h -- Macros for C symbols in assembler
- *
- * Copyright (C) 2003 John Williams <jwilliams@itee.uq.edu.au>
- * Copyright (C) 2001 NEC Corporation
- * Copyright (C) 2001 Miles Bader <miles@gnu.org>
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- *
- * Written by Miles Bader <miles@gnu.org>
- */
-
-#include <asm/clinkage.h>
diff --git a/libc/sysdeps/linux/microblaze/clone.c b/libc/sysdeps/linux/microblaze/clone.c
index a47ee8c68..d92100865 100644
--- a/libc/sysdeps/linux/microblaze/clone.c
+++ b/libc/sysdeps/linux/microblaze/clone.c
@@ -1,52 +1,47 @@
/*
- * libc/sysdeps/linux/microblaze/clone.c -- `clone' syscall for linux/microblaze
+ * Copyright (C) 2004 Atmel Corporation
*
- * Copyright (C) 2003 John Williams <jwilliams@itee.uq.edu.au>
- * Copyright (C) 2002,03 NEC Electronics Corporation
- * Copyright (C) 2002,03 Miles Bader <miles@gnu.org>
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- *
- * Written by Miles Bader <miles@gnu.org>
- * Microblaze port by John Williams
+ * This file is subject to the terms and conditions of the GNU Lesser General
+ * Public License. See the file "COPYING.LIB" in the main directory of this
+ * archive for more details.
*/
-
+#include <sched.h>
#include <errno.h>
#include <sys/syscall.h>
+#include <unistd.h>
-int
-clone (int (*fn)(void *arg), void *child_stack, int flags, void *arg)
+int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg, ...)
{
- register unsigned long rval __asm__ (SYSCALL_RET) = -EINVAL;
+ int rval = -EINVAL;
+ if (fn && child_stack)
+ rval = INTERNAL_SYSCALL(clone, 0, 2, flags, child_stack);
+
+ if (rval == 0)
+ {
+ int exitCode = fn(arg);
+ rval = INTERNAL_SYSCALL(exit, 0, 1, exitCode);
+ }
- if (fn && child_stack)
- {
- register unsigned long syscall __asm__ (SYSCALL_NUM);
- register unsigned long arg0 __asm__ (SYSCALL_ARG0);
- register unsigned long arg1 __asm__ (SYSCALL_ARG1);
+ return rval;
+}
- /* Clone this thread. */
- arg0 = flags;
- arg1 = (unsigned long)child_stack;
- syscall = __NR_clone;
- __asm__ __volatile__ ("bralid r17, trap;nop;"
- : "=r" (rval), "=r" (syscall)
- : "1" (syscall), "r" (arg0), "r" (arg1)
- : SYSCALL_CLOBBERS);
+#ifdef __NR_clone2
+int
+__clone2(int (*fn)(void *arg), void *child_stack, size_t stack_size,
+ int flags, void *arg, ...)
+{
+ int rval = -EINVAL;
+ if (fn && child_stack)
+ {
+ rval = INTERNAL_SYSCALL(clone2, 0, 3, flags, child_stack, stack_size);
+ }
- if (rval == 0)
- /* In child thread, call FN and exit. */
+ if (rval == 0)
{
- arg0 = (*fn) (arg);
- syscall = __NR_exit;
- __asm__ __volatile__ ("bralid r17, trap;nop;"
- : "=r" (rval), "=r" (syscall)
- : "1" (syscall), "r" (arg0)
- : SYSCALL_CLOBBERS);
+ int exitCode = fn(arg);
+ rval = INTERNAL_SYSCALL(exit, 0, 1, exitCode);
}
- }
- __syscall_return (int, rval);
+ return rval;
}
+#endif
diff --git a/libc/sysdeps/linux/microblaze/crt0.S b/libc/sysdeps/linux/microblaze/crt0.S
index 99687b707..6be1e4dfa 100644
--- a/libc/sysdeps/linux/microblaze/crt0.S
+++ b/libc/sysdeps/linux/microblaze/crt0.S
@@ -20,22 +20,18 @@
.text
C_ENTRY(_start):
- lw r5, r0, r1 // Arg 0: argc
+ lw r5, r0, r1 /* Arg 0: argc */
- addi r6, r1, 4 // Arg 1: argv
+ addi r6, r1, 4 /* Arg 1: argv */
- // Arg 2: envp
- addi r3, r5, 1 // skip argc elements to get envp start
- // ...plus the NULL at the end of argv
- add r3, r3, r3 // Make word offset
+ /* Arg 2: envp */
+ addi r3, r5, 1 /* skip argc elements to get envp start */
+ /* ...plus the NULL at the end of argv */
+ add r3, r3, r3 /* Make word offset */
add r3, r3, r3
- add r7, r6, r3 // add to argv to get offset
+ add r7, r6, r3 /* add to argv to get offset */
- // Load SDAs
- la r2, r0, C_SYMBOL_NAME(_SDA_BASE_)
- la r13, r0, C_SYMBOL_NAME(_SDA2_BASE_)
-
- // tail-call uclibc's startup routine
+ /* tail-call uclibc's startup routine */
brid C_SYMBOL_NAME(__uClibc_main)
nop
diff --git a/libc/sysdeps/linux/microblaze/crt1.S b/libc/sysdeps/linux/microblaze/crt1.S
new file mode 100644
index 000000000..7bf8f64c1
--- /dev/null
+++ b/libc/sysdeps/linux/microblaze/crt1.S
@@ -0,0 +1,57 @@
+/*
+ * libc/sysdeps/linux/microblaze/crt1.S -- Initial program entry point for linux/microblaze
+ *
+ * Copyright (C) 2009 Meyer Sound Laboratories
+ * Copyright (C) 2003 John Williams <jwilliams@itee.uq.edu.au>
+ * Copyright (C) 2001,2002 NEC Corporation
+ * Copyright (C) 2001,2002 Miles Bader <miles@gnu.org>
+ *
+ * This file is subject to the terms and conditions of the GNU Lesser
+ * General Public License. See the file COPYING.LIB in the main
+ * directory of this archive for more details.
+ *
+ * Written by Miles Bader <miles@gnu.org>
+ */
+
+#include <libc-symbols.h>
+
+/* Upon entry, the stack contains the following data:
+ argc, argv[0], ..., argv[argc-1], 0, envp[0], ..., 0
+*/
+
+ .text
+ .globl C_SYMBOL_NAME(_start)
+ .align 4
+C_SYMBOL_NAME(_start):
+
+ /*
+ Preparing arguments for uClibc's startup routine.
+ The routine has 6 arguments, so 5 of them are placed
+ into registers, one on the stack
+ */
+
+ la r5, r0, C_SYMBOL_NAME(main) /* Arg 1: main() */
+ lw r6, r0, r1 /* Arg 2: argc */
+ addi r7, r1, 4 /* Arg 3: argv */
+ la r8, r0, _init /* Arg 4: init */
+ la r9, r0, _fini /* Arg 5: fini */
+ addk r10,r0,r0 /* Arg 6: rtld_fini = NULL */
+
+
+ /* Reserve space for __uClibc_main to save parameters
+ (Microblaze ABI stack calling convention)
+ and for stack_end argument to __uClibc_main */
+ add r3, r1, r0
+ addi r1, r1, -32
+
+ /* tail-call uClibc's startup routine */
+ brid C_SYMBOL_NAME(__uClibc_main)
+ swi r3, r1, 28 /* Arg 7: stack end [DELAY SLOT] */
+
+/* Define a symbol for the first piece of initialized data. */
+ .data
+ .globl __data_start
+__data_start:
+ .long 0
+ .weak data_start
+ data_start = __data_start
diff --git a/libc/sysdeps/linux/microblaze/crti.S b/libc/sysdeps/linux/microblaze/crti.S
new file mode 100644
index 000000000..e00396897
--- /dev/null
+++ b/libc/sysdeps/linux/microblaze/crti.S
@@ -0,0 +1,41 @@
+/*
+ * libc/sysdeps/linux/microblaze/crti.S -- init/fini entry code for microblaze
+ * (baselined with gcc 4.1.2)
+ *
+ * Copyright (C) 2010 Digital Design Corporation
+ *
+ * This file is subject to the terms and conditions of the GNU Lesser
+ * General Public License. See the file COPYING.LIB in the main
+ * directory of this archive for more details.
+ */
+
+#define END_INIT
+#define END_FINI
+#define ALIGN
+#include <libc-symbols.h>
+
+/*@HEADER_ENDS*/
+
+ .section .init
+ .align 2
+ .globl _init
+_init:
+ addik r1, r1, -32
+ swi r19, r1, 28
+ addk r19, r1, r0
+ swi r15, r1, 0
+
+ ALIGN
+ END_INIT
+
+ .section .fini
+ .align 2
+ .globl _fini
+_fini:
+ addik r1, r1, -32
+ swi r19, r1, 28
+ addk r19, r1, r0
+ swi r15, r1, 0
+
+ ALIGN
+ END_FINI
diff --git a/libc/sysdeps/linux/microblaze/crtn.S b/libc/sysdeps/linux/microblaze/crtn.S
new file mode 100644
index 000000000..6f4ef60d3
--- /dev/null
+++ b/libc/sysdeps/linux/microblaze/crtn.S
@@ -0,0 +1,43 @@
+/*
+ * libc/sysdeps/linux/microblaze/crtn.S -- init/fini exit code for microblaze
+ * (baselined with gcc 4.1.2)
+ *
+ * Copyright (C) 2010 Digital Design Corporation
+ *
+ * This file is subject to the terms and conditions of the GNU Lesser
+ * General Public License. See the file COPYING.LIB in the main
+ * directory of this archive for more details.
+ */
+
+#define END_INIT
+#define END_FINI
+#define ALIGN
+#include <libc-symbols.h>
+
+ .section .init
+ .align 2
+ .globl _init
+ .ent _init
+
+ lwi r15, r1, 0
+ lwi r19, r1, 28
+ rtsd r15, 8
+ addik r1, r1, 32 # Delay slot
+
+ .end _init
+$Lfe2:
+
+ .section .fini
+ .align 2
+ .globl _fini
+ .ent _fini
+
+ lwi r15, r1, 0
+ lwi r19, r1, 28
+ rtsd r15, 8
+ addik r1, r1, 32 # Delay slot
+
+ .end _fini
+$Lfe3:
+
+/*@TRAILER_BEGINS*/
diff --git a/libc/sysdeps/linux/microblaze/fixdfsi.c b/libc/sysdeps/linux/microblaze/fixdfsi.c
new file mode 100644
index 000000000..1611176aa
--- /dev/null
+++ b/libc/sysdeps/linux/microblaze/fixdfsi.c
@@ -0,0 +1,85 @@
+/*
+** libgcc support for software floating point.
+** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved.
+** Permission is granted to do *anything* you want with this file,
+** commercial or otherwise, provided this message remains intact. So there!
+** I would appreciate receiving any updates/patches/changes that anyone
+** makes, and am willing to be the repository for said changes (am I
+** making a big mistake?).
+
+Warning! Only single-precision is actually implemented. This file
+won't really be much use until double-precision is supported.
+
+However, once that is done, this file might eventually become a
+replacement for libgcc1.c. It might also make possible
+cross-compilation for an IEEE target machine from a non-IEEE
+host such as a VAX.
+
+If you'd like to work on completing this, please talk to rms@gnu.ai.mit.edu.
+
+--> Double precision floating support added by James Carlson on 20 April 1998.
+
+**
+** Pat Wood
+** Pipeline Associates, Inc.
+** pipeline!phw@motown.com or
+** sun!pipeline!phw or
+** uunet!motown!pipeline!phw
+**
+** 05/01/91 -- V1.0 -- first release to gcc mailing lists
+** 05/04/91 -- V1.1 -- added float and double prototypes and return values
+** -- fixed problems with adding and subtracting zero
+** -- fixed rounding in truncdfsf2
+** -- fixed SWAP define and tested on 386
+*/
+
+/*
+** The following are routines that replace the libgcc soft floating point
+** routines that are called automatically when -msoft-float is selected.
+** The support single and double precision IEEE format, with provisions
+** for byte-swapped machines (tested on 386). Some of the double-precision
+** routines work at full precision, but most of the hard ones simply punt
+** and call the single precision routines, producing a loss of accuracy.
+** long long support is not assumed or included.
+** Overall accuracy is close to IEEE (actually 68882) for single-precision
+** arithmetic. I think there may still be a 1 in 1000 chance of a bit
+** being rounded the wrong way during a multiply. I'm not fussy enough to
+** bother with it, but if anyone is, knock yourself out.
+**
+** Efficiency has only been addressed where it was obvious that something
+** would make a big difference. Anyone who wants to do this right for
+** best speed should go in and rewrite in assembler.
+**
+** I have tested this only on a 68030 workstation and 386/ix integrated
+** in with -msoft-float.
+*/
+
+#include "floatlib.h"
+
+/* convert double to int */
+long
+__fixdfsi (double a1)
+{
+ register union double_long dl1;
+ register int exp;
+ register long l;
+
+ dl1.d = a1;
+
+ if (!dl1.l.upper && !dl1.l.lower)
+ return (0);
+
+ exp = EXPD (dl1) - EXCESSD - 31;
+ l = MANTD (dl1);
+
+ if (exp > 0)
+ return SIGND(dl1) ? (1<<31) : ((1ul<<31)-1);
+
+ /* shift down until exp = 0 or l = 0 */
+ if (exp < 0 && exp > -32 && l)
+ l >>= -exp;
+ else
+ return (0);
+
+ return (SIGND (dl1) ? -l : l);
+}
diff --git a/libc/sysdeps/linux/microblaze/floatlib.h b/libc/sysdeps/linux/microblaze/floatlib.h
new file mode 100644
index 000000000..817ba7de0
--- /dev/null
+++ b/libc/sysdeps/linux/microblaze/floatlib.h
@@ -0,0 +1,140 @@
+/*
+** libgcc support for software floating point.
+** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved.
+** Permission is granted to do *anything* you want with this file,
+** commercial or otherwise, provided this message remains intact. So there!
+** I would appreciate receiving any updates/patches/changes that anyone
+** makes, and am willing to be the repository for said changes (am I
+** making a big mistake?).
+
+Warning! Only single-precision is actually implemented. This file
+won't really be much use until double-precision is supported.
+
+However, once that is done, this file might eventually become a
+replacement for libgcc1.c. It might also make possible
+cross-compilation for an IEEE target machine from a non-IEEE
+host such as a VAX.
+
+If you'd like to work on completing this, please talk to rms@gnu.ai.mit.edu.
+
+--> Double precision floating support added by James Carlson on 20 April 1998.
+
+**
+** Pat Wood
+** Pipeline Associates, Inc.
+** pipeline!phw@motown.com or
+** sun!pipeline!phw or
+** uunet!motown!pipeline!phw
+**
+** 05/01/91 -- V1.0 -- first release to gcc mailing lists
+** 05/04/91 -- V1.1 -- added float and double prototypes and return values
+** -- fixed problems with adding and subtracting zero
+** -- fixed rounding in truncdfsf2
+** -- fixed SWAP define and tested on 386
+*/
+
+/*
+** The following are routines that replace the libgcc soft floating point
+** routines that are called automatically when -msoft-float is selected.
+** The support single and double precision IEEE format, with provisions
+** for byte-swapped machines (tested on 386). Some of the double-precision
+** routines work at full precision, but most of the hard ones simply punt
+** and call the single precision routines, producing a loss of accuracy.
+** long long support is not assumed or included.
+** Overall accuracy is close to IEEE (actually 68882) for single-precision
+** arithmetic. I think there may still be a 1 in 1000 chance of a bit
+** being rounded the wrong way during a multiply. I'm not fussy enough to
+** bother with it, but if anyone is, knock yourself out.
+**
+** Efficiency has only been addressed where it was obvious that something
+** would make a big difference. Anyone who wants to do this right for
+** best speed should go in and rewrite in assembler.
+**
+** I have tested this only on a 68030 workstation and 386/ix integrated
+** in with -msoft-float.
+*/
+
+#ifndef __FLOAT_LIB_H__
+#define __FLOAT_LIB_H__
+/* the following deal with IEEE single-precision numbers */
+#define EXCESS 126
+#define SIGNBIT 0x80000000
+#define HIDDEN (1 << 23)
+#define SIGN(fp) ((fp) & SIGNBIT)
+#define EXP(fp) (((fp) >> 23) & 0xFF)
+#define MANT(fp) (((fp) & 0x7FFFFF) | HIDDEN)
+#define PACK(s,e,m) ((s) | ((e) << 23) | (m))
+
+/* the following deal with IEEE double-precision numbers */
+#define EXCESSD 1022
+#define HIDDEND (1 << 20)
+#define EXPD(fp) (((fp.l.upper) >> 20) & 0x7FF)
+#define SIGND(fp) ((fp.l.upper) & SIGNBIT)
+#define MANTD(fp) (((((fp.l.upper) & 0xFFFFF) | HIDDEND) << 10) | \
+ (fp.l.lower >> 22))
+#define HIDDEND_LL ((long long)1 << 52)
+#define MANTD_LL(fp) ((fp.ll & (HIDDEND_LL-1)) | HIDDEND_LL)
+#define PACKD_LL(s,e,m) (((long long)((s)+((e)<<20))<<32)|(m))
+
+/* define SWAP for 386/960 reverse-byte-order brain-damaged CPUs */
+union double_long {
+ double d;
+#ifdef SWAP
+ struct {
+ unsigned long lower;
+ long upper;
+ } l;
+#else
+ struct {
+ long upper;
+ unsigned long lower;
+ } l;
+#endif
+ long long ll;
+};
+
+union float_long
+ {
+ float f;
+ long l;
+ };
+
+#endif
+
+/* Functions defined in different files */
+
+float __addsf3 (float, float);
+float __subsf3 (float, float);
+long __cmpsf2 (float, float);
+float __mulsf3 (float, float);
+float __divsf3 (float, float);
+double __floatsidf (register long);
+double __floatdidf (register long long);
+float __floatsisf (register long );
+float __floatdisf (register long long );
+float __negsf2 (float);
+double __negdf2 (double);
+double __extendsfdf2 (float);
+float __truncdfsf2 (double);
+long __cmpdf2 (double, double);
+long __fixsfsi (float);
+long __fixdfsi (double);
+long long __fixdfdi (double);
+unsigned long __fixunsdfsi (double);
+unsigned long long __fixunsdfdi (double);
+double __adddf3 (double, double);
+double __subdf3 (double, double);
+double __muldf3 (double, double);
+double __divdf3 (double, double);
+int __gtdf2 (double, double);
+int __gedf2 (double, double);
+int __ltdf2 (double, double);
+int __ledf2 (double, double);
+int __eqdf2 (double, double);
+int __nedf2 (double, double);
+int __gtsf2 (float, float);
+int __gesf2 (float, float);
+int __ltsf2 (float, float);
+int __lesf2 (float, float);
+int __eqsf2 (float, float);
+int __nesf2 (float, float);
diff --git a/libc/sysdeps/linux/microblaze/jmpbuf-offsets.h b/libc/sysdeps/linux/microblaze/jmpbuf-offsets.h
new file mode 100644
index 000000000..c6cccc739
--- /dev/null
+++ b/libc/sysdeps/linux/microblaze/jmpbuf-offsets.h
@@ -0,0 +1,6 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+#define JB_SIZE (4 * 18)
diff --git a/libc/sysdeps/linux/microblaze/jmpbuf-unwind.h b/libc/sysdeps/linux/microblaze/jmpbuf-unwind.h
new file mode 100644
index 000000000..a24cd12f0
--- /dev/null
+++ b/libc/sysdeps/linux/microblaze/jmpbuf-unwind.h
@@ -0,0 +1,11 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+#include <setjmp.h>
+
+/* Test if longjmp to JMPBUF would unwind the frame
+ containing a local variable at ADDRESS. */
+#define _JMPBUF_UNWINDS(jmpbuf, address) \
+ ((void *) (address) < (void *) (jmpbuf)[0].__sp)
diff --git a/libc/sysdeps/linux/microblaze/mmap.c b/libc/sysdeps/linux/microblaze/mmap.c
deleted file mode 100644
index cad528d17..000000000
--- a/libc/sysdeps/linux/microblaze/mmap.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Use new style mmap for microblaze */
-/*
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-#include <unistd.h>
-#include <errno.h>
-#include <sys/mman.h>
-#include <sys/syscall.h>
-
-libc_hidden_proto(mmap)
-
-_syscall6 (__ptr_t, mmap, __ptr_t, addr, size_t, len, int, prot,
- int, flags, int, fd, __off_t, offset);
-libc_hidden_def(mmap)
diff --git a/libc/sysdeps/linux/microblaze/setjmp.S b/libc/sysdeps/linux/microblaze/setjmp.S
index 7068d4b40..3c1d8a1dd 100644
--- a/libc/sysdeps/linux/microblaze/setjmp.S
+++ b/libc/sysdeps/linux/microblaze/setjmp.S
@@ -8,46 +8,74 @@
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License. See the file COPYING.LIB in the main
* directory of this archive for more details.
- *
+ *
* Written by Miles Bader <miles@gnu.org>
- */
+ *
+ * PIC code based on glibc 2.3.6 */
+
+/*
+ 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.
-#define _SETJMP_H
-#define _ASM
-#include <bits/setjmp.h>
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
-#include <clinkage.h>
+#include <libc-symbols.h>
.text
-C_ENTRY(setjmp):
- addi r6, r0, 1 /* Save the signal mask. */
+ .globl C_SYMBOL_NAME(setjmp)
+ .align 4
+C_SYMBOL_NAME(setjmp):
+#ifdef __PIC__
+ brid 1f
+#else
braid C_SYMBOL_NAME(__sigsetjmp)
- nop
+#endif
+ addi r6, r0, 1 /* Save the signal mask. */
.globl C_SYMBOL_NAME(_setjmp)
C_SYMBOL_NAME(_setjmp):
- add r6, r0, r0 /* Don't save the signal mask. */
+ and r6, r0, r0 /* Don't save the signal mask. */
.globl C_SYMBOL_NAME(__sigsetjmp)
C_SYMBOL_NAME(__sigsetjmp):
+1:
/* Save registers relative to r5 (arg0)*/
swi r1, r5, 0 /* stack pointer */
swi r15, r5, 4 /* link register */
- swi r18, r5, 8 /* assembler temp */
- swi r19, r5, 12 /* now call-preserved regs */
- swi r20, r5, 16
- swi r21, r5, 20
- swi r22, r5, 24
- swi r23, r5, 28
- swi r24, r5, 32
- swi r25, r5, 36
- swi r26, r5, 40
- swi r27, r5, 44
- swi r28, r5, 48
- swi r29, r5, 52
- swi r30, r5, 56
+ swi r2, r5, 8 /* SDA and SDA2 ptrs */
+ swi r13, r5, 12
+ swi r18, r5, 16 /* assembler temp */
+ swi r19, r5, 20 /* now call-preserved regs */
+ swi r20, r5, 24
+ swi r21, r5, 28
+ swi r22, r5, 32
+ swi r23, r5, 36
+ swi r24, r5, 40
+ swi r25, r5, 44
+ swi r26, r5, 48
+ swi r27, r5, 52
+ swi r28, r5, 56
+ swi r29, r5, 60
+ swi r30, r5, 64
+ swi r31, r5, 68
/* Make a tail call to __sigjmp_save; it takes the same args. */
+#ifdef __PIC__
+ mfs r12,rpc
+ addik r12,r12,_GLOBAL_OFFSET_TABLE_+8
+ lwi r12,r12,__sigjmp_save@GOT
+ brad r12
+ nop
+#else
braid C_SYMBOL_NAME(__sigjmp_save)
nop
-C_END(setjmp)
+#endif
diff --git a/libc/sysdeps/linux/microblaze/sys/procfs.h b/libc/sysdeps/linux/microblaze/sys/procfs.h
new file mode 100644
index 000000000..eca782856
--- /dev/null
+++ b/libc/sysdeps/linux/microblaze/sys/procfs.h
@@ -0,0 +1,144 @@
+/* Copyright (C) 1996, 1997, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#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>
+
+
+/* Type for a general-purpose register. */
+#ifndef ELF_GREG_T
+#define ELF_GREG_T
+typedef unsigned long elf_greg_t;
+#endif
+
+/* This is exactly the same as `struct pt_regs' in the kernel. */
+struct elf_gregset
+{
+ elf_greg_t gpr[32]; /* General purpose registers. */
+
+ elf_greg_t pc; /* program counter */
+ elf_greg_t psw; /* program status word */
+ elf_greg_t ear; /* Exception address register */
+ elf_greg_t esr; /* Excep[tion Status Register */
+ elf_greg_t fsr; /* FPU Status register */
+
+ elf_greg_t kernel_mode; /* 1 if in `kernel mode', 0 if user mode */
+ elf_greg_t single_step; /* 1 if in single step mode */
+};
+
+#ifndef ELF_NGREG
+#define ELF_NGREG (sizeof (struct elf_gregset) / sizeof(elf_greg_t))
+#endif
+
+#ifndef ELF_GREGSET_T
+#define ELF_GREGSET_T
+typedef elf_greg_t elf_gregset_t[ELF_NGREG];
+#endif
+
+/* Register set for the floating-point registers. */
+#ifndef ELF_FPREGSET_T
+#define ELF_FPREGSET_T
+typedef elf_greg_t elf_fpregset_t;
+#endif
+
+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.
+ * Fields present but not used are marked with "XXX".
+ */
+struct elf_prstatus
+{
+ struct elf_siginfo pr_info; /* Info associated with signal */
+ short pr_cursig; /* Current signal */
+ unsigned long pr_sigpend; /* Set of pending signals */
+ unsigned long pr_sighold; /* Set of held signals */
+ __kernel_pid_t pr_pid;
+ __kernel_pid_t pr_ppid;
+ __kernel_pid_t pr_pgrp;
+ __kernel_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 co-processor 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 pr_flag; /* flags */
+ __kernel_uid_t pr_uid;
+ __kernel_gid_t pr_gid;
+ __kernel_pid_t 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_fpregset_t prfpregset_t;
+
+/* We don't have any differences between processes and threads,
+ therefore have only one PID type. */
+typedef __kernel_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;
+
+
+#endif /* sys/procfs.h */
diff --git a/libc/sysdeps/linux/microblaze/sys/ptrace.h b/libc/sysdeps/linux/microblaze/sys/ptrace.h
index b7a9adf25..a81f97162 100644
--- a/libc/sysdeps/linux/microblaze/sys/ptrace.h
+++ b/libc/sysdeps/linux/microblaze/sys/ptrace.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_PTRACE_H
#define _SYS_PTRACE_H 1
@@ -65,12 +64,16 @@ enum __ptrace_request
PTRACE_KILL = 8,
#define PT_KILL PTRACE_KILL
+ /* Single step the process. */
+ PTRACE_SINGLESTEP = 9,
+#define PT_STEP PTRACE_SINGLESTEP
+
/* Attach to a process that is already running. */
- PTRACE_ATTACH = 0x10,
+ PTRACE_ATTACH = 16,
#define PT_ATTACH PTRACE_ATTACH
/* Detach from a process attached to with PTRACE_ATTACH. */
- PTRACE_DETACH = 0x11,
+ PTRACE_DETACH = 17,
#define PT_DETACH PTRACE_DETACH
/* Continue and stop at the next (return from) syscall. */
diff --git a/libc/sysdeps/linux/microblaze/sys/ucontext.h b/libc/sysdeps/linux/microblaze/sys/ucontext.h
index 07f0933ff..7c5e30384 100644
--- a/libc/sysdeps/linux/microblaze/sys/ucontext.h
+++ b/libc/sysdeps/linux/microblaze/sys/ucontext.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_UCONTEXT_H
#define _SYS_UCONTEXT_H 1
diff --git a/libc/sysdeps/linux/microblaze/sys/user.h b/libc/sysdeps/linux/microblaze/sys/user.h
new file mode 100644
index 000000000..eafb88553
--- /dev/null
+++ b/libc/sysdeps/linux/microblaze/sys/user.h
@@ -0,0 +1,76 @@
+/* Copyright (C) 1998, 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#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. */
+
+struct user_fpregs_struct
+{
+ long int cwd;
+ long int swd;
+ long int twd;
+ long int fip;
+ long int fcs;
+ long int foo;
+ long int fos;
+ long int st_space [20];
+};
+
+struct user_regs_struct
+{
+ unsigned int gpr[32];
+ unsigned int pc;
+ unsigned int msr;
+ unsigned int ear;
+ unsigned int esr;
+ unsigned int fsr;
+ unsigned int btr;
+ unsigned int pvr[12];
+};
+
+struct user
+{
+ struct user_regs_struct regs;
+ int u_fpvalid;
+ struct user_fpregs_struct i387;
+ unsigned long int u_tsize;
+ unsigned long int u_dsize;
+ unsigned long int u_ssize;
+ unsigned long start_code;
+ unsigned long start_stack;
+ long int signal;
+ int reserved;
+ struct user_regs_struct* u_ar0;
+ struct user_fpregs_struct* u_fpstate;
+ unsigned long int magic;
+ char u_comm [32];
+ int u_debugreg [8];
+};
+
+#define PAGE_SHIFT 12
+#define PAGE_SIZE (1UL << PAGE_SHIFT)
+#define PAGE_MASK (~(PAGE_SIZE-1))
+#define NBPG PAGE_SIZE
+#define UPAGES 1
+#define HOST_TEXT_START_ADDR (u.start_code)
+#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
+
+#endif /* _SYS_USER_H */
diff --git a/libc/sysdeps/linux/microblaze/syscall.c b/libc/sysdeps/linux/microblaze/syscall.c
deleted file mode 100644
index 0e07e4595..000000000
--- a/libc/sysdeps/linux/microblaze/syscall.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * libc/sysdeps/linux/microblaze/syscall.c -- generic syscall function for linux/microblaze
- *
- * Copyright (C) 2003 John Williams <jwilliams@itee.uq.edu.au>
- * Copyright (C) 2002 NEC Corporation
- * Copyright (C) 2002 Miles Bader <miles@gnu.org>
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- *
- * Written by Miles Bader <miles@gnu.org>
- */
-
-#include <errno.h>
-#include <sys/syscall.h>
-
-typedef unsigned long arg_t;
-
-/* Invoke `system call' NUM, passing it the remaining arguments.
- This is completely system-dependent, and not often useful. */
-long
-syscall (long num, arg_t a1, arg_t a2, arg_t a3, arg_t a4, arg_t a5, arg_t a6)
-{
- /* We don't know how many arguments are valid, so A5 and A6 are fetched
- off the stack even for (the majority of) system calls with fewer
- arguments; hopefully this won't cause any problems. A1-A4 are in
- registers, so they're OK. */
- register arg_t a __asm__ (SYSCALL_ARG0) = a1;
- register arg_t b __asm__ (SYSCALL_ARG1) = a2;
- register arg_t c __asm__ (SYSCALL_ARG2) = a3;
- register arg_t d __asm__ (SYSCALL_ARG3) = a4;
- register arg_t e __asm__ (SYSCALL_ARG4) = a5;
- register arg_t f __asm__ (SYSCALL_ARG5) = a6;
- register unsigned long syscall __asm__ (SYSCALL_NUM) = num;
- register unsigned long ret __asm__ (SYSCALL_RET);
- unsigned long ret_sav;
-
- *((unsigned long *)0xFFFF4004) = (unsigned int)('+');
- __asm__ ("brlid r17, 08x; nop;"
- : "=r" (ret)
- : "r" (syscall), "r" (a), "r" (b), "r" (c), "r" (d), "r" (e), "r" (f)
- : SYSCALL_CLOBBERS);
-
- ret_sav=ret;
- *((unsigned long *)0xFFFF4004) = (unsigned int)('-');
-
-
-
- __syscall_return (long, ret);
-}
diff --git a/libc/sysdeps/linux/microblaze/vfork.S b/libc/sysdeps/linux/microblaze/vfork.S
index 1e802ae29..cd6012889 100644
--- a/libc/sysdeps/linux/microblaze/vfork.S
+++ b/libc/sysdeps/linux/microblaze/vfork.S
@@ -1,44 +1,47 @@
/*
* libc/sysdeps/linux/microblaze/vfork.S -- `vfork' syscall for linux/microblaze
*
+ * Copyright (C) 2003 John Williams <jwilliams@itee.uq.edu.au>
* Copyright (C) 2001 NEC Corporation
* Copyright (C) 2001 Miles Bader <miles@gnu.org>
- * Copyright (C) 2003 John Williams <jwilliams@itee.uq.edu.au>
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
*
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-/*
+ * This file is subject to the terms and conditions of the GNU Lesser
+ * General Public License. See the file COPYING.LIB in the main
+ * directory of this archive for more details.
+ *
* Written by Miles Bader <miles@gnu.org>
* Microblaze port by John Williams
*/
-#define _ERRNO_H 1
-#include <bits/errno.h>
-#define _SYSCALL_H
-#include <bits/sysnum.h>
-
-#include <clinkage.h>
+#include <sys/syscall.h>
/* Clone the calling process, but without copying the whole address space.
The calling process is suspended until the new process exits or is
replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
and the process ID of the new process to the old process. */
-.global C_SYMBOL_NAME(errno)
-
-C_ENTRY (__vfork):
+ .globl __vfork
+ .hidden __vfork
+ .align 4
+__vfork:
addi r12, r0, SYS_vfork
- bralid r17, 0x08;
- nop
- addi r4, r3, 125 // minimum err value
- blti r4, 1f // is r3 < -125?
- rtsd r15, 8 // normal return
- nop
-1: sub r3, r3, r0 // r3 = -r3
+ brki r14, 0x08;
+ addi r4, r3, 125 /* minimum err value */
+ blti r4, 1f /* is r3 < -125? */
+ bri 2f /* normal return */
+1: sub r3, r3, r0 /* r3 = -r3 */
+#ifdef __PIC__
+ mfs r3,rpc
+ addik r3,r3,_GLOBAL_OFFSET_TABLE_+8
+ lwi r3,r3,C_SYMBOL_NAME(errno)@GOT
+ sw r3, r0, r3
+#else
swi r3, r0, C_SYMBOL_NAME(errno);
- rtsd r15, 8 // error return
+#endif
+ /* state restore etc */
+2: rtsd r15, 8 /* error return */
nop
-C_END(__vfork)
+ .size __vfork, .-__vfork
+
weak_alias(__vfork,vfork)
-libc_hidden_weak(vfork)
+libc_hidden_def(vfork)
diff --git a/libc/sysdeps/linux/mips/Makefile.arch b/libc/sysdeps/linux/mips/Makefile.arch
index da5ca1e0f..2c2e66fbb 100644
--- a/libc/sysdeps/linux/mips/Makefile.arch
+++ b/libc/sysdeps/linux/mips/Makefile.arch
@@ -5,14 +5,20 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-CSRC := \
- __longjmp.c brk.c setjmp_aux.c mmap.c __syscall_error.c \
- cacheflush.c pread_write.c sysmips.c _test_and_set.c sigaction.c \
- readahead.c posix_fadvise.c posix_fadvise64.c
+CSRC-y := \
+ __longjmp.c brk.c setjmp_aux.c \
+ pread_write.c sigaction.c _test_and_set.c
-SSRC := bsd-_setjmp.S bsd-setjmp.S setjmp.S clone.S syscall.S pipe.S
+SSRC-y := bsd-_setjmp.S bsd-setjmp.S setjmp.S syscall.S pipe.S syscall_error.S
+
+CSRC-$(UCLIBC_LINUX_SPECIFIC) += cacheflush.c sysmips.c
+CSRC-$(UCLIBC_HAS_ADVANCED_REALTIME) += posix_fadvise.c
+CSRC-$(if $(findstring yy,$(UCLIBC_HAS_LFS)$(UCLIBC_HAS_ADVANCED_REALTIME)),y) += posix_fadvise64.c
+SSRC-$(if $(UCLIBC_HAS_THREADS_NATIVE),,y) += vfork.S clone.S
+SSRC-$(UCLIBC_HAS_CONTEXT_FUNCS) += makecontext.S setcontext.S getcontext.S \
+ swapcontext.S
+
+ASFLAGS-syscall_error.S += -D_LIBC_REENTRANT
ARCH_HEADERS := sgidefs.h
# regdef.h
-
-include $(top_srcdir)libc/sysdeps/linux/Makefile.commonarch
diff --git a/libc/sysdeps/linux/mips/__longjmp.c b/libc/sysdeps/linux/mips/__longjmp.c
index 9dc09f27a..aa94f76fa 100644
--- a/libc/sysdeps/linux/mips/__longjmp.c
+++ b/libc/sysdeps/linux/mips/__longjmp.c
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <features.h>
#include <setjmp.h>
@@ -102,13 +101,13 @@ void __longjmp (__jmp_buf env, int val_arg)
/* Restore the stack pointer and the FP. They have to be restored
last and in a single asm as gcc, depending on options used, may
use either of them to access env. */
-#if _MIPS_SIM == _MIPS_SIM_ABI64
+#if _MIPS_SIM != _MIPS_SIM_ABI32
__asm__ __volatile__ ("ld $29, %0\n\t"
"ld $30, %1\n\t" : : "m" (env[0].__sp), "m" (env[0].__fp));
-#else /* O32 || N32 */
+#else /* O32 */
__asm__ __volatile__ ("lw $29, %0\n\t"
"lw $30, %1\n\t" : : "m" (env[0].__sp), "m" (env[0].__fp));
-#endif /* O32 || N32 */
+#endif /* O32 */
/* Give setjmp 1 if given a 0, or what they gave us if non-zero. */
if (val == 0)
diff --git a/libc/sysdeps/linux/mips/_test_and_set.c b/libc/sysdeps/linux/mips/_test_and_set.c
index 9fd48f753..2ed874c86 100644
--- a/libc/sysdeps/linux/mips/_test_and_set.c
+++ b/libc/sysdeps/linux/mips/_test_and_set.c
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* Define the real-function versions of all inline functions
defined in sys/tas.h */
diff --git a/libc/sysdeps/linux/mips/bits/atomic.h b/libc/sysdeps/linux/mips/bits/atomic.h
index ca53d3842..e4f9e3b73 100644
--- a/libc/sysdeps/linux/mips/bits/atomic.h
+++ b/libc/sysdeps/linux/mips/bits/atomic.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _MIPS_BITS_ATOMIC_H
#define _MIPS_BITS_ATOMIC_H 1
@@ -49,6 +48,32 @@ typedef uintmax_t uatomic_max_t;
# define MIPS_SYNC sync
#endif
+/* Certain revisions of the R10000 Processor need an LL/SC Workaround
+ enabled. Revisions before 3.0 misbehave on atomic operations, and
+ Revs 2.6 and lower deadlock after several seconds due to other errata.
+
+ To quote the R10K Errata:
+ Workaround: The basic idea is to inhibit the four instructions
+ from simultaneously becoming active in R10000. Padding all
+ ll/sc sequences with nops or changing the looping branch in the
+ routines to a branch likely (which is always predicted taken
+ by R10000) will work. The nops should go after the loop, and the
+ number of them should be 28. This number could be decremented for
+ each additional instruction in the ll/sc loop such as the lock
+ modifier(s) between the ll and sc, the looping branch and its
+ delay slot. For typical short routines with one ll/sc loop, any
+ instructions after the loop could also count as a decrement. The
+ nop workaround pollutes the cache more but would be a few cycles
+ faster if all the code is in the cache and the looping branch
+ is predicted not taken. */
+
+
+#ifdef _MIPS_ARCH_R10000
+#define R10K_BEQZ_INSN "beqzl"
+#else
+#define R10K_BEQZ_INSN "beqz"
+#endif
+
#define MIPS_SYNC_STR_2(X) #X
#define MIPS_SYNC_STR_1(X) MIPS_SYNC_STR_2(X)
#define MIPS_SYNC_STR MIPS_SYNC_STR_1(MIPS_SYNC)
@@ -58,10 +83,10 @@ typedef uintmax_t uatomic_max_t;
in which values are returned. */
#define __arch_compare_and_exchange_xxx_8_int(mem, newval, oldval, rel, acq) \
- (abort (), __prev = __cmp = 0)
+ (abort (), __prev = 0, __cmp = 0)
#define __arch_compare_and_exchange_xxx_16_int(mem, newval, oldval, rel, acq) \
- (abort (), __prev = __cmp = 0)
+ (abort (), __prev = 0, __cmp = 0)
#define __arch_compare_and_exchange_xxx_32_int(mem, newval, oldval, rel, acq) \
__asm__ __volatile__ ( \
@@ -69,23 +94,23 @@ typedef uintmax_t uatomic_max_t;
MIPS_PUSH_MIPS2 \
rel "\n" \
"1:\t" \
- "ll %0,%4\n\t" \
+ "ll %0,%5\n\t" \
"move %1,$0\n\t" \
- "bne %0,%2,2f\n\t" \
- "move %1,%3\n\t" \
- "sc %1,%4\n\t" \
- "beqz %1,1b\n" \
+ "bne %0,%3,2f\n\t" \
+ "move %1,%4\n\t" \
+ "sc %1,%2\n\t" \
+ R10K_BEQZ_INSN" %1,1b\n" \
acq "\n\t" \
".set pop\n" \
"2:\n\t" \
- : "=&r" (__prev), "=&r" (__cmp) \
+ : "=&r" (__prev), "=&r" (__cmp), "=m" (*mem) \
: "r" (oldval), "r" (newval), "m" (*mem) \
: "memory")
#if _MIPS_SIM == _ABIO32
/* We can't do an atomic 64-bit operation in O32. */
#define __arch_compare_and_exchange_xxx_64_int(mem, newval, oldval, rel, acq) \
- (abort (), __prev = __cmp = 0)
+ (abort (), __prev = 0, __cmp = 0)
#else
#define __arch_compare_and_exchange_xxx_64_int(mem, newval, oldval, rel, acq) \
__asm__ __volatile__ ("\n" \
@@ -93,16 +118,16 @@ typedef uintmax_t uatomic_max_t;
MIPS_PUSH_MIPS2 \
rel "\n" \
"1:\t" \
- "lld %0,%4\n\t" \
+ "lld %0,%5\n\t" \
"move %1,$0\n\t" \
- "bne %0,%2,2f\n\t" \
- "move %1,%3\n\t" \
- "scd %1,%4\n\t" \
- "beqz %1,1b\n" \
+ "bne %0,%3,2f\n\t" \
+ "move %1,%4\n\t" \
+ "scd %1,%2\n\t" \
+ R10K_BEQZ_INSN" %1,1b\n" \
acq "\n\t" \
".set pop\n" \
"2:\n\t" \
- : "=&r" (__prev), "=&r" (__cmp) \
+ : "=&r" (__prev), "=&r" (__cmp), "=m" (*mem) \
: "r" (oldval), "r" (newval), "m" (*mem) \
: "memory")
#endif
@@ -110,22 +135,22 @@ typedef uintmax_t uatomic_max_t;
/* For all "bool" routines, we return FALSE if exchange succesful. */
#define __arch_compare_and_exchange_bool_8_int(mem, new, old, rel, acq) \
-({ typeof (*mem) __prev; int __cmp; \
+({ __typeof (*mem) __prev attribute_unused; int __cmp; \
__arch_compare_and_exchange_xxx_8_int(mem, new, old, rel, acq); \
!__cmp; })
#define __arch_compare_and_exchange_bool_16_int(mem, new, old, rel, acq) \
-({ typeof (*mem) __prev; int __cmp; \
+({ __typeof (*mem) __prev attribute_unused; int __cmp; \
__arch_compare_and_exchange_xxx_16_int(mem, new, old, rel, acq); \
!__cmp; })
#define __arch_compare_and_exchange_bool_32_int(mem, new, old, rel, acq) \
-({ typeof (*mem) __prev; int __cmp; \
+({ __typeof (*mem) __prev attribute_unused; int __cmp; \
__arch_compare_and_exchange_xxx_32_int(mem, new, old, rel, acq); \
!__cmp; })
#define __arch_compare_and_exchange_bool_64_int(mem, new, old, rel, acq) \
-({ typeof (*mem) __prev; int __cmp; \
+({ __typeof (*mem) __prev attribute_unused; int __cmp; \
__arch_compare_and_exchange_xxx_64_int(mem, new, old, rel, acq); \
!__cmp; })
@@ -133,24 +158,24 @@ typedef uintmax_t uatomic_max_t;
successful or not. */
#define __arch_compare_and_exchange_val_8_int(mem, new, old, rel, acq) \
-({ typeof (*mem) __prev; int __cmp; \
+({ __typeof (*mem) __prev attribute_unused; int __cmp attribute_unused; \
__arch_compare_and_exchange_xxx_8_int(mem, new, old, rel, acq); \
- (typeof (*mem))__prev; })
+ (__typeof (*mem))__prev; })
#define __arch_compare_and_exchange_val_16_int(mem, new, old, rel, acq) \
-({ typeof (*mem) __prev; int __cmp; \
+({ __typeof (*mem) __prev attribute_unused; int __cmp attribute_unused; \
__arch_compare_and_exchange_xxx_16_int(mem, new, old, rel, acq); \
- (typeof (*mem))__prev; })
+ (__typeof (*mem))__prev; })
#define __arch_compare_and_exchange_val_32_int(mem, new, old, rel, acq) \
-({ typeof (*mem) __prev; int __cmp; \
+({ __typeof (*mem) __prev attribute_unused; int __cmp attribute_unused; \
__arch_compare_and_exchange_xxx_32_int(mem, new, old, rel, acq); \
- (typeof (*mem))__prev; })
+ (__typeof (*mem))__prev; })
#define __arch_compare_and_exchange_val_64_int(mem, new, old, rel, acq) \
-({ typeof (*mem) __prev; int __cmp; \
+({ __typeof (*mem) __prev attribute_unused; int __cmp attribute_unused; \
__arch_compare_and_exchange_xxx_64_int(mem, new, old, rel, acq); \
- (typeof (*mem))__prev; })
+ (__typeof (*mem))__prev; })
/* Compare and exchange with "acquire" semantics, ie barrier after. */
@@ -183,20 +208,20 @@ typedef uintmax_t uatomic_max_t;
(abort (), 0)
#define __arch_exchange_xxx_32_int(mem, newval, rel, acq) \
-({ typeof (*mem) __prev; int __cmp; \
+({ __typeof (*mem) __prev; int __cmp; \
__asm__ __volatile__ ("\n" \
".set push\n\t" \
MIPS_PUSH_MIPS2 \
rel "\n" \
"1:\t" \
- "ll %0,%3\n\t" \
- "move %1,%2\n\t" \
- "sc %1,%3\n\t" \
- "beqz %1,1b\n" \
+ "ll %0,%4\n\t" \
+ "move %1,%3\n\t" \
+ "sc %1,%2\n\t" \
+ R10K_BEQZ_INSN" %1,1b\n" \
acq "\n\t" \
".set pop\n" \
"2:\n\t" \
- : "=&r" (__prev), "=&r" (__cmp) \
+ : "=&r" (__prev), "=&r" (__cmp), "=m" (*mem) \
: "r" (newval), "m" (*mem) \
: "memory"); \
__prev; })
@@ -207,20 +232,20 @@ typedef uintmax_t uatomic_max_t;
(abort (), 0)
#else
#define __arch_exchange_xxx_64_int(mem, newval, rel, acq) \
-({ typeof (*mem) __prev; int __cmp; \
+({ __typeof (*mem) __prev; int __cmp; \
__asm__ __volatile__ ("\n" \
".set push\n\t" \
MIPS_PUSH_MIPS2 \
rel "\n" \
"1:\n" \
- "lld %0,%3\n\t" \
- "move %1,%2\n\t" \
- "scd %1,%3\n\t" \
- "beqz %1,1b\n" \
+ "lld %0,%4\n\t" \
+ "move %1,%3\n\t" \
+ "scd %1,%2\n\t" \
+ R10K_BEQZ_INSN" %1,1b\n" \
acq "\n\t" \
".set pop\n" \
"2:\n\t" \
- : "=&r" (__prev), "=&r" (__cmp) \
+ : "=&r" (__prev), "=&r" (__cmp), "=m" (*mem) \
: "r" (newval), "m" (*mem) \
: "memory"); \
__prev; })
@@ -236,26 +261,26 @@ typedef uintmax_t uatomic_max_t;
/* Atomically add value and return the previous (unincremented) value. */
#define __arch_exchange_and_add_8_int(mem, newval, rel, acq) \
- (abort (), (typeof(*mem)) 0)
+ (abort (), (__typeof(*mem)) 0)
#define __arch_exchange_and_add_16_int(mem, newval, rel, acq) \
- (abort (), (typeof(*mem)) 0)
+ (abort (), (__typeof(*mem)) 0)
#define __arch_exchange_and_add_32_int(mem, value, rel, acq) \
-({ typeof (*mem) __prev; int __cmp; \
+({ __typeof (*mem) __prev; int __cmp; \
__asm__ __volatile__ ("\n" \
".set push\n\t" \
MIPS_PUSH_MIPS2 \
rel "\n" \
"1:\t" \
- "ll %0,%3\n\t" \
- "addu %1,%0,%2\n\t" \
- "sc %1,%3\n\t" \
- "beqz %1,1b\n" \
+ "ll %0,%4\n\t" \
+ "addu %1,%0,%3\n\t" \
+ "sc %1,%2\n\t" \
+ R10K_BEQZ_INSN" %1,1b\n" \
acq "\n\t" \
".set pop\n" \
"2:\n\t" \
- : "=&r" (__prev), "=&r" (__cmp) \
+ : "=&r" (__prev), "=&r" (__cmp), "=m" (*mem) \
: "r" (value), "m" (*mem) \
: "memory"); \
__prev; })
@@ -263,23 +288,23 @@ typedef uintmax_t uatomic_max_t;
#if _MIPS_SIM == _ABIO32
/* We can't do an atomic 64-bit operation in O32. */
#define __arch_exchange_and_add_64_int(mem, value, rel, acq) \
- (abort (), (typeof(*mem)) 0)
+ (abort (), (__typeof(*mem)) 0)
#else
#define __arch_exchange_and_add_64_int(mem, value, rel, acq) \
-({ typeof (*mem) __prev; int __cmp; \
+({ __typeof (*mem) __prev; int __cmp; \
__asm__ __volatile__ ( \
".set push\n\t" \
MIPS_PUSH_MIPS2 \
rel "\n" \
"1:\t" \
- "lld %0,%3\n\t" \
- "daddu %1,%0,%2\n\t" \
- "scd %1,%3\n\t" \
- "beqz %1,1b\n" \
+ "lld %0,%4\n\t" \
+ "daddu %1,%0,%3\n\t" \
+ "scd %1,%2\n\t" \
+ R10K_BEQZ_INSN" %1,1b\n" \
acq "\n\t" \
".set pop\n" \
"2:\n\t" \
- : "=&r" (__prev), "=&r" (__cmp) \
+ : "=&r" (__prev), "=&r" (__cmp), "=m" (*mem) \
: "r" (value), "m" (*mem) \
: "memory"); \
__prev; })
diff --git a/libc/sysdeps/linux/mips/bits/dirent.h b/libc/sysdeps/linux/mips/bits/dirent.h
index 014e011c9..65c9fc603 100644
--- a/libc/sysdeps/linux/mips/bits/dirent.h
+++ b/libc/sysdeps/linux/mips/bits/dirent.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _DIRENT_H
# error "Never use <bits/dirent.h> directly; include <dirent.h> instead."
diff --git a/libc/sysdeps/linux/mips/bits/dlfcn.h b/libc/sysdeps/linux/mips/bits/dlfcn.h
index 1f054f979..c19c166e3 100644
--- a/libc/sysdeps/linux/mips/bits/dlfcn.h
+++ b/libc/sysdeps/linux/mips/bits/dlfcn.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _DLFCN_H
# error "Never use <bits/dlfcn.h> directly; include <dlfcn.h> instead."
@@ -27,7 +26,9 @@
#define RTLD_NOW 0x0002 /* Immediate function call binding. */
#define RTLD_BINDING_MASK 0x3 /* Mask of binding time value. */
#define RTLD_NOLOAD 0x00008 /* Do not load the object. */
+#if 0 /* uClibc doesnt support these */
#define RTLD_DEEPBIND 0x00010 /* Use deep binding. */
+#endif
/* If the following bit is set in the MODE argument to `dlopen',
the symbols of the loaded object and its dependencies are made
diff --git a/libc/sysdeps/linux/mips/bits/epoll.h b/libc/sysdeps/linux/mips/bits/epoll.h
new file mode 100644
index 000000000..4c6eb3bb7
--- /dev/null
+++ b/libc/sysdeps/linux/mips/bits/epoll.h
@@ -0,0 +1,29 @@
+/* Copyright (C) 2002-2012 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_EPOLL_H
+# error "Never use <bits/epoll.h> directly; include <sys/epoll.h> instead."
+#endif
+
+/* Flags to be passed to epoll_create1. */
+enum
+ {
+ EPOLL_CLOEXEC = 02000000,
+#define EPOLL_CLOEXEC EPOLL_CLOEXEC
+ EPOLL_NONBLOCK = 00000200
+#define EPOLL_NONBLOCK EPOLL_NONBLOCK
+ };
diff --git a/libc/sysdeps/linux/mips/bits/eventfd.h b/libc/sysdeps/linux/mips/bits/eventfd.h
new file mode 100644
index 000000000..17b2f469e
--- /dev/null
+++ b/libc/sysdeps/linux/mips/bits/eventfd.h
@@ -0,0 +1,31 @@
+/* Copyright (C) 2007-2013 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_EVENTFD_H
+# error "Never use <bits/eventfd.h> directly; include <sys/eventfd.h> instead."
+#endif
+
+/* Flags for eventfd. */
+enum
+ {
+ EFD_SEMAPHORE = 00000001,
+#define EFD_SEMAPHORE EFD_SEMAPHORE
+ EFD_CLOEXEC = 02000000,
+#define EFD_CLOEXEC EFD_CLOEXEC
+ EFD_NONBLOCK = 00000200
+#define EFD_NONBLOCK EFD_NONBLOCK
+ };
diff --git a/libc/sysdeps/linux/mips/bits/fcntl.h b/libc/sysdeps/linux/mips/bits/fcntl.h
index 896786943..e7fed9b8a 100644
--- a/libc/sysdeps/linux/mips/bits/fcntl.h
+++ b/libc/sysdeps/linux/mips/bits/fcntl.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FCNTL_H
# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
@@ -51,6 +50,8 @@
# define O_DIRECT 0x8000 /* Direct disk access hint. */
# define O_DIRECTORY 0x10000 /* Must be a directory. */
# define O_NOATIME 0x40000 /* Do not set atime. */
+# define O_CLOEXEC 02000000 /* set close_on_exec */
+# define O_PATH 010000000 /* Resolve pathname but do not open file. */
#endif
/* For now Linux has no synchronisity options for data and read operations.
@@ -111,6 +112,8 @@
# define F_NOTIFY 1026 /* Request notfications on a directory. */
# define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with
close-on-exit set on new fd. */
+# define F_SETPIPE_SZ 1031 /* Set pipe page size array. */
+# define F_GETPIPE_SZ 1032 /* Get pipe page size array. */
#endif
/* For F_[GET|SET]FL. */
@@ -209,7 +212,7 @@ struct flock64
#endif
-#ifdef __USE_GNU
+#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
@@ -232,7 +235,7 @@ struct flock64
__BEGIN_DECLS
-#ifdef __USE_GNU
+#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)
diff --git a/libc/sysdeps/linux/mips/bits/fenv.h b/libc/sysdeps/linux/mips/bits/fenv.h
index 24e0694ca..944101f75 100644
--- a/libc/sysdeps/linux/mips/bits/fenv.h
+++ b/libc/sysdeps/linux/mips/bits/fenv.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FENV_H
# error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
@@ -69,9 +68,9 @@ typedef struct
fenv_t;
/* If the default argument is used we use this value. */
-#define FE_DFL_ENV ((__const fenv_t *) -1)
+#define FE_DFL_ENV ((const fenv_t *) -1)
#ifdef __USE_GNU
/* Floating-point environment where none of the exception is masked. */
-# define FE_NOMASK_ENV ((__const fenv_t *) -2)
+# define FE_NOMASK_ENV ((const fenv_t *) -2)
#endif
diff --git a/libc/sysdeps/linux/mips/bits/inotify.h b/libc/sysdeps/linux/mips/bits/inotify.h
new file mode 100644
index 000000000..67d648bd9
--- /dev/null
+++ b/libc/sysdeps/linux/mips/bits/inotify.h
@@ -0,0 +1,29 @@
+/* Copyright (C) 2005-2012 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_INOTIFY_H
+# error "Never use <bits/inotify.h> directly; include <sys/inotify.h> instead."
+#endif
+
+/* Flags for the parameter of inotify_init1. */
+enum
+ {
+ IN_CLOEXEC = 02000000,
+#define IN_CLOEXEC IN_CLOEXEC
+ IN_NONBLOCK = 00000200
+#define IN_NONBLOCK IN_NONBLOCK
+ };
diff --git a/libc/sysdeps/linux/mips/bits/ioctl-types.h b/libc/sysdeps/linux/mips/bits/ioctl-types.h
index a8dcf242d..4d16c706c 100644
--- a/libc/sysdeps/linux/mips/bits/ioctl-types.h
+++ b/libc/sysdeps/linux/mips/bits/ioctl-types.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_IOCTL_H
# error "Never use <bits/ioctl-types.h> directly; include <sys/ioctl.h> instead."
diff --git a/libc/sysdeps/linux/mips/bits/ipc.h b/libc/sysdeps/linux/mips/bits/ipc.h
index 1f629ce66..97a8da032 100644
--- a/libc/sysdeps/linux/mips/bits/ipc.h
+++ b/libc/sysdeps/linux/mips/bits/ipc.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_IPC_H
# error "Never use <bits/ipc.h> directly; include <sys/ipc.h> instead."
diff --git a/libc/sysdeps/linux/mips/bits/kernel_sigaction.h b/libc/sysdeps/linux/mips/bits/kernel_sigaction.h
index 5c8454837..65eff7c92 100644
--- a/libc/sysdeps/linux/mips/bits/kernel_sigaction.h
+++ b/libc/sysdeps/linux/mips/bits/kernel_sigaction.h
@@ -24,25 +24,4 @@ struct old_kernel_sigaction {
#endif
};
-
-#define _KERNEL_NSIG 128
-#define _KERNEL_NSIG_BPW _MIPS_SZLONG
-#define _KERNEL_NSIG_WORDS (_KERNEL_NSIG / _KERNEL_NSIG_BPW)
-
-typedef struct {
- unsigned long sig[_KERNEL_NSIG_WORDS];
-} kernel_sigset_t;
-
-/* This is the sigaction structure from the Linux 2.1.68 kernel. */
-struct kernel_sigaction {
- unsigned int sa_flags;
- __sighandler_t k_sa_handler;
- kernel_sigset_t sa_mask;
- void (*sa_restorer)(void);
- int s_resv[1]; /* reserved */
-};
-
-extern int __syscall_rt_sigaction (int, const struct kernel_sigaction *__unbounded,
- struct kernel_sigaction *__unbounded, size_t) attribute_hidden;
-
#endif
diff --git a/libc/sysdeps/linux/mips/bits/kernel_stat.h b/libc/sysdeps/linux/mips/bits/kernel_stat.h
index 3161562ea..a2a6169a3 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... */
@@ -12,6 +8,18 @@
#include <sgidefs.h>
#if _MIPS_SIM == _MIPS_SIM_ABI64
+typedef struct {
+ unsigned int tv_sec;
+ unsigned int tv_nsec;
+} __ktimespec_t;
+#else
+typedef struct {
+ time_t tv_sec;
+ unsigned long tv_nsec;
+} __ktimespec_t;
+#endif
+
+#if _MIPS_SIM == _MIPS_SIM_ABI64
/* The memory layout is the same as of struct stat64 of the 32-bit kernel. */
struct kernel_stat {
__kernel_dev_t st_dev;
@@ -24,12 +32,9 @@ struct kernel_stat {
__kernel_dev_t st_rdev;
unsigned int st_pad2[3];
__kernel_off_t st_size;
- unsigned int st_atime;
- unsigned int st_atime_nsec;
- unsigned int st_mtime;
- unsigned int st_mtime_nsec;
- unsigned int st_ctime;
- unsigned int st_ctime_nsec;
+ __ktimespec_t st_atim;
+ __ktimespec_t st_mtim;
+ __ktimespec_t st_ctim;
unsigned int st_blksize;
unsigned int reserved3;
unsigned long st_blocks;
@@ -48,12 +53,9 @@ struct kernel_stat {
unsigned int st_rdev;
unsigned int st_pad2[3];
unsigned long long st_size;
- unsigned int st_atime;
- unsigned int st_atime_nsec;
- unsigned int st_mtime;
- unsigned int st_mtime_nsec;
- unsigned int st_ctime;
- unsigned int st_ctime_nsec;
+ __ktimespec_t st_atim;
+ __ktimespec_t st_mtim;
+ __ktimespec_t st_ctim;
unsigned int st_blksize;
unsigned int reserved3;
unsigned long long st_blocks;
@@ -72,12 +74,9 @@ struct kernel_stat {
long st_pad2[2];
__kernel_off_t st_size;
long st_pad3;
- time_t st_atime;
- long st_atime_nsec;
- time_t st_mtime;
- long st_mtime_nsec;
- time_t st_ctime;
- long st_ctime_nsec;
+ __ktimespec_t st_atim;
+ __ktimespec_t st_mtim;
+ __ktimespec_t st_ctim;
long st_blksize;
long st_blocks;
long st_pad4[14];
@@ -94,19 +93,14 @@ struct kernel_stat64 {
unsigned long st_rdev;
unsigned long st_pad1[3]; /* Reserved for st_rdev expansion */
long long st_size;
- time_t st_atime;
- unsigned long st_atime_nsec;
- time_t st_mtime;
- unsigned long st_mtime_nsec;
- time_t st_ctime;
- unsigned long st_ctime_nsec;
+ __ktimespec_t st_atim;
+ __ktimespec_t st_mtim;
+ __ktimespec_t st_ctim;
unsigned long st_blksize;
unsigned long st_pad2;
long long st_blocks;
};
#endif /* O32 */
-#define STAT_HAVE_NSEC 1
-
#endif /* _BITS_STAT_STRUCT_H */
diff --git a/libc/sysdeps/linux/mips/bits/kernel_types.h b/libc/sysdeps/linux/mips/bits/kernel_types.h
index 9fc3b9672..97faeaca5 100644
--- a/libc/sysdeps/linux/mips/bits/kernel_types.h
+++ b/libc/sysdeps/linux/mips/bits/kernel_types.h
@@ -32,6 +32,8 @@ typedef int __kernel_gid32_t;
typedef __kernel_uid_t __kernel_old_uid_t;
typedef __kernel_gid_t __kernel_old_gid_t;
typedef __kernel_dev_t __kernel_old_dev_t;
+typedef long __kernel_long_t;
+typedef unsigned long __kernel_ulong_t;
typedef long long __kernel_loff_t;
#else
typedef unsigned int __kernel_dev_t;
@@ -68,6 +70,8 @@ typedef int __kernel_gid32_t;
typedef __kernel_uid_t __kernel_old_uid_t;
typedef __kernel_gid_t __kernel_old_gid_t;
typedef __kernel_dev_t __kernel_old_dev_t;
+typedef long __kernel_long_t;
+typedef unsigned long __kernel_ulong_t;
typedef long long __kernel_loff_t;
#endif
diff --git a/libc/sysdeps/linux/mips/bits/mathdef.h b/libc/sysdeps/linux/mips/bits/mathdef.h
index 331da13a9..6afe20d8a 100644
--- a/libc/sysdeps/linux/mips/bits/mathdef.h
+++ b/libc/sysdeps/linux/mips/bits/mathdef.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#if !defined _MATH_H && !defined _COMPLEX_H
# error "Never use <bits/mathdef.h> directly; include <math.h> instead"
@@ -26,10 +25,9 @@
#if defined __USE_ISOC99 && defined _MATH_H && !defined _MATH_H_MATHDEF
# define _MATH_H_MATHDEF 1
-/* Normally, there is no long double type and the `float' and `double'
- expressions are evaluated as `double'. */
-typedef double float_t; /* `float' expressions are evaluated as
- `double'. */
+/* MIPS has both `float' and `double' arithmetic. */
+typedef float float_t; /* `float' expressions are evaluated as
+ `float'. */
typedef double double_t; /* `double' expressions are evaluated as
`double'. */
diff --git a/libc/sysdeps/linux/mips/bits/mman.h b/libc/sysdeps/linux/mips/bits/mman.h
index 47d33933a..ca1497ebc 100644
--- a/libc/sysdeps/linux/mips/bits/mman.h
+++ b/libc/sysdeps/linux/mips/bits/mman.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_MMAN_H
# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
@@ -66,6 +65,8 @@
# define MAP_LOCKED 0x8000 /* pages are locked */
# define MAP_POPULATE 0x10000 /* populate (prefault) pagetables */
# define MAP_NONBLOCK 0x20000 /* do not block on IO */
+# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could
+ be uninitialized. */
#endif
/* Flags to `msync'. */
diff --git a/libc/sysdeps/linux/mips/bits/msq.h b/libc/sysdeps/linux/mips/bits/msq.h
index 2b0d38ec8..fe09cfadf 100644
--- a/libc/sysdeps/linux/mips/bits/msq.h
+++ b/libc/sysdeps/linux/mips/bits/msq.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_MSG_H
# error "Never use <bits/msq.h> directly; include <sys/msg.h> instead."
diff --git a/libc/sysdeps/linux/mips/bits/poll.h b/libc/sysdeps/linux/mips/bits/poll.h
index eee4ea253..c653d96e9 100644
--- a/libc/sysdeps/linux/mips/bits/poll.h
+++ b/libc/sysdeps/linux/mips/bits/poll.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_POLL_H
# error "Never use <bits/poll.h> directly; include <sys/poll.h> instead."
diff --git a/libc/sysdeps/linux/mips/bits/resource.h b/libc/sysdeps/linux/mips/bits/resource.h
index 1c8b99a93..b204aefd6 100644
--- a/libc/sysdeps/linux/mips/bits/resource.h
+++ b/libc/sysdeps/linux/mips/bits/resource.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_RESOURCE_H
# error "Never use <bits/resource.h> directly; include <sys/resource.h> instead."
diff --git a/libc/sysdeps/linux/mips/bits/sem.h b/libc/sysdeps/linux/mips/bits/sem.h
index 6282de9cc..4d412a2cb 100644
--- a/libc/sysdeps/linux/mips/bits/sem.h
+++ b/libc/sysdeps/linux/mips/bits/sem.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_SEM_H
# error "Never include <bits/sem.h> directly; use <sys/sem.h> instead."
diff --git a/libc/sysdeps/linux/mips/bits/setjmp.h b/libc/sysdeps/linux/mips/bits/setjmp.h
index 08e74fe0a..51f972e97 100644
--- a/libc/sysdeps/linux/mips/bits/setjmp.h
+++ b/libc/sysdeps/linux/mips/bits/setjmp.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _BITS_SETJMP_H
#define _BITS_SETJMP_H 1
@@ -26,13 +25,19 @@
#include <sgidefs.h>
+#if _MIPS_SIM == _MIPS_SIM_ABI32
+#define __ptr_size void *
+#else
+#define __ptr_size long long
+#endif
+
typedef struct
{
/* Program counter. */
- void * __pc;
+ __ptr_size __pc;
/* Stack pointer. */
- void * __sp;
+ __ptr_size __sp;
/* Callee-saved registers s0 through s7. */
#if _MIPS_SIM == _MIPS_SIM_ABI32
@@ -42,10 +47,10 @@ typedef struct
#endif
/* The frame pointer. */
- void * __fp;
+ __ptr_size __fp;
/* The global pointer. */
- void * __gp;
+ __ptr_size __gp;
/* Floating point status register. */
int __fpc_csr;
@@ -58,15 +63,4 @@ typedef struct
#endif /* N32 || O32 */
} __jmp_buf[1];
-#ifdef __USE_MISC
-/* Offset to the program counter in `jmp_buf'. */
-# define JB_PC 0
-#endif
-
-
-/* Test if longjmp to JMPBUF would unwind the frame
- containing a local variable at ADDRESS. */
-#define _JMPBUF_UNWINDS(jmpbuf, address) \
- ((void *) (address) < (void *) (jmpbuf)[0].__sp)
-
#endif /* bits/setjmp.h */
diff --git a/libc/sysdeps/linux/mips/bits/shm.h b/libc/sysdeps/linux/mips/bits/shm.h
index b3083346d..43869b3f4 100644
--- a/libc/sysdeps/linux/mips/bits/shm.h
+++ b/libc/sysdeps/linux/mips/bits/shm.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_SHM_H
# error "Never include <bits/shm.h> directly; use <sys/shm.h> instead."
diff --git a/libc/sysdeps/linux/mips/bits/sigaction.h b/libc/sysdeps/linux/mips/bits/sigaction.h
index d04e25f76..533d45d10 100644
--- a/libc/sysdeps/linux/mips/bits/sigaction.h
+++ b/libc/sysdeps/linux/mips/bits/sigaction.h
@@ -14,46 +14,30 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SIGNAL_H
# error "Never include <bits/sigaction.h> directly; use <signal.h> instead."
#endif
/* Structure describing the action to be taken when a signal arrives. */
-struct sigaction
- {
- /* Special flags. */
- unsigned int sa_flags;
-
- /* Signal handler. */
+struct sigaction {
+ unsigned sa_flags;
#ifdef __USE_POSIX199309
- union
- {
- /* Used if SA_SIGINFO is not set. */
- __sighandler_t sa_handler;
- /* Used if SA_SIGINFO is set. */
- void (*sa_sigaction) (int, siginfo_t *, void *);
- }
- __sigaction_handler;
-# define sa_handler __sigaction_handler.sa_handler
-# define sa_sigaction __sigaction_handler.sa_sigaction
+ union {
+ __sighandler_t sa_handler;
+ void (*sa_sigaction)(int, siginfo_t *, void *);
+ } __sigaction_handler;
+# define sa_handler __sigaction_handler.sa_handler
+# define sa_sigaction __sigaction_handler.sa_sigaction
#else
- __sighandler_t sa_handler;
-#endif
- /* Additional set of signals to be blocked. */
- __sigset_t sa_mask;
-
- /* The ABI says here are two unused ints following. */
- /* Restore handler. */
- void (*sa_restorer) (void);
-
-#if _MIPS_SZPTR < 64
- int sa_resv[1];
+ __sighandler_t sa_handler;
#endif
- };
+ sigset_t sa_mask;
+ void (*sa_restorer)(void);
+ /*int s_resv[1]; - reserved [deleted in uclibc] */
+};
/* Bits in `sa_flags'. */
/* Please note that some Linux kernels versions use different values for these
diff --git a/libc/sysdeps/linux/mips/bits/sigcontext.h b/libc/sysdeps/linux/mips/bits/sigcontext.h
index 99faeed39..dd18c49a6 100644
--- a/libc/sysdeps/linux/mips/bits/sigcontext.h
+++ b/libc/sysdeps/linux/mips/bits/sigcontext.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _BITS_SIGCONTEXT_H
#define _BITS_SIGCONTEXT_H 1
diff --git a/libc/sysdeps/linux/mips/bits/sigcontextinfo.h b/libc/sysdeps/linux/mips/bits/sigcontextinfo.h
index f453c8d9b..09ce0185e 100644
--- a/libc/sysdeps/linux/mips/bits/sigcontextinfo.h
+++ b/libc/sysdeps/linux/mips/bits/sigcontextinfo.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <sgidefs.h>
diff --git a/libc/sysdeps/linux/mips/bits/siginfo.h b/libc/sysdeps/linux/mips/bits/siginfo.h
index ba3e1f630..b204301af 100644
--- a/libc/sysdeps/linux/mips/bits/siginfo.h
+++ b/libc/sysdeps/linux/mips/bits/siginfo.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#if !defined _SIGNAL_H && !defined __need_siginfo_t \
&& !defined __need_sigevent_t
@@ -70,6 +69,22 @@ typedef struct siginfo
__uid_t si_uid; /* Real user ID of sending process. */
} _kill;
+ /* POSIX.1b timers. */
+ struct
+ {
+ int si_tid; /* Timer ID. */
+ int si_overrun; /* Overrun count. */
+ sigval_t si_sigval; /* Signal value. */
+ } _timer;
+
+ /* POSIX.1b signals. */
+ struct
+ {
+ __pid_t si_pid; /* Sending process ID. */
+ __uid_t si_uid; /* Real user ID of sending process. */
+ sigval_t si_sigval; /* Signal value. */
+ } _rt;
+
/* SIGCHLD. */
struct
{
@@ -84,29 +99,23 @@ typedef struct siginfo
struct
{
void *si_addr; /* Faulting insn/memory ref. */
+ short int si_addr_lsb; /* Valid LSB of the reported address. */
} _sigfault;
/* SIGPOLL. */
struct
{
- int si_band; /* Band event for SIGPOLL. */
+ long int si_band; /* Band event for SIGPOLL. */
int si_fd;
} _sigpoll;
- /* POSIX.1b timers. */
+ /* SIGSYS. */
struct
{
- unsigned int _timer1;
- unsigned int _timer2;
- } _timer;
-
- /* POSIX.1b signals. */
- struct
- {
- __pid_t si_pid; /* Sending process ID. */
- __uid_t si_uid; /* Real user ID of sending process. */
- sigval_t si_sigval; /* Signal value. */
- } _rt;
+ void *_call_addr; /* Calling user insn. */
+ int _syscall; /* Triggering system call number. */
+ unsigned int _arch; /* AUDIT_ARCH_* of syscall. */
+ } _sigsys;
} _sifields;
} siginfo_t;
@@ -114,6 +123,8 @@ typedef struct siginfo
/* X/Open requires some more fields with fixed names. */
# define si_pid _sifields._kill.si_pid
# define si_uid _sifields._kill.si_uid
+# define si_timerid _sifields._timer.si_tid
+# define si_overrun _sifields._timer.si_overrun
# define si_status _sifields._sigchld.si_status
# define si_utime _sifields._sigchld.si_utime
# define si_stime _sifields._sigchld.si_stime
@@ -121,8 +132,12 @@ typedef struct siginfo
# define si_int _sifields._rt.si_sigval.sival_int
# define si_ptr _sifields._rt.si_sigval.sival_ptr
# define si_addr _sifields._sigfault.si_addr
+# define si_addr_lsb _sifields._sigfault.si_addr_lsb
# define si_band _sifields._sigpoll.si_band
# define si_fd _sifields._sigpoll.si_fd
+# define si_call_addr _sifields._sigsys._call_addr
+# define si_syscall _sifields._sigsys._syscall
+# define si_arch _sifields._sigsys._arch
/* Values for `si_code'. Positive values are reserved for kernel-generated
@@ -143,13 +158,14 @@ enum
# define SI_ASYNCIO SI_ASYNCIO
SI_QUEUE, /* Sent by sigqueue. */
# define SI_QUEUE SI_QUEUE
- SI_USER, /* Sent by kill, sigsend, raise. */
+ SI_USER, /* Sent by kill, sigsend. */
# define SI_USER SI_USER
SI_KERNEL = 0x80 /* Send by kernel. */
#define SI_KERNEL SI_KERNEL
};
+# if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
/* `si_code' values for SIGILL signal. */
enum
{
@@ -208,10 +224,16 @@ enum
# define BUS_ADRALN BUS_ADRALN
BUS_ADRERR, /* Non-existant physical address. */
# define BUS_ADRERR BUS_ADRERR
- BUS_OBJERR /* Object specific hardware error. */
+ BUS_OBJERR, /* Object specific hardware error. */
# define BUS_OBJERR BUS_OBJERR
+ BUS_MCEERR_AR, /* Hardware memory error: action required. */
+# define BUS_MCEERR_AR BUS_MCEERR_AR
+ BUS_MCEERR_AO /* Hardware memory error: action optional. */
+# define BUS_MCEERR_AO BUS_MCEERR_AO
};
+# endif
+# ifdef __USE_XOPEN_EXTENDED
/* `si_code' values for SIGTRAP signal. */
enum
{
@@ -220,7 +242,9 @@ enum
TRAP_TRACE /* Process trace trap. */
# define TRAP_TRACE TRAP_TRACE
};
+# endif
+# if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
/* `si_code' values for SIGCHLD signal. */
enum
{
@@ -254,6 +278,7 @@ enum
POLL_HUP /* Device disconnected. */
# define POLL_HUP POLL_HUP
};
+# endif
# undef __need_siginfo_t
#endif /* !have siginfo_t && (have _SIGNAL_H || need siginfo_t). */
@@ -265,8 +290,11 @@ enum
/* Structure to transport application-defined values with signals. */
# define __SIGEV_MAX_SIZE 64
-# define __SIGEV_HEAD_SIZE (sizeof(long) + 2*sizeof(int))
-# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE - __SIGEV_HEAD_SIZE) / sizeof (int))
+# if __WORDSIZE == 64
+# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 4)
+# else
+# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 3)
+# endif
/* Forward declaration of the `pthread_attr_t' type. */
struct __pthread_attr_s;
@@ -282,6 +310,10 @@ typedef struct sigevent
{
int _pad[__SIGEV_PAD_SIZE];
+ /* When SIGEV_SIGNAL and SIGEV_THREAD_ID set, LWP ID of the
+ thread to receive the signal. */
+ __pid_t _tid;
+
struct
{
void (*_function) (sigval_t); /* Function to start. */
diff --git a/libc/sysdeps/linux/mips/bits/signalfd.h b/libc/sysdeps/linux/mips/bits/signalfd.h
new file mode 100644
index 000000000..c2bea7605
--- /dev/null
+++ b/libc/sysdeps/linux/mips/bits/signalfd.h
@@ -0,0 +1,29 @@
+/* Copyright (C) 2007-2012 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_SIGNALFD_H
+# error "Never use <bits/signalfd.h> directly; include <sys/signalfd.h> instead."
+#endif
+
+/* Flags for signalfd. */
+enum
+ {
+ SFD_CLOEXEC = 02000000,
+#define SFD_CLOEXEC SFD_CLOEXEC
+ SFD_NONBLOCK = 00000200
+#define SFD_NONBLOCK SFD_NONBLOCK
+ };
diff --git a/libc/sysdeps/linux/mips/bits/signum.h b/libc/sysdeps/linux/mips/bits/signum.h
index a9b684834..e83250e2d 100644
--- a/libc/sysdeps/linux/mips/bits/signum.h
+++ b/libc/sysdeps/linux/mips/bits/signum.h
@@ -13,22 +13,11 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifdef _SIGNAL_H
-/* Fake signal functions. */
-#define SIG_ERR ((__sighandler_t) -1) /* Error return. */
-#define SIG_DFL ((__sighandler_t) 0) /* Default action. */
-#define SIG_IGN ((__sighandler_t) 1) /* Ignore signal. */
-
-#ifdef __USE_UNIX98
-# define SIG_HOLD ((__sighandler_t) 2) /* Add signal to hold mask. */
-#endif
-
-
#define SIGHUP 1 /* Hangup (POSIX). */
#define SIGINT 2 /* Interrupt (ANSI). */
#define SIGQUIT 3 /* Quit (POSIX). */
@@ -64,16 +53,20 @@
#define SIGXCPU 30 /* CPU limit exceeded (4.2 BSD). */
#define SIGXFSZ 31 /* File size limit exceeded (4.2 BSD). */
-
-#define _NSIG 128 /* Biggest signal number + 1
- (including real-time signals). */
-
-#define SIGRTMIN (__libc_current_sigrtmin ())
-#define SIGRTMAX (__libc_current_sigrtmax ())
-
-/* These are the hard limits of the kernel. These values should not be
- used directly at user level. */
-#define __SIGRTMIN 32
-#define __SIGRTMAX (_NSIG - 1)
+/* MIPS is special by having 128 signals.
+ * All (?) other architectures have at most 64 signals.
+ * Having 128 signals is problematic because signal nos are 1-based
+ * and last signal number is then 128.
+ * This plays havoc with WIFSIGNALED and WCOREDUMP in waitpid status word,
+ * when process dies from signal 128.
+ * Linux kernel 3.9 accepts signal 128, with awful results :/
+ * It is being fixed.
+ *
+ * glibc (accidentally?) papers over this issue by declaring _NSIG to be 128,
+ * not 129 (despite claiming that _NSIG is "biggest signal number + 1"
+ * in the comment above that definition). We follow suit.
+ * Note that this results in __SIGRTMAX == 127. It is intended.
+ */
+#define _NSIG 128
#endif /* <signal.h> included. */
diff --git a/libc/sysdeps/linux/mips/bits/sigstack.h b/libc/sysdeps/linux/mips/bits/sigstack.h
index d2c855220..b5a92f398 100644
--- a/libc/sysdeps/linux/mips/bits/sigstack.h
+++ b/libc/sysdeps/linux/mips/bits/sigstack.h
@@ -13,21 +13,22 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SIGNAL_H
# error "Never include this file directly. Use <signal.h> instead"
#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
deleted file mode 100644
index c43a4cd2e..000000000
--- a/libc/sysdeps/linux/mips/bits/socket.h
+++ /dev/null
@@ -1,328 +0,0 @@
-/* System-specific socket constants and types. Linux/MIPS version.
- Copyright (C) 1991, 92, 1994-1999, 2000, 2001, 2004, 2005, 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 __BITS_SOCKET_H
-#define __BITS_SOCKET_H
-
-#if !defined _SYS_SOCKET_H && !defined _NETINET_IN_H
-# error "Never include <bits/socket.h> directly; use <sys/socket.h> instead."
-#endif
-
-#define __need_size_t
-#define __need_NULL
-#include <stddef.h>
-
-#include <limits.h>
-#include <sys/types.h>
-
-/* Type for length arguments in socket calls. */
-#ifndef __socklen_t_defined
-typedef __socklen_t socklen_t;
-# define __socklen_t_defined
-#endif
-
-/* Types of sockets. */
-enum __socket_type
-{
- SOCK_DGRAM = 1, /* Connectionless, unreliable datagrams
- of fixed maximum length. */
-#define SOCK_DGRAM SOCK_DGRAM
- SOCK_STREAM = 2, /* Sequenced, reliable, connection-based
- byte streams. */
-#define SOCK_STREAM SOCK_STREAM
- SOCK_RAW = 3, /* Raw protocol interface. */
-#define SOCK_RAW SOCK_RAW
- SOCK_RDM = 4, /* Reliably-delivered messages. */
-#define SOCK_RDM SOCK_RDM
- SOCK_SEQPACKET = 5, /* Sequenced, reliable, connection-based,
- datagrams of fixed maximum length. */
-#define SOCK_SEQPACKET SOCK_SEQPACKET
- SOCK_PACKET = 10 /* Linux specific way of getting packets
- at the dev level. For writing rarp and
- other similar things on the user level. */
-#define SOCK_PACKET SOCK_PACKET
-};
-
-/* Protocol families. */
-#define PF_UNSPEC 0 /* Unspecified. */
-#define PF_LOCAL 1 /* Local to host (pipes and file-domain). */
-#define PF_UNIX PF_LOCAL /* Old BSD name for PF_LOCAL. */
-#define PF_FILE PF_LOCAL /* Another non-standard name for PF_LOCAL. */
-#define PF_INET 2 /* IP protocol family. */
-#define PF_AX25 3 /* Amateur Radio AX.25. */
-#define PF_IPX 4 /* Novell Internet Protocol. */
-#define PF_APPLETALK 5 /* Appletalk DDP. */
-#define PF_NETROM 6 /* Amateur radio NetROM. */
-#define PF_BRIDGE 7 /* Multiprotocol bridge. */
-#define PF_ATMPVC 8 /* ATM PVCs. */
-#define PF_X25 9 /* Reserved for X.25 project. */
-#define PF_INET6 10 /* IP version 6. */
-#define PF_ROSE 11 /* Amateur Radio X.25 PLP. */
-#define PF_DECnet 12 /* Reserved for DECnet project. */
-#define PF_NETBEUI 13 /* Reserved for 802.2LLC project. */
-#define PF_SECURITY 14 /* Security callback pseudo AF. */
-#define PF_KEY 15 /* PF_KEY key management API. */
-#define PF_NETLINK 16
-#define PF_ROUTE PF_NETLINK /* Alias to emulate 4.4BSD. */
-#define PF_PACKET 17 /* Packet family. */
-#define PF_ASH 18 /* Ash. */
-#define PF_ECONET 19 /* Acorn Econet. */
-#define PF_ATMSVC 20 /* ATM SVCs. */
-#define PF_SNA 22 /* Linux SNA Project */
-#define PF_IRDA 23 /* IRDA sockets. */
-#define PF_PPPOX 24 /* PPPoX sockets. */
-#define PF_WANPIPE 25 /* Wanpipe API sockets. */
-#define PF_BLUETOOTH 31 /* Bluetooth sockets. */
-#define PF_MAX 32 /* For now.. */
-
-/* Address families. */
-#define AF_UNSPEC PF_UNSPEC
-#define AF_LOCAL PF_LOCAL
-#define AF_UNIX PF_UNIX
-#define AF_FILE PF_FILE
-#define AF_INET PF_INET
-#define AF_AX25 PF_AX25
-#define AF_IPX PF_IPX
-#define AF_APPLETALK PF_APPLETALK
-#define AF_NETROM PF_NETROM
-#define AF_BRIDGE PF_BRIDGE
-#define AF_ATMPVC PF_ATMPVC
-#define AF_X25 PF_X25
-#define AF_INET6 PF_INET6
-#define AF_ROSE PF_ROSE
-#define AF_DECnet PF_DECnet
-#define AF_NETBEUI PF_NETBEUI
-#define AF_SECURITY PF_SECURITY
-#define AF_KEY PF_KEY
-#define AF_NETLINK PF_NETLINK
-#define AF_ROUTE PF_ROUTE
-#define AF_PACKET PF_PACKET
-#define AF_ASH PF_ASH
-#define AF_ECONET PF_ECONET
-#define AF_ATMSVC PF_ATMSVC
-#define AF_SNA PF_SNA
-#define AF_IRDA PF_IRDA
-#define AF_PPPOX PF_PPPOX
-#define AF_WANPIPE PF_WANPIPE
-#define AF_BLUETOOTH PF_BLUETOOTH
-#define AF_MAX PF_MAX
-
-/* Socket level values. Others are defined in the appropriate headers.
-
- XXX These definitions also should go into the appropriate headers as
- far as they are available. */
-#define SOL_RAW 255
-#define SOL_DECNET 261
-#define SOL_X25 262
-#define SOL_PACKET 263
-#define SOL_ATM 264 /* ATM layer (cell level). */
-#define SOL_AAL 265 /* ATM Adaption Layer (packet level). */
-#define SOL_IRDA 266
-
-/* Maximum queue length specifiable by listen. */
-#define SOMAXCONN 128
-
-/* Get the definition of the macro to define the common sockaddr members. */
-#include <bits/sockaddr.h>
-
-/* Structure describing a generic socket address. */
-struct sockaddr
- {
- __SOCKADDR_COMMON (sa_); /* Common data: address family and length. */
- char sa_data[14]; /* Address data. */
- };
-
-
-/* Structure large enough to hold any socket address (with the historical
- exception of AF_UNIX). We reserve 128 bytes. */
-#if ULONG_MAX > 0xffffffff
-# define __ss_aligntype __uint64_t
-#else
-# define __ss_aligntype __uint32_t
-#endif
-#define _SS_SIZE 128
-#define _SS_PADSIZE (_SS_SIZE - (2 * sizeof (__ss_aligntype)))
-
-struct sockaddr_storage
- {
- __SOCKADDR_COMMON (ss_); /* Address family, etc. */
- __ss_aligntype __ss_align; /* Force desired alignment. */
- char __ss_padding[_SS_PADSIZE];
- };
-
-
-/* Bits in the FLAGS argument to `send', `recv', et al. */
-enum
- {
- MSG_OOB = 0x01, /* Process out-of-band data. */
-#define MSG_OOB MSG_OOB
- MSG_PEEK = 0x02, /* Peek at incoming messages. */
-#define MSG_PEEK MSG_PEEK
- MSG_DONTROUTE = 0x04, /* Don't use local routing. */
-#define MSG_DONTROUTE MSG_DONTROUTE
-#ifdef __USE_GNU
- /* DECnet uses a different name. */
- MSG_TRYHARD = MSG_DONTROUTE,
-# define MSG_TRYHARD MSG_DONTROUTE
-#endif
- MSG_CTRUNC = 0x08, /* Control data lost before delivery. */
-#define MSG_CTRUNC MSG_CTRUNC
- MSG_PROXY = 0x10, /* Supply or ask second address. */
-#define MSG_PROXY MSG_PROXY
- MSG_TRUNC = 0x20,
-#define MSG_TRUNC MSG_TRUNC
- MSG_DONTWAIT = 0x40, /* Nonblocking IO. */
-#define MSG_DONTWAIT MSG_DONTWAIT
- MSG_EOR = 0x80, /* End of record. */
-#define MSG_EOR MSG_EOR
- MSG_WAITALL = 0x100, /* Wait for a full request. */
-#define MSG_WAITALL MSG_WAITALL
- MSG_FIN = 0x200,
-#define MSG_FIN MSG_FIN
- MSG_SYN = 0x400,
-#define MSG_SYN MSG_SYN
- MSG_CONFIRM = 0x800, /* Confirm path validity. */
-#define MSG_CONFIRM MSG_CONFIRM
- MSG_RST = 0x1000,
-#define MSG_RST MSG_RST
- MSG_ERRQUEUE = 0x2000, /* Fetch message from error queue. */
-#define MSG_ERRQUEUE MSG_ERRQUEUE
- MSG_NOSIGNAL = 0x4000, /* Do not generate SIGPIPE. */
-#define MSG_NOSIGNAL MSG_NOSIGNAL
- MSG_MORE = 0x8000 /* Sender will send more. */
-#define MSG_MORE MSG_MORE
- };
-
-
-/* Structure describing messages sent by
- `sendmsg' and received by `recvmsg'. */
-/* Note: do not change these members to match glibc; these match the
- SuSv3 spec already (e.g. msg_iovlen/msg_controllen).
- http://www.opengroup.org/onlinepubs/009695399/basedefs/sys/socket.h.html */
-/* Note: linux kernel uses __kernel_size_t (which is 8bytes on 64bit
- platforms, and 4bytes on 32bit platforms) for msg_iovlen/msg_controllen */
-struct msghdr
- {
- void *msg_name; /* Address to send to/receive from. */
- socklen_t msg_namelen; /* Length of address data. */
-
- struct iovec *msg_iov; /* Vector of data to send/receive into. */
-#if __WORDSIZE == 32
- int msg_iovlen; /* Number of elements in the vector. */
-#else
- size_t msg_iovlen; /* Number of elements in the vector. */
-#endif
-
- void *msg_control; /* Ancillary data (eg BSD filedesc passing). */
-#if __WORDSIZE == 32
- socklen_t msg_controllen; /* Ancillary data buffer length. */
-#else
- size_t msg_controllen; /* Ancillary data buffer length. */
-#endif
-
- int msg_flags; /* Flags on received message. */
- };
-
-/* Structure used for storage of ancillary data object information. */
-struct cmsghdr
- {
- size_t cmsg_len; /* Length of data in cmsg_data plus length
- of cmsghdr structure. */
- int cmsg_level; /* Originating protocol. */
- int cmsg_type; /* Protocol specific type. */
-#if (!defined __STRICT_ANSI__ && __GNUC__ >= 2) || __STDC_VERSION__ >= 199901L
- __extension__ unsigned char __cmsg_data __flexarr; /* Ancillary data. */
-#endif
- };
-
-/* Ancillary data object manipulation macros. */
-#if (!defined __STRICT_ANSI__ && __GNUC__ >= 2) || __STDC_VERSION__ >= 199901L
-# define CMSG_DATA(cmsg) ((cmsg)->__cmsg_data)
-#else
-# define CMSG_DATA(cmsg) ((unsigned char *) ((struct cmsghdr *) (cmsg) + 1))
-#endif
-#define CMSG_NXTHDR(mhdr, cmsg) __cmsg_nxthdr (mhdr, cmsg)
-#define CMSG_FIRSTHDR(mhdr) \
- ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) \
- ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) NULL)
-#define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) \
- & (size_t) ~(sizeof (size_t) - 1))
-#define CMSG_SPACE(len) (CMSG_ALIGN (len) \
- + CMSG_ALIGN (sizeof (struct cmsghdr)))
-#define CMSG_LEN(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len))
-
-extern struct cmsghdr * __NTH (__cmsg_nxthdr (struct msghdr *__mhdr,
- struct cmsghdr *__cmsg)) __THROW;
-#ifdef __USE_EXTERN_INLINES
-# ifndef _EXTERN_INLINE
-# define _EXTERN_INLINE extern __inline
-# endif
-_EXTERN_INLINE struct cmsghdr *
-__NTH (__cmsg_nxthdr (struct msghdr *__mhdr, struct cmsghdr *__cmsg))
-{
- if ((size_t) __cmsg->cmsg_len < sizeof (struct cmsghdr))
- /* The kernel header does this so there may be a reason. */
- return 0;
-
- __cmsg = (struct cmsghdr *) ((unsigned char *) __cmsg
- + CMSG_ALIGN (__cmsg->cmsg_len));
- if ((unsigned char *) (__cmsg + 1) > ((unsigned char *) __mhdr->msg_control
- + __mhdr->msg_controllen)
- || ((unsigned char *) __cmsg + CMSG_ALIGN (__cmsg->cmsg_len)
- > ((unsigned char *) __mhdr->msg_control + __mhdr->msg_controllen)))
- /* No more entries. */
- return 0;
- return __cmsg;
-}
-#endif /* Use `extern inline'. */
-
-/* Socket level message types. This must match the definitions in
- <linux/socket.h>. */
-enum
- {
- SCM_RIGHTS = 0x01 /* Transfer file descriptors. */
-#define SCM_RIGHTS SCM_RIGHTS
-#ifdef __USE_BSD
- , SCM_CREDENTIALS = 0x02 /* Credentials passing. */
-# define SCM_CREDENTIALS SCM_CREDENTIALS
-#endif
- };
-
-/* User visible structure for SCM_CREDENTIALS message */
-
-struct ucred
-{
- pid_t pid; /* PID of sending process. */
- uid_t uid; /* UID of sending process. */
- gid_t gid; /* GID of sending process. */
-};
-
-/* Get socket manipulation related informations from kernel headers. */
-#include <asm/socket.h>
-
-
-/* Structure used to manipulate the SO_LINGER option. */
-struct linger
- {
- int l_onoff; /* Nonzero to linger on close. */
- int l_linger; /* Time to linger. */
- };
-
-#endif /* bits/socket.h */
diff --git a/libc/sysdeps/linux/mips/bits/socket_type.h b/libc/sysdeps/linux/mips/bits/socket_type.h
new file mode 100644
index 000000000..20d27328e
--- /dev/null
+++ b/libc/sysdeps/linux/mips/bits/socket_type.h
@@ -0,0 +1,55 @@
+/* System-specific socket constants and types. Linux/MIPS version.
+ Copyright (C) 1991, 92, 1994-1999, 2000, 2001, 2004, 2005, 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_SOCKET_H
+# error "Never include <bits/socket_type.h> directly; use <sys/socket.h> instead."
+#endif
+
+/* Types of sockets. */
+enum __socket_type
+{
+ SOCK_DGRAM = 1, /* Connectionless, unreliable datagrams
+ of fixed maximum length. */
+#define SOCK_DGRAM SOCK_DGRAM
+ SOCK_STREAM = 2, /* Sequenced, reliable, connection-based
+ byte streams. */
+#define SOCK_STREAM SOCK_STREAM
+ SOCK_RAW = 3, /* Raw protocol interface. */
+#define SOCK_RAW SOCK_RAW
+ SOCK_RDM = 4, /* Reliably-delivered messages. */
+#define SOCK_RDM SOCK_RDM
+ SOCK_SEQPACKET = 5, /* Sequenced, reliable, connection-based,
+ datagrams of fixed maximum length. */
+#define SOCK_SEQPACKET SOCK_SEQPACKET
+ SOCK_DCCP = 6,
+#define SOCK_DCCP SOCK_DCCP /* Datagram Congestion Control Protocol. */
+ SOCK_PACKET = 10, /* Linux specific way of getting packets
+ at the dev level. For writing rarp and
+ other similar things on the user level. */
+#define SOCK_PACKET SOCK_PACKET
+
+ /* Flags to be ORed into the type parameter of socket and socketpair. */
+
+ SOCK_CLOEXEC = 02000000, /* Atomically set close-on-exec flag for the
+ new descriptor(s). */
+#define SOCK_CLOEXEC SOCK_CLOEXEC
+ SOCK_NONBLOCK = 00000200 /* Atomically mark descriptor(s) as
+ non-blocking. */
+#define SOCK_NONBLOCK SOCK_NONBLOCK
+};
diff --git a/libc/sysdeps/linux/mips/bits/stackinfo.h b/libc/sysdeps/linux/mips/bits/stackinfo.h
index 86e3d621b..7803dccf7 100644
--- a/libc/sysdeps/linux/mips/bits/stackinfo.h
+++ b/libc/sysdeps/linux/mips/bits/stackinfo.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* This file contains a bit of information about the stack allocation
of the processor. */
diff --git a/libc/sysdeps/linux/mips/bits/stat.h b/libc/sysdeps/linux/mips/bits/stat.h
index e35d64928..539fa33d2 100644
--- a/libc/sysdeps/linux/mips/bits/stat.h
+++ b/libc/sysdeps/linux/mips/bits/stat.h
@@ -1,5 +1,5 @@
-/* Copyright (C) 1992, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004
- Free Software Foundation, Inc.
+/* Copyright (C) 1992, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004,
+ 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
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_STAT_H
# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
@@ -61,16 +60,27 @@ struct stat
long int st_pad2[2];
__off64_t st_size; /* Size of file, in bytes. */
#endif
- /*
- * Actually this should be timestruc_t st_atime, st_mtime and
- * st_ctime but we don't have it under Linux.
- */
+#ifdef __USE_MISC
+ /* Nanosecond resolution timestamps are stored in a format
+ equivalent to 'struct timespec'. This is the type used
+ whenever possible but the Unix namespace rules do not allow the
+ identifier 'timespec' to appear in the <sys/stat.h> header.
+ Therefore we have to handle the use of this header in strictly
+ standard-compliant sources special. */
+ struct timespec st_atim; /* Time of last access. */
+ struct timespec st_mtim; /* Time of last modification. */
+ struct timespec st_ctim; /* Time of last status change. */
+# define st_atime st_atim.tv_sec /* Backward compatibility. */
+# define st_mtime st_mtim.tv_sec
+# define st_ctime st_ctim.tv_sec
+#else
__time_t st_atime; /* Time of last access. */
unsigned long int st_atimensec; /* Nscecs of last access. */
__time_t st_mtime; /* Time of last modification. */
unsigned long int st_mtimensec; /* Nsecs of last modification. */
__time_t st_ctime; /* Time of last status change. */
unsigned long int st_ctimensec; /* Nsecs of last status change. */
+#endif
__blksize_t st_blksize; /* Optimal block size for I/O. */
#ifndef __USE_FILE_OFFSET64
__blkcnt_t st_blocks; /* Number of 512-byte blocks allocated. */
@@ -93,16 +103,27 @@ struct stat {
unsigned int st_rdev; /* Device number, if device. */
int st_pad2[3];
__off_t st_size; /* Size of file, in bytes. */
- /*
- * Actually this should be timestruc_t st_atime, st_mtime and
- * st_ctime but we don't have it under Linux.
- */
+#ifdef __USE_MISC
+ /* Nanosecond resolution timestamps are stored in a format
+ equivalent to 'struct timespec'. This is the type used
+ whenever possible but the Unix namespace rules do not allow the
+ identifier 'timespec' to appear in the <sys/stat.h> header.
+ Therefore we have to handle the use of this header in strictly
+ standard-compliant sources special. */
+ struct timespec st_atim; /* Time of last access. */
+ struct timespec st_mtim; /* Time of last modification. */
+ struct timespec st_ctim; /* Time of last status change. */
+# define st_atime st_atim.tv_sec /* Backward compatibility. */
+# define st_mtime st_mtim.tv_sec
+# define st_ctime st_ctim.tv_sec
+#else
int st_atime;
int st_atimensec;
int st_mtime;
int st_mtimensec;
int st_ctime;
int st_ctimensec;
+#endif
int st_blksize; /* Optimal block size for I/O. */
int st_pad3;
__blkcnt_t st_blocks; /* Number of 512-byte blocks allocated. */
@@ -124,16 +145,27 @@ struct stat64
__dev_t st_rdev; /* Device number, if device. */
long int st_pad2[2];
__off64_t st_size; /* Size of file, in bytes. */
- /*
- * Actually this should be timestruc_t st_atime, st_mtime and
- * st_ctime but we don't have it under Linux.
- */
+#ifdef __USE_MISC
+ /* Nanosecond resolution timestamps are stored in a format
+ equivalent to 'struct timespec'. This is the type used
+ whenever possible but the Unix namespace rules do not allow the
+ identifier 'timespec' to appear in the <sys/stat.h> header.
+ Therefore we have to handle the use of this header in strictly
+ standard-compliant sources special. */
+ struct timespec st_atim; /* Time of last access. */
+ struct timespec st_mtim; /* Time of last modification. */
+ struct timespec st_ctim; /* Time of last status change. */
+# define st_atime st_atim.tv_sec /* Backward compatibility. */
+# define st_mtime st_mtim.tv_sec
+# define st_ctime st_ctim.tv_sec
+#else
__time_t st_atime; /* Time of last access. */
unsigned long int st_atimensec; /* Nscecs of last access. */
__time_t st_mtime; /* Time of last modification. */
unsigned long int st_mtimensec; /* Nsecs of last modification. */
__time_t st_ctime; /* Time of last status change. */
unsigned long int st_ctimensec; /* Nsecs of last status change. */
+#endif
__blksize_t st_blksize; /* Optimal block size for I/O. */
long int st_pad3;
__blkcnt64_t st_blocks; /* Number of 512-byte blocks allocated. */
@@ -152,16 +184,27 @@ struct stat64 {
unsigned int st_rdev; /* Device number, if device. */
int st_pad2[3];
__off_t st_size; /* Size of file, in bytes. */
- /*
- * Actually this should be timestruc_t st_atime, st_mtime and
- * st_ctime but we don't have it under Linux.
- */
+#ifdef __USE_MISC
+ /* Nanosecond resolution timestamps are stored in a format
+ equivalent to 'struct timespec'. This is the type used
+ whenever possible but the Unix namespace rules do not allow the
+ identifier 'timespec' to appear in the <sys/stat.h> header.
+ Therefore we have to handle the use of this header in strictly
+ standard-compliant sources special. */
+ struct timespec st_atim; /* Time of last access. */
+ struct timespec st_mtim; /* Time of last modification. */
+ struct timespec st_ctim; /* Time of last status change. */
+# define st_atime st_atim.tv_sec /* Backward compatibility. */
+# define st_mtime st_mtim.tv_sec
+# define st_ctime st_ctim.tv_sec
+#else
int st_atime;
int st_atimensec;
int st_mtime;
int st_mtimensec;
int st_ctime;
int st_ctimensec;
+#endif
int st_blksize; /* Optimal block size for I/O. */
int st_pad3;
__blkcnt_t st_blocks; /* Number of 512-byte blocks allocated. */
@@ -173,6 +216,8 @@ struct stat64 {
/* Tell code we have these members. */
#define _STATBUF_ST_BLKSIZE
#define _STATBUF_ST_RDEV
+/* Nanosecond resolution time values are supported. */
+#define _STATBUF_ST_NSEC
/* Encoding of the file mode. */
@@ -201,3 +246,8 @@ struct stat64 {
#define __S_IREAD 0400 /* Read by owner. */
#define __S_IWRITE 0200 /* Write by owner. */
#define __S_IEXEC 0100 /* Execute by owner. */
+
+#ifdef __USE_ATFILE
+# define UTIME_NOW ((1l << 30) - 1l)
+# define UTIME_OMIT ((1l << 30) - 2l)
+#endif
diff --git a/libc/sysdeps/linux/mips/bits/statfs.h b/libc/sysdeps/linux/mips/bits/statfs.h
index 2f9bd54ed..8e2ebc6ac 100644
--- a/libc/sysdeps/linux/mips/bits/statfs.h
+++ b/libc/sysdeps/linux/mips/bits/statfs.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_STATFS_H
# error "Never include <bits/statfs.h> directly; use <sys/statfs.h> instead."
diff --git a/libc/sysdeps/linux/mips/bits/syscalls.h b/libc/sysdeps/linux/mips/bits/syscalls.h
index fa8b876d7..787bb7d55 100644
--- a/libc/sysdeps/linux/mips/bits/syscalls.h
+++ b/libc/sysdeps/linux/mips/bits/syscalls.h
@@ -10,67 +10,6 @@
#include <errno.h>
-#define SYS_ify(syscall_name) (__NR_##syscall_name)
-
-#undef _syscall0
-#define _syscall0(type,name) \
-type name(void) \
-{ \
-return (type) (INLINE_SYSCALL(name, 0)); \
-}
-
-#undef _syscall1
-#define _syscall1(type,name,type1,arg1) \
-type name(type1 arg1) \
-{ \
-return (type) (INLINE_SYSCALL(name, 1, arg1)); \
-}
-
-#undef _syscall2
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name(type1 arg1,type2 arg2) \
-{ \
-return (type) (INLINE_SYSCALL(name, 2, arg1, arg2)); \
-}
-
-#undef _syscall3
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name(type1 arg1,type2 arg2,type3 arg3) \
-{ \
-return (type) (INLINE_SYSCALL(name, 3, arg1, arg2, arg3)); \
-}
-
-#undef _syscall4
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
-{ \
-return (type) (INLINE_SYSCALL(name, 4, arg1, arg2, arg3, arg4)); \
-}
-
-#undef _syscall5
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
- type5,arg5) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
-{ \
-return (type) (INLINE_SYSCALL(name, 5, arg1, arg2, arg3, arg4, arg5)); \
-}
-
-#undef _syscall6
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
- type5,arg5,type6,arg6) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, type6 arg6) \
-{ \
-return (type) (INLINE_SYSCALL(name, 6, arg1, arg2, arg3, arg4, arg5, arg6)); \
-}
-
-#undef _syscall7
-#define _syscall7(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
- type5,arg5,type6,arg6,type7,arg7) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, type6 arg6,type7 arg7) \
-{ \
-return (type) (INLINE_SYSCALL(name, 7, arg1, arg2, arg3, arg4, arg5, arg6, arg7)); \
-}
-
/*
* Import from:
* glibc-ports/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
@@ -80,10 +19,9 @@ return (type) (INLINE_SYSCALL(name, 7, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
/* Define a macro which expands into the inline wrapper code for a system
call. */
-#undef INLINE_SYSCALL
#define INLINE_SYSCALL(name, nr, args...) \
({ INTERNAL_SYSCALL_DECL(err); \
- long result_var = INTERNAL_SYSCALL (name, err, nr, args); \
+ long result_var = INTERNAL_SYSCALL(name, err, nr, args); \
if ( INTERNAL_SYSCALL_ERROR_P (result_var, err) ) \
{ \
__set_errno (INTERNAL_SYSCALL_ERRNO (result_var, err)); \
@@ -91,21 +29,16 @@ return (type) (INLINE_SYSCALL(name, 7, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
} \
result_var; })
-#undef INTERNAL_SYSCALL_DECL
-#define INTERNAL_SYSCALL_DECL(err) long err
+#define INTERNAL_SYSCALL_DECL(err) long err attribute_unused
-#undef INTERNAL_SYSCALL_ERROR_P
#define INTERNAL_SYSCALL_ERROR_P(val, err) ((long) (err))
-#undef INTERNAL_SYSCALL_ERRNO
#define INTERNAL_SYSCALL_ERRNO(val, err) (val)
-#undef INTERNAL_SYSCALL
#define INTERNAL_SYSCALL(name, err, nr, args...) \
internal_syscall##nr (, "li\t$2, %2\t\t\t# " #name "\n\t", \
"i" (SYS_ify (name)), err, args)
-#undef INTERNAL_SYSCALL_NCS
#define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
internal_syscall##nr (= number, , "r" (__v0), err, args)
@@ -328,7 +261,7 @@ return (type) (INLINE_SYSCALL(name, 7, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
})
#define __SYSCALL_CLOBBERS "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", \
- "$14", "$15", "$24", "$25", "memory"
+ "$14", "$15", "$24", "$25", "hi", "lo", "memory"
#else /* N32 || N64 */
@@ -385,7 +318,7 @@ return (type) (INLINE_SYSCALL(name, 7, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
})
#define __SYSCALL_CLOBBERS "$1", "$3", "$10", "$11", "$12", "$13", \
- "$14", "$15", "$24", "$25", "memory"
+ "$14", "$15", "$24", "$25", "hi", "lo", "memory"
#endif
diff --git a/libc/sysdeps/linux/mips/bits/termios.h b/libc/sysdeps/linux/mips/bits/termios.h
index 546faa020..0b26bcd0c 100644
--- a/libc/sysdeps/linux/mips/bits/termios.h
+++ b/libc/sysdeps/linux/mips/bits/termios.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _TERMIOS_H
# error "Never include <bits/termios.h> directly; use <termios.h> instead."
@@ -73,6 +72,7 @@ struct termios
#define IXANY 0004000 /* Any character will restart after stop. */
#define IXOFF 0010000 /* Enable start/stop input control. */
#define IMAXBEL 0020000 /* Ring bell when input queue is full. */
+#define IUTF8 0040000 /* Input is UTF8. */
/* c_oflag bits */
#define OPOST 0000001 /* Perform output processing. */
diff --git a/libc/sysdeps/linux/mips/bits/timerfd.h b/libc/sysdeps/linux/mips/bits/timerfd.h
new file mode 100644
index 000000000..032735d01
--- /dev/null
+++ b/libc/sysdeps/linux/mips/bits/timerfd.h
@@ -0,0 +1,29 @@
+/* Copyright (C) 2008-2012 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_TIMERFD_H
+# error "Never use <bits/timerfd.h> directly; include <sys/timerfd.h> instead."
+#endif
+
+/* Bits to be set in the FLAGS parameter of `timerfd_create'. */
+enum
+ {
+ TFD_CLOEXEC = 02000000,
+#define TFD_CLOEXEC TFD_CLOEXEC
+ TFD_NONBLOCK = 00000200
+#define TFD_NONBLOCK TFD_NONBLOCK
+ };
diff --git a/libc/sysdeps/linux/mips/bits/uClibc_arch_features.h b/libc/sysdeps/linux/mips/bits/uClibc_arch_features.h
index 42a7c4526..bcdf124a4 100644
--- a/libc/sysdeps/linux/mips/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/mips/bits/uClibc_arch_features.h
@@ -4,6 +4,7 @@
#ifndef _BITS_UCLIBC_ARCH_FEATURES_H
#define _BITS_UCLIBC_ARCH_FEATURES_H
+#include <sgidefs.h>
/* instruction used when calling abort() to kill yourself */
#define __UCLIBC_ABORT_INSTRUCTION__ "break 255"
@@ -11,28 +12,35 @@
/* can your target use syscall6() for mmap ? */
#define __UCLIBC_MMAP_HAS_6_ARGS__
-/* does your target use syscall4() for truncate64 ? (32bit arches only) */
-#define __UCLIBC_TRUNCATE64_HAS_4_ARGS__
+/* does your target align 64bit values in register pairs ? (32bit arches only) */
+#if _MIPS_SIM == _ABIO32
+#define __UCLIBC_SYSCALL_ALIGN_64BIT__
+#else
+#undef __UCLIBC_SYSCALL_ALIGN_64BIT__
+#endif
/* 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 ? */
#undef __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 */
+#undef __UCLIBC_ASM_LINE_SEP__
+
#endif /* _BITS_UCLIBC_ARCH_FEATURES_H */
diff --git a/libc/sysdeps/linux/mips/bits/uClibc_page.h b/libc/sysdeps/linux/mips/bits/uClibc_page.h
index 915918c36..e379ce669 100644
--- a/libc/sysdeps/linux/mips/bits/uClibc_page.h
+++ b/libc/sysdeps/linux/mips/bits/uClibc_page.h
@@ -11,8 +11,8 @@
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * License along with this library; if not, see
+ * <http://www.gnu.org/licenses/>.
*/
/* Supply an architecture specific value for PAGE_SIZE and friends. */
diff --git a/libc/sysdeps/linux/mips/bits/wordsize.h b/libc/sysdeps/linux/mips/bits/wordsize.h
index 666c7ad07..fe130806c 100644
--- a/libc/sysdeps/linux/mips/bits/wordsize.h
+++ b/libc/sysdeps/linux/mips/bits/wordsize.h
@@ -12,8 +12,10 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#define __WORDSIZE _MIPS_SZPTR
+#if _MIPS_SIM == _ABI64
+# define __WORDSIZE_TIME64_COMPAT32 1
+#endif
diff --git a/libc/sysdeps/linux/mips/brk.c b/libc/sysdeps/linux/mips/brk.c
index 36620b210..9ddb92969 100644
--- a/libc/sysdeps/linux/mips/brk.c
+++ b/libc/sysdeps/linux/mips/brk.c
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <errno.h>
#include <unistd.h>
@@ -23,7 +22,6 @@
void *__curbrk attribute_hidden = 0;
-libc_hidden_proto(brk)
int brk (void *addr)
{
void *newbrk;
diff --git a/libc/sysdeps/linux/mips/bsd-_setjmp.S b/libc/sysdeps/linux/mips/bsd-_setjmp.S
index 6853dea98..de9ca50bb 100644
--- a/libc/sysdeps/linux/mips/bsd-_setjmp.S
+++ b/libc/sysdeps/linux/mips/bsd-_setjmp.S
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* This just does a tail-call to `__sigsetjmp (ARG, 0)'.
We cannot do it in C because it must be a tail-call, so frame-unwinding
diff --git a/libc/sysdeps/linux/mips/bsd-setjmp.S b/libc/sysdeps/linux/mips/bsd-setjmp.S
index 1f57a97e7..879d30e47 100644
--- a/libc/sysdeps/linux/mips/bsd-setjmp.S
+++ b/libc/sysdeps/linux/mips/bsd-setjmp.S
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* This just does a tail-call to `__sigsetjmp (ARG, 1)'.
We cannot do it in C because it must be a tail-call, so frame-unwinding
diff --git a/libc/sysdeps/linux/mips/cacheflush.c b/libc/sysdeps/linux/mips/cacheflush.c
index f99c58171..afa634612 100644
--- a/libc/sysdeps/linux/mips/cacheflush.c
+++ b/libc/sysdeps/linux/mips/cacheflush.c
@@ -12,19 +12,18 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the uClibc Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
+ License along with the uClibc Library; if not, see
+ <http://www.gnu.org/licenses/>. */
-#include <errno.h>
-#include <unistd.h>
#include <sys/syscall.h>
#ifdef __NR_cacheflush
-_syscall3(int, cacheflush, void *, addr, const int, nbytes, const int, op);
-strong_alias(cacheflush, _flush_cache)
+# include <sys/cachectl.h>
+_syscall3(int, cacheflush, void *, addr, const int, nbytes, const int, op)
+strong_alias_untyped(cacheflush, _flush_cache)
#endif
#ifdef __NR_cachectl
-_syscall3(int, cachectl, void *, addr, const int, nbytes, const int, op);
+# include <sys/cachectl.h>
+_syscall3(int, cachectl, void *, addr, const int, nbytes, const int, op)
#endif
diff --git a/libc/sysdeps/linux/mips/clone.S b/libc/sysdeps/linux/mips/clone.S
index 716cd993f..8f7059d04 100644
--- a/libc/sysdeps/linux/mips/clone.S
+++ b/libc/sysdeps/linux/mips/clone.S
@@ -1,6 +1,6 @@
-/* Copyright (C) 1996, 1997, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 2000, 2003, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
- Contributed by Ralf Baechle <ralf@gnu.ai.mit.edu>, 1996.
+ Contributed by Ralf Baechle <ralf@linux-mips.org>, 1996.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -13,107 +13,130 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* clone() is even more special than fork() as it mucks with stacks
and invokes a function in the right context after its all over. */
#include <features.h>
-#include <asm/unistd.h>
-#include <sys/regdef.h>
-#define _ERRNO_H 1
-#include <bits/errno.h>
#include <sys/asm.h>
+#include <sysdep.h>
+#define _ERRNO_H 1
+#include <bits/errno.h>
+#ifdef RESET_PID
+#include <tls.h>
+#endif
-/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg) */
+#define CLONE_VM 0x00000100
+#define CLONE_THREAD 0x00010000
+
+/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg,
+ void *parent_tidptr, void *tls, void *child_tidptr) */
.text
-.globl clone ;
- .align 2;
- .type clone,@function;
- .ent clone, 0;
-
-clone:
- .frame sp, 4*SZREG, sp
-#ifdef __PIC__
-#if _MIPS_SIM == _MIPS_SIM_ABI32
- .set noreorder
- .cpload $25
- .set reorder
- subu sp,32
- .cprestore 16
-#else /* N32 */
- PTR_SUBU sp,32 /* fn, arg, gp, pad */
- .cpsetup $25, 16, clone
-#endif /* N32 */
+#if _MIPS_SIM == _ABIO32
+# define EXTRA_LOCALS 1
#else
- subu sp,32
+# define EXTRA_LOCALS 0
+#endif
+LOCALSZ= 4
+FRAMESZ= (((NARGSAVE+LOCALSZ)*SZREG)+ALSZ)&ALMASK
+GPOFF= FRAMESZ-(1*SZREG)
+NESTED(clone,4*SZREG,sp)
+#ifdef __PIC__
+ SETUP_GP
+#endif
+ PTR_SUBU sp, FRAMESZ
+ SETUP_GP64 (GPOFF, clone)
+#ifdef __PIC__
+ SAVE_GP (GPOFF)
+#endif
+#ifdef PROF
+ .set noat
+ move $1,ra
+ jal _mcount
+ .set at
#endif
/* Sanity check arguments. */
li v0,EINVAL
- beqz a0,error /* No NULL function pointers. */
- beqz a1,error /* No NULL stack pointers. */
+ beqz a0,L(error) /* No NULL function pointers. */
+ beqz a1,L(error) /* No NULL stack pointers. */
-#if _MIPS_SIM != _MIPS_SIM_ABI32
- and a1,~(16-1) /* force alignment */
-#endif
PTR_SUBU a1,32 /* Reserve argument save space. */
PTR_S a0,0(a1) /* Save function pointer. */
PTR_S a3,PTRSIZE(a1) /* Save argument pointer. */
+#ifdef RESET_PID
+ LONG_S a2,(PTRSIZE*2)(a1) /* Save clone flags. */
+#endif
+ move a0,a2
+
+ /* Shuffle in the last three arguments - arguments 5, 6, and 7 to
+ this function, but arguments 3, 4, and 5 to the syscall. */
+#if _MIPS_SIM == _ABIO32
+ PTR_L a2,(FRAMESZ+PTRSIZE+PTRSIZE+16)(sp)
+ PTR_S a2,16(sp)
+ PTR_L a2,(FRAMESZ+16)(sp)
+ PTR_L a3,(FRAMESZ+PTRSIZE+16)(sp)
+#else
+ move a2,a4
+ move a3,a5
+ move a4,a6
+#endif
/* Do the system call */
- move a0,a2
li v0,__NR_clone
syscall
- bnez a3,error
- beqz v0,__thread_start
+ bnez a3,L(error)
+ beqz v0,L(thread_start)
/* Successful return from the parent */
-#if _MIPS_SIM != _MIPS_SIM_ABI32
- .cpreturn
-#endif
- PTR_ADDU sp,32
+ RESTORE_GP64
+ PTR_ADDU sp, FRAMESZ
j $31 ; nop
/* Something bad happened -- no child created */
-error:
-#if _MIPS_SIM != _MIPS_SIM_ABI32
- .cpreturn
-#endif
- PTR_ADDU sp,32
-
- /* uClibc change -- start */
- move a0,v0 /* Pass return val to C function. */
- /* uClibc change -- stop */
-
+L(error):
#ifdef __PIC__
PTR_LA t9,__syscall_error
+ RESTORE_GP64
+ PTR_ADDU sp, FRAMESZ
+ /* uClibc change -- start */
+ move a0,v0 /* Pass return val to C function. */
+ /* uClibc change -- stop */
jr t9
#else
+ RESTORE_GP64
+ PTR_ADDU sp, FRAMESZ
+ /* uClibc change -- start */
+ move a0,v0 /* Pass return val to C function. */
+ /* uClibc change -- stop */
j __syscall_error
#endif
- .end clone
+ END(clone)
/* Load up the arguments to the function. Put this block of code in
its own function so that we can terminate the stack trace with our
debug info. */
-.globl __thread_start;
- .align 2;
- .ent __thread_start, 0;
-
-__thread_start:
-#if _MIPS_SIM == _MIPS_SIM_ABI32
+ENTRY(__thread_start)
+L(thread_start):
/* cp is already loaded. */
- .cprestore 16
-#endif
+ SAVE_GP (GPOFF)
/* The stackframe has been created on entry of clone(). */
+
+#ifdef RESET_PID
+ /* Check and see if we need to reset the PID. */
+ LONG_L a0,(PTRSIZE*2)(sp)
+ and a1,a0,CLONE_THREAD
+ beqz a1,L(restore_pid)
+L(donepid):
+#endif
+
/* Restore the arg for user's function. */
PTR_L t9,0(sp) /* Function pointer. */
PTR_L a0,PTRSIZE(sp) /* Argument pointer. */
@@ -123,5 +146,27 @@ __thread_start:
/* Call _exit rather than doing it inline for breakpoint purposes. */
move a0,v0
- jal HIDDEN_JUMPTARGET(_exit)
- .end __thread_start
+#ifdef __PIC__
+ PTR_LA t9,_exit
+ jalr t9
+#else
+ jal _exit
+#endif
+
+#ifdef RESET_PID
+L(restore_pid):
+ and a1,a0,CLONE_VM
+ li v0,-1
+ bnez a1,L(gotpid)
+ li v0,__NR_getpid
+ syscall
+L(gotpid):
+ READ_THREAD_POINTER(v1)
+ INT_S v0,PID_OFFSET(v1)
+ INT_S v0,TID_OFFSET(v1)
+ b L(donepid)
+#endif
+
+ END(__thread_start)
+
+weak_alias(clone, __clone)
diff --git a/libc/sysdeps/linux/mips/crt1.S b/libc/sysdeps/linux/mips/crt1.S
index 2e38cf07c..083615515 100644
--- a/libc/sysdeps/linux/mips/crt1.S
+++ b/libc/sysdeps/linux/mips/crt1.S
@@ -31,9 +31,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <sys/regdef.h>
@@ -81,34 +80,17 @@
#endif
.type main,@function
.type __uClibc_main,@function
+ .ent __start
__start:
#ifdef __PIC__
-#if _MIPS_SIM == _MIPS_SIM_ABI32
- .set noreorder
- move $0, $31 /* Save old ra. */
- bal 10f /* Find addr of cpload. */
- nop
-10:
- .cpload $31
- move $31, $0
- .set reorder
-#else
- move $0, $31; /* Save old ra. */
- .set noreorder
- bal 10f /* Find addr of .cpsetup. */
- nop
-10:
- .set reorder
- .cpsetup $31, $25, 10b
- move $31, $0
-#endif
+ SETUP_GPX($0)
+ SETUP_GPX64($25,$0)
#else
- la $28, _gp /* Setup GP correctly if we're non-PIC. */
+ PTR_LA $28, _gp /* Setup GP correctly if we're non-PIC. */
move $31, $0
#endif
-
PTR_LA $4, main /* main */
PTR_L $5, 0($29) /* argc */
PTR_ADDIU $6, $29, PTRSIZE /* argv */
@@ -116,18 +98,18 @@ __start:
/* Allocate space on the stack for seven arguments and
* make sure the stack is aligned to double words (8 bytes) */
+ and $29, -2 * SZREG
+
#if _MIPS_SIM == _MIPS_SIM_ABI32
- and $29, -2 * 4
- subu $29, 32
- la $7, _init /* init */
- la $8, _fini
- sw $8, 16($29) /* fini */
- sw $2, 20($29) /* rtld_fini */
- sw $29, 24($29) /* stack_end */
-#else
- and $29, -2 * PTRSIZE
+ PTR_SUBIU $29, 32
+#endif
PTR_LA $7, _init /* init */
- PTR_LA $8, _fini /* fini */
+ PTR_LA $8, _fini
+#if _MIPS_SIM == _MIPS_SIM_ABI32
+ PTR_S $8, 16($29) /* fini */
+ PTR_S $2, 20($29) /* rtld_fini */
+ PTR_S $29, 24($29) /* stack_end */
+#else
move $9, $2 /* rtld_fini */
move $10, $29 /* stack_end */
#endif
@@ -136,6 +118,7 @@ hlt:
/* Crash if somehow `__uClibc_main' returns anyway. */
b hlt
.size __start,.-__start
+.end __start
/* Define a symbol for the first piece of initialized data. */
.data
@@ -145,4 +128,3 @@ __data_start:
.weak data_start
data_start = __data_start
-
diff --git a/libc/sysdeps/linux/mips/crtn.S b/libc/sysdeps/linux/mips/crtn.S
index cedd593f0..f3756a2f1 100644
--- a/libc/sysdeps/linux/mips/crtn.S
+++ b/libc/sysdeps/linux/mips/crtn.S
@@ -10,7 +10,6 @@
#NO_APP
.align 2
.globl _init
- .ent _init
.type _init, @function
#NO_APP
lw $31,28($sp)
@@ -22,14 +21,12 @@
.set macro
.set reorder
- .end _init
#APP
.section .fini
#NO_APP
.align 2
.globl _fini
- .ent _fini
.type _fini, @function
#NO_APP
lw $31,28($sp)
@@ -41,7 +38,6 @@
.set macro
.set reorder
- .end _fini
#APP
.ident "GCC: (GNU) 3.3.2"
@@ -54,10 +50,8 @@
.section .init
#NO_APP
- .align 2
.align 3
.globl _init
- .ent _init
.type _init, @function
#NO_APP
ld $31,8($sp)
@@ -68,16 +62,12 @@
addiu $sp,$sp,16
.set macro
.set reorder
-
- .end _init
#APP
.section .fini
#NO_APP
- .align 2
.align 3
.globl _fini
- .ent _fini
.type _fini, @function
#NO_APP
ld $31,8($sp)
@@ -89,7 +79,6 @@
.set macro
.set reorder
- .end _fini
#APP
.ident "GCC: (GNU) 3.4.3"
@@ -105,7 +94,6 @@
#NO_APP
.align 2
.globl _init
- .ent _init
.type _init, @function
#NO_APP
ld $31,24($sp)
@@ -118,14 +106,12 @@
.set macro
.set reorder
- .end _init
#APP
.section .fini
#NO_APP
.align 2
.globl _fini
- .ent _fini
.type _fini, @function
#NO_APP
ld $31,24($sp)
@@ -138,7 +124,6 @@
.set macro
.set reorder
- .end _fini
#APP
.ident "GCC: (GNU) 3.3.2"
diff --git a/libc/sysdeps/linux/mips/fpu_control.h b/libc/sysdeps/linux/mips/fpu_control.h
index c58b23503..f855af506 100644
--- a/libc/sysdeps/linux/mips/fpu_control.h
+++ b/libc/sysdeps/linux/mips/fpu_control.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FPU_CONTROL_H
#define _FPU_CONTROL_H
diff --git a/libc/sysdeps/linux/mips/getcontext.S b/libc/sysdeps/linux/mips/getcontext.S
new file mode 100644
index 000000000..c4ad081b0
--- /dev/null
+++ b/libc/sysdeps/linux/mips/getcontext.S
@@ -0,0 +1,148 @@
+/* Save current context.
+ Copyright (C) 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Maciej W. Rozycki <macro@codesourcery.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. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#include <sys/asm.h>
+#include <sys/fpregdef.h>
+#include <sys/regdef.h>
+
+#include "ucontext_i.h"
+
+/* int getcontext (ucontext_t *ucp) */
+
+ .text
+LOCALSZ = 0
+MASK = 0x00000000
+#ifdef __PIC__
+LOCALSZ = 1 /* save gp */
+# if _MIPS_SIM != _ABIO32
+MASK = 0x10000000
+# endif
+#endif
+FRAMESZ = ((LOCALSZ * SZREG) + ALSZ) & ALMASK
+GPOFF = FRAMESZ - (1 * SZREG)
+
+NESTED (__getcontext, FRAMESZ, ra)
+ .mask MASK, 0
+ .fmask 0x00000000, 0
+
+#ifdef __PIC__
+ SETUP_GP
+
+ move a2, sp
+# define _SP a2
+
+# if _MIPS_SIM != _ABIO32
+ move a3, gp
+# define _GP a3
+# endif
+
+ PTR_ADDIU sp, -FRAMESZ
+ SETUP_GP64 (GPOFF, __getcontext)
+ SAVE_GP (GPOFF)
+
+#else /* ! __PIC__ */
+# define _SP sp
+# define _GP gp
+
+#endif /* ! __PIC__ */
+
+#ifdef PROF
+ .set noat
+ move AT, ra
+ jal _mcount
+ .set at
+#endif
+
+ /* Store a magic flag. */
+ li v1, 1
+ REG_S v1, (0 * SZREG + MCONTEXT_GREGS)(a0) /* zero */
+
+ REG_S s0, (16 * SZREG + MCONTEXT_GREGS)(a0)
+ REG_S s1, (17 * SZREG + MCONTEXT_GREGS)(a0)
+ REG_S s2, (18 * SZREG + MCONTEXT_GREGS)(a0)
+ REG_S s3, (19 * SZREG + MCONTEXT_GREGS)(a0)
+ REG_S s4, (20 * SZREG + MCONTEXT_GREGS)(a0)
+ REG_S s5, (21 * SZREG + MCONTEXT_GREGS)(a0)
+ REG_S s6, (22 * SZREG + MCONTEXT_GREGS)(a0)
+ REG_S s7, (23 * SZREG + MCONTEXT_GREGS)(a0)
+#if ! defined (__PIC__) || _MIPS_SIM != _ABIO32
+ REG_S _GP, (28 * SZREG + MCONTEXT_GREGS)(a0)
+#endif
+ REG_S _SP, (29 * SZREG + MCONTEXT_GREGS)(a0)
+ REG_S fp, (30 * SZREG + MCONTEXT_GREGS)(a0)
+ REG_S ra, (31 * SZREG + MCONTEXT_GREGS)(a0)
+ REG_S ra, MCONTEXT_PC(a0)
+
+#ifdef __mips_hard_float
+# if _MIPS_SIM == _ABI64
+ s.d fs0, (24 * SZREG + MCONTEXT_FPREGS)(a0)
+ s.d fs1, (25 * SZREG + MCONTEXT_FPREGS)(a0)
+ s.d fs2, (26 * SZREG + MCONTEXT_FPREGS)(a0)
+ s.d fs3, (27 * SZREG + MCONTEXT_FPREGS)(a0)
+ s.d fs4, (28 * SZREG + MCONTEXT_FPREGS)(a0)
+ s.d fs5, (29 * SZREG + MCONTEXT_FPREGS)(a0)
+ s.d fs6, (30 * SZREG + MCONTEXT_FPREGS)(a0)
+ s.d fs7, (31 * SZREG + MCONTEXT_FPREGS)(a0)
+
+# else /* _MIPS_SIM != _ABI64 */
+ s.d fs0, (20 * SZREG + MCONTEXT_FPREGS)(a0)
+ s.d fs1, (22 * SZREG + MCONTEXT_FPREGS)(a0)
+ s.d fs2, (24 * SZREG + MCONTEXT_FPREGS)(a0)
+ s.d fs3, (26 * SZREG + MCONTEXT_FPREGS)(a0)
+ s.d fs4, (28 * SZREG + MCONTEXT_FPREGS)(a0)
+ s.d fs5, (30 * SZREG + MCONTEXT_FPREGS)(a0)
+
+# endif /* _MIPS_SIM != _ABI64 */
+
+ cfc1 v1, fcr31
+ sw v1, MCONTEXT_FPC_CSR(a0)
+#endif /* __mips_hard_float */
+
+/* rt_sigprocmask (SIG_BLOCK, NULL, &ucp->uc_sigmask, _NSIG8) */
+ li a3, _NSIG8
+ PTR_ADDU a2, a0, UCONTEXT_SIGMASK
+ move a1, zero
+ li a0, SIG_BLOCK
+
+ li v0, SYS_ify (rt_sigprocmask)
+ syscall
+ bnez a3, 99f
+
+#ifdef __PIC__
+ RESTORE_GP64
+ PTR_ADDIU sp, FRAMESZ
+#endif
+ move v0, zero
+ jr ra
+
+99:
+#ifdef __PIC__
+ PTR_LA t9, JUMPTARGET (__syscall_error)
+ RESTORE_GP64
+ PTR_ADDIU sp, FRAMESZ
+ jr t9
+
+#else /* ! __PIC__ */
+
+ j JUMPTARGET (__syscall_error)
+#endif /* ! __PIC__ */
+PSEUDO_END (__getcontext)
+
+weak_alias (__getcontext, getcontext)
diff --git a/libc/sysdeps/linux/mips/jmpbuf-unwind.h b/libc/sysdeps/linux/mips/jmpbuf-unwind.h
new file mode 100644
index 000000000..2c0df95f5
--- /dev/null
+++ b/libc/sysdeps/linux/mips/jmpbuf-unwind.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+#include <setjmp.h>
+
+/* Test if longjmp to JMPBUF would unwind the frame
+ containing a local variable at ADDRESS. */
+#define _JMPBUF_UNWINDS(jmpbuf, address) \
+ ((void *) (address) < (void *) (jmpbuf)[0].__sp)
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <stdint.h>
+#include <unwind.h>
+
+#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
+ _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
+
+#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
+ ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[0].__sp - (_adj))
+#endif
diff --git a/libc/sysdeps/linux/mips/kernel_rt_sigframe.h b/libc/sysdeps/linux/mips/kernel_rt_sigframe.h
new file mode 100644
index 000000000..77ffaf68d
--- /dev/null
+++ b/libc/sysdeps/linux/mips/kernel_rt_sigframe.h
@@ -0,0 +1,10 @@
+/* Linux kernel RT signal frame. */
+typedef struct kernel_rt_sigframe
+ {
+ uint32_t rs_ass[4];
+ uint32_t rs_code[2];
+ siginfo_t rs_info;
+ struct ucontext rs_uc;
+ uint32_t rs_altcode[8] __attribute__ ((__aligned__ (1 << 7)));
+ }
+kernel_rt_sigframe_t;
diff --git a/libc/sysdeps/linux/mips/makecontext.S b/libc/sysdeps/linux/mips/makecontext.S
new file mode 100644
index 000000000..6427339a6
--- /dev/null
+++ b/libc/sysdeps/linux/mips/makecontext.S
@@ -0,0 +1,188 @@
+/* Modify saved context.
+ Copyright (C) 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Maciej W. Rozycki <macro@codesourcery.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. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#include <sys/asm.h>
+#include <sys/fpregdef.h>
+#include <sys/regdef.h>
+
+#include "ucontext_i.h"
+
+/* int makecontext (ucontext_t *ucp, (void *func) (), int argc, ...) */
+
+ .text
+LOCALSZ = 0
+ARGSZ = 0
+MASK = 0x00000000
+#ifdef __PIC__
+LOCALSZ = 1 /* save gp */
+#endif
+#if _MIPS_SIM != _ABIO32
+ARGSZ = 5 /* save a3-a7 */
+# ifdef __PIC__
+MASK = 0x10000000
+# endif
+#endif
+FRAMESZ = (((ARGSZ + LOCALSZ) * SZREG) + ALSZ) & ALMASK
+GPOFF = FRAMESZ - ((ARGSZ + 1) * SZREG)
+#if _MIPS_SIM != _ABIO32
+A3OFF = FRAMESZ - (5 * SZREG) /* callee-allocated */
+A4OFF = FRAMESZ - (4 * SZREG)
+A5OFF = FRAMESZ - (3 * SZREG)
+A6OFF = FRAMESZ - (2 * SZREG)
+A7OFF = FRAMESZ - (1 * SZREG)
+NARGREGS = 8
+#else
+A3OFF = FRAMESZ + (3 * SZREG) /* caller-allocated */
+NARGREGS = 4
+#endif
+
+NESTED (__makecontext, FRAMESZ, ra)
+ .mask MASK, -(ARGSZ * SZREG)
+ .fmask 0x00000000, 0
+
+98:
+#ifdef __PIC__
+ SETUP_GP
+#endif
+
+ PTR_ADDIU sp, -FRAMESZ
+
+#ifdef __PIC__
+ SETUP_GP64 (GPOFF, __makecontext)
+ SAVE_GP (GPOFF)
+#endif
+
+#ifdef PROF
+ .set noat
+ move AT, ra
+ jal _mcount
+ .set at
+#endif
+
+ /* Store args to be passed. */
+ REG_S a3, A3OFF(sp)
+#if _MIPS_SIM != _ABIO32
+ REG_S a4, A4OFF(sp)
+ REG_S a5, A5OFF(sp)
+ REG_S a6, A6OFF(sp)
+ REG_S a7, A7OFF(sp)
+#endif
+
+ /* Store a magic flag. */
+ li v1, 1
+ REG_S v1, (0 * SZREG + MCONTEXT_GREGS)(a0) /* zero */
+
+ /* Set up the stack. */
+ PTR_L t0, STACK_SP(a0)
+ PTR_L t2, STACK_SIZE(a0)
+ PTR_ADDIU t1, sp, A3OFF
+ PTR_ADDU t0, t2
+ and t0, ALMASK
+ blez a2, 2f /* no arguments */
+
+ /* Store register arguments. */
+ PTR_ADDIU t2, a0, MCONTEXT_GREGS + 4 * SZREG
+ move t3, zero
+0:
+ addiu t3, 1
+ REG_L v1, (t1)
+ PTR_ADDIU t1, SZREG
+ REG_S v1, (t2)
+ PTR_ADDIU t2, SZREG
+ bgeu t3, a2, 2f /* all done */
+ bltu t3, NARGREGS, 0b /* next */
+
+ /* Make room for stack arguments. */
+ PTR_SUBU t2, a2, t3
+ PTR_SLL t2, 3
+ PTR_SUBU t0, t2
+ and t0, ALMASK
+
+ /* Store stack arguments. */
+ move t2, t0
+1:
+ addiu t3, 1
+ REG_L v1, (t1)
+ PTR_ADDIU t1, SZREG
+ REG_S v1, (t2)
+ PTR_ADDIU t2, SZREG
+ bltu t3, a2, 1b /* next */
+
+2:
+#if _MIPS_SIM == _ABIO32
+ /* Make room for a0-a3 storage. */
+ PTR_ADDIU t0, -(NARGSAVE * SZREG)
+#endif
+ PTR_L v1, UCONTEXT_LINK(a0)
+#ifdef __PIC__
+ PTR_ADDIU t9, 99f - 98b
+#else
+ PTR_LA t9, 99f
+#endif
+ REG_S t0, (29 * SZREG + MCONTEXT_GREGS)(a0) /* sp */
+ REG_S v1, (16 * SZREG + MCONTEXT_GREGS)(a0) /* s0 */
+#ifdef __PIC__
+ REG_S gp, (17 * SZREG + MCONTEXT_GREGS)(a0) /* s1 */
+#endif
+ REG_S t9, (31 * SZREG + MCONTEXT_GREGS)(a0) /* ra */
+ REG_S a1, MCONTEXT_PC(a0)
+
+#ifdef __PIC__
+ RESTORE_GP64
+ PTR_ADDIU sp, FRAMESZ
+#endif
+ jr ra
+
+99:
+#ifdef __PIC__
+ move gp, s1
+#endif
+ move a0, zero
+ beqz s0, 0f
+
+ /* setcontext (ucp) */
+ move a0, s0
+#ifdef __PIC__
+ PTR_LA t9, JUMPTARGET (__setcontext)
+ jalr t9
+# if _MIPS_SIM == _ABIO32
+ move gp, s1
+# endif
+#else
+ jal JUMPTARGET (__setcontext)
+#endif
+ move a0, v0
+
+0:
+ /* exit (a0) */
+#ifdef __PIC__
+ PTR_LA t9, HIDDEN_JUMPTARGET (exit)
+ jalr t9
+#else
+ jal HIDDEN_JUMPTARGET (exit)
+#endif
+
+ /* You don't exist, you won't feel anything. */
+1:
+ lb zero, (zero)
+ b 1b
+PSEUDO_END (__makecontext)
+
+weak_alias (__makecontext, makecontext)
diff --git a/libc/sysdeps/linux/mips/mmap.c b/libc/sysdeps/linux/mips/mmap.c
deleted file mode 100644
index 4e0897f45..000000000
--- a/libc/sysdeps/linux/mips/mmap.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Use new style mmap for mips */
-/*
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-#include <unistd.h>
-#include <errno.h>
-#include <sys/mman.h>
-#include <sys/syscall.h>
-
-libc_hidden_proto(mmap)
-
-#if 0
-/* For now, leave mmap using mmap1 since mmap2 seems
- * to have issues (i.e. it doesn't work 100% properly).
- */
-#ifdef __NR_mmap2
-# undef __NR_mmap
-# define __NR_mmap __NR_mmap2
-#endif
-#endif
-
-_syscall6 (__ptr_t, mmap, __ptr_t, addr, size_t, len, int, prot,
- int, flags, int, fd, __off_t, offset);
-libc_hidden_def(mmap)
diff --git a/libc/sysdeps/linux/mips/posix_fadvise.c b/libc/sysdeps/linux/mips/posix_fadvise.c
index 8546d96ba..b0110bfb2 100644
--- a/libc/sysdeps/linux/mips/posix_fadvise.c
+++ b/libc/sysdeps/linux/mips/posix_fadvise.c
@@ -8,19 +8,16 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#include <features.h>
-#include <unistd.h>
-#include <errno.h>
-#include <endian.h>
-#include <stdint.h>
-#include <sys/types.h>
#include <sys/syscall.h>
-#include <fcntl.h>
-int posix_fadvise(int fd, off_t offset, off_t len, int advice)
-{
/* MIPS kernel only has NR_fadvise64 which acts as NR_fadvise64_64 */
#ifdef __NR_fadvise64
+# include <fcntl.h>
+# include <endian.h>
+# include <bits/wordsize.h>
+
+int posix_fadvise(int fd, off_t offset, off_t len, int advice)
+{
INTERNAL_SYSCALL_DECL(err);
# if _MIPS_SIM == _ABIO32
int ret = INTERNAL_SYSCALL(fadvise64, err, 7, fd, 0,
@@ -33,7 +30,9 @@ int posix_fadvise(int fd, off_t offset, off_t len, int advice)
if (INTERNAL_SYSCALL_ERROR_P (ret, err))
return INTERNAL_SYSCALL_ERRNO (ret, err);
return 0;
-#else
- return ENOSYS;
-#endif
}
+# if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64
+strong_alias(posix_fadvise,posix_fadvise64)
+# endif
+
+#endif
diff --git a/libc/sysdeps/linux/mips/posix_fadvise64.c b/libc/sysdeps/linux/mips/posix_fadvise64.c
index d9b89d123..02244aaab 100644
--- a/libc/sysdeps/linux/mips/posix_fadvise64.c
+++ b/libc/sysdeps/linux/mips/posix_fadvise64.c
@@ -8,36 +8,28 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#include <features.h>
-#include <unistd.h>
-#include <errno.h>
-#include <endian.h>
-#include <stdint.h>
-#include <sys/types.h>
+#include <_lfs_64.h>
#include <sys/syscall.h>
-#include <fcntl.h>
+#include <bits/wordsize.h>
-#ifdef __UCLIBC_HAS_LFS__
+/* MIPS kernel only has NR_fadvise64 which acts as NR_fadvise64_64 */
+#if defined __NR_fadvise64 && __WORDSIZE == 32
+# include <fcntl.h>
+# include <endian.h>
-int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advice)
+int posix_fadvise64(int fd, off64_t offset, off64_t len, int advice)
{
-/* MIPS kernel only has NR_fadvise64 which acts as NR_fadvise64_64 */
-#ifdef __NR_fadvise64
INTERNAL_SYSCALL_DECL(err);
-# if _MIPS_SIM == _MIPS_SIM_ABI32
+# if _MIPS_SIM == _ABIO32
int ret = INTERNAL_SYSCALL(fadvise64, err, 7, fd, 0,
- __LONG_LONG_PAIR ((long) (offset >> 32), (long) offset),
- __LONG_LONG_PAIR ((long) (len >> 32), (long) len),
- advice);
+ __LONG_LONG_PAIR ((long) (offset >> 32), (long) offset),
+ __LONG_LONG_PAIR ((long) (len >> 32), (long) len),
+ advice);
# else /* N32 || N64 */
int ret = INTERNAL_SYSCALL(fadvise64, err, 4, fd, offset, len, advice);
# endif
if (INTERNAL_SYSCALL_ERROR_P (ret, err))
return INTERNAL_SYSCALL_ERRNO (ret, err);
return 0;
-#else
- return ENOSYS;
-#endif
}
-
-#endif /* __UCLIBC_HAS_LFS__ */
+#endif
diff --git a/libc/sysdeps/linux/mips/pread_write.c b/libc/sysdeps/linux/mips/pread_write.c
index 0939e17b6..1220fec54 100644
--- a/libc/sysdeps/linux/mips/pread_write.c
+++ b/libc/sysdeps/linux/mips/pread_write.c
@@ -4,112 +4,28 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-/*
- * 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...
- */
#include <sys/syscall.h>
#include <unistd.h>
-#include <stdint.h>
#include <endian.h>
#include <sgidefs.h>
-#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
+/* We should generalize this for 32bit userlands w/64bit regs. This applies
+ * to the x86_64 x32 and the mips n32 ABIs. */
+#if _MIPS_SIM == _MIPS_SIM_NABI32
+# define __NR___syscall_pread __NR_pread64
+static _syscall4(ssize_t, __syscall_pread, int, fd, void *, buf, size_t, count, off_t, offset)
+# define MY_PREAD(fd, buf, count, offset) \
+ __syscall_pread(fd, buf, count, offset)
+# define MY_PREAD64(fd, buf, count, offset) \
+ __syscall_pread(fd, buf, count, offset)
+
+# define __NR___syscall_pwrite __NR_pwrite64
+static _syscall4(ssize_t, __syscall_pwrite, int, fd, const void *, buf, size_t, count, off_t, offset)
+# define MY_PWRITE(fd, buf, count, offset) \
+ __syscall_pwrite(fd, buf, count, offset)
+# define MY_PWRITE64(fd, buf, count, offset) \
+ __syscall_pwrite(fd, buf, count, offset)
#endif
-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
-
-#include <bits/kernel_types.h>
-
-
-#ifdef __NR_pread
-
-# if _MIPS_SIM == _MIPS_SIM_ABI64
-# define __NR___libc_pread __NR_pread
-_syscall4(ssize_t, __libc_pread, int, fd, void *, buf, size_t, count, off_t, offset);
-weak_alias (__libc_pread, pread)
-# ifdef __UCLIBC_HAS_LFS__
-# define __NR___libc_pread64 __NR_pread
-_syscall4(ssize_t, __libc_pread64, int, fd, void *, buf, size_t, count, off64_t, offset);
-weak_alias (__libc_pread64, pread64)
-# endif /* __UCLIBC_HAS_LFS__ */
-# else /* O32 || N32 */
-# define __NR___syscall_pread __NR_pread
-static __inline__ _syscall6(ssize_t, __syscall_pread, int, fd, void *, buf,
- size_t, count, int, dummy, 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,0,__LONG_LONG_PAIR(offset>>31,offset)));
-}
-weak_alias(__libc_pread,pread)
-
-# ifdef __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, 0, __LONG_LONG_PAIR (high, low)));
-}
-weak_alias(__libc_pread64,pread64)
-# endif /* __UCLIBC_HAS_LFS__ */
-# endif /* O32 || N32 */
-
-#endif /* __NR_pread */
-
-/**********************************************************************/
-
-#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
-
-#ifdef __NR_pwrite
-
-# if _MIPS_SIM == _MIPS_SIM_ABI64
-# define __NR___libc_pwrite __NR_pwrite
-_syscall4(ssize_t, __libc_pwrite, int, fd, const void *, buf, size_t, count, off_t, offset);
-weak_alias (__libc_pwrite, pwrite)
-# ifdef __UCLIBC_HAS_LFS__
-# define __NR___libc_pwrite64 __NR_pwrite
-_syscall4(ssize_t, __libc_pwrite64, int, fd, const void *, buf, size_t, count, off64_t, offset);
-weak_alias (__libc_pwrite64, pwrite64)
-# endif /* __UCLIBC_HAS_LFS__ */
-# else /* O32 || N32 */
-# define __NR___syscall_pwrite __NR_pwrite
-static __inline__ _syscall6(ssize_t, __syscall_pwrite, int, fd, const void *, buf,
- size_t, count, int, dummy, 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,0,__LONG_LONG_PAIR(offset>>31,offset)));
-}
-weak_alias(__libc_pwrite,pwrite)
-
-# ifdef __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, 0, __LONG_LONG_PAIR (high, low)));
-}
-weak_alias(__libc_pwrite64,pwrite64)
-# endif /* __UCLIBC_HAS_LFS__ */
-# endif /* O32 || N32 */
-#endif /* __NR_pwrite */
+#include "../common/pread_write.c"
diff --git a/libc/sysdeps/linux/mips/readahead.c b/libc/sysdeps/linux/mips/readahead.c
deleted file mode 100644
index 9157c2762..000000000
--- a/libc/sysdeps/linux/mips/readahead.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Provide kernel hint to read ahead.
- Copyright (C) 2002, 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.
-
- 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 <errno.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/syscall.h>
-
-#ifdef __UCLIBC_HAS_LFS__
-#include <_lfs_64.h>
-# ifdef __NR_readahead
-
-ssize_t readahead(int fd, off64_t offset, size_t count)
-{
-# if _MIPS_SIM == _ABIO32
- return INLINE_SYSCALL (readahead, 5, fd, 0,
- __LONG_LONG_PAIR ((off_t) (offset >> 32), (off_t) offset),
- count);
-# else /* N32 || N64 */
- return INLINE_SYSCALL (readahead, 3, fd, offset, count);
-# endif
-}
-
-# endif
-#endif
diff --git a/libc/sysdeps/linux/mips/setcontext.S b/libc/sysdeps/linux/mips/setcontext.S
new file mode 100644
index 000000000..d3cde0e50
--- /dev/null
+++ b/libc/sysdeps/linux/mips/setcontext.S
@@ -0,0 +1,191 @@
+/* Set current context.
+ Copyright (C) 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Maciej W. Rozycki <macro@codesourcery.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. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#include <sys/asm.h>
+#include <sys/fpregdef.h>
+#include <sys/regdef.h>
+
+#include "ucontext_i.h"
+
+/* int setcontext (const ucontext_t *ucp) */
+
+ .text
+LOCALSZ = 0
+ARGSZ = 0
+MASK = 0x00000000
+#ifdef __PIC__
+LOCALSZ = 1 /* save gp */
+#endif
+#if _MIPS_SIM != _ABIO32
+ARGSZ = 1 /* save a0 */
+# ifdef __PIC__
+MASK = 0x10000000
+# endif
+#endif
+FRAMESZ = (((ARGSZ + LOCALSZ) * SZREG) + ALSZ) & ALMASK
+GPOFF = FRAMESZ - ((ARGSZ + 1) * SZREG)
+#if _MIPS_SIM != _ABIO32
+A0OFF = FRAMESZ - (1 * SZREG) /* callee-allocated */
+#else
+A0OFF = FRAMESZ + (0 * SZREG) /* caller-allocated */
+#endif
+
+NESTED (__setcontext, FRAMESZ, ra)
+ .mask MASK, -(ARGSZ * SZREG)
+ .fmask 0x00000000, 0
+
+#ifdef __PIC__
+ SETUP_GP
+#endif
+
+ PTR_ADDIU sp, -FRAMESZ
+
+#ifdef __PIC__
+ SETUP_GP64 (GPOFF, __setcontext)
+ SAVE_GP (GPOFF)
+#endif
+
+#ifdef PROF
+ .set noat
+ move AT, ra
+ jal _mcount
+ .set at
+#endif
+
+ /* Check for the magic flag. */
+ li v0, 1
+ REG_L v1, (0 * SZREG + MCONTEXT_GREGS)(a0) /* zero */
+ bne v0, v1, 98f
+
+ REG_S a0, A0OFF(sp)
+
+/* rt_sigprocmask (SIG_SETMASK, &ucp->uc_sigmask, NULL, _NSIG8) */
+ li a3, _NSIG8
+ move a2, zero
+ PTR_ADDU a1, a0, UCONTEXT_SIGMASK
+ li a0, SIG_SETMASK
+
+ li v0, SYS_ify (rt_sigprocmask)
+ syscall
+ bnez a3, 99f
+
+ REG_L v0, A0OFF(sp)
+
+#ifdef __mips_hard_float
+# if _MIPS_SIM == _ABI64
+ l.d fs0, (24 * SZREG + MCONTEXT_FPREGS)(v0)
+ l.d fs1, (25 * SZREG + MCONTEXT_FPREGS)(v0)
+ l.d fs2, (26 * SZREG + MCONTEXT_FPREGS)(v0)
+ l.d fs3, (27 * SZREG + MCONTEXT_FPREGS)(v0)
+ l.d fs4, (28 * SZREG + MCONTEXT_FPREGS)(v0)
+ l.d fs5, (29 * SZREG + MCONTEXT_FPREGS)(v0)
+ l.d fs6, (30 * SZREG + MCONTEXT_FPREGS)(v0)
+ l.d fs7, (31 * SZREG + MCONTEXT_FPREGS)(v0)
+
+# else /* _MIPS_SIM != _ABI64 */
+ l.d fs0, (20 * SZREG + MCONTEXT_FPREGS)(v0)
+ l.d fs1, (22 * SZREG + MCONTEXT_FPREGS)(v0)
+ l.d fs2, (24 * SZREG + MCONTEXT_FPREGS)(v0)
+ l.d fs3, (26 * SZREG + MCONTEXT_FPREGS)(v0)
+ l.d fs4, (28 * SZREG + MCONTEXT_FPREGS)(v0)
+ l.d fs5, (30 * SZREG + MCONTEXT_FPREGS)(v0)
+
+# endif /* _MIPS_SIM != _ABI64 */
+
+ lw v1, MCONTEXT_FPC_CSR(v0)
+ ctc1 v1, fcr31
+#endif /* __mips_hard_float */
+
+ /* Note the contents of argument registers will be random
+ unless makecontext() has been called. */
+ REG_L a0, (4 * SZREG + MCONTEXT_GREGS)(v0)
+ REG_L a1, (5 * SZREG + MCONTEXT_GREGS)(v0)
+ REG_L a2, (6 * SZREG + MCONTEXT_GREGS)(v0)
+ REG_L a3, (7 * SZREG + MCONTEXT_GREGS)(v0)
+#if _MIPS_SIM != _ABIO32
+ REG_L a4, (8 * SZREG + MCONTEXT_GREGS)(v0)
+ REG_L a5, (9 * SZREG + MCONTEXT_GREGS)(v0)
+ REG_L a6, (10 * SZREG + MCONTEXT_GREGS)(v0)
+ REG_L a7, (11 * SZREG + MCONTEXT_GREGS)(v0)
+#endif
+
+ REG_L s0, (16 * SZREG + MCONTEXT_GREGS)(v0)
+ REG_L s1, (17 * SZREG + MCONTEXT_GREGS)(v0)
+ REG_L s2, (18 * SZREG + MCONTEXT_GREGS)(v0)
+ REG_L s3, (19 * SZREG + MCONTEXT_GREGS)(v0)
+ REG_L s4, (20 * SZREG + MCONTEXT_GREGS)(v0)
+ REG_L s5, (21 * SZREG + MCONTEXT_GREGS)(v0)
+ REG_L s6, (22 * SZREG + MCONTEXT_GREGS)(v0)
+ REG_L s7, (23 * SZREG + MCONTEXT_GREGS)(v0)
+#if ! defined (__PIC__) || _MIPS_SIM != _ABIO32
+ REG_L gp, (28 * SZREG + MCONTEXT_GREGS)(v0)
+#endif
+ REG_L sp, (29 * SZREG + MCONTEXT_GREGS)(v0)
+ REG_L fp, (30 * SZREG + MCONTEXT_GREGS)(v0)
+ REG_L ra, (31 * SZREG + MCONTEXT_GREGS)(v0)
+ REG_L t9, MCONTEXT_PC(v0)
+
+ move v0, zero
+ jr t9
+
+98:
+ /* This is a context obtained from a signal handler.
+ Perform a full restore by pushing the context
+ passed onto a simulated signal frame on the stack
+ and call the signal return syscall as if a signal
+ handler exited normally. */
+ PTR_ADDIU sp, -((RT_SIGFRAME_SIZE + ALSZ) & ALMASK)
+
+ /* Only ucontext is referred to from rt_sigreturn,
+ copy it. */
+ PTR_ADDIU t1, sp, RT_SIGFRAME_UCONTEXT
+ li t3, ((UCONTEXT_SIZE + SZREG - 1) / SZREG) - 1
+0:
+ REG_L t2, (a0)
+ PTR_ADDIU a0, SZREG
+ REG_S t2, (t1)
+ PTR_ADDIU t1, SZREG
+ .set noreorder
+ bgtz t3, 0b
+ addiu t3, -1
+ .set reorder
+
+/* rt_sigreturn () -- no arguments, sp points to struct rt_sigframe. */
+ li v0, SYS_ify (rt_sigreturn)
+ syscall
+
+ /* Restore the stack and fall through to the error
+ path. Successful rt_sigreturn never returns to
+ its calling place. */
+ PTR_ADDIU sp, ((RT_SIGFRAME_SIZE + ALSZ) & ALMASK)
+99:
+#ifdef __PIC__
+ PTR_LA t9, JUMPTARGET (__syscall_error)
+ RESTORE_GP64
+ PTR_ADDIU sp, FRAMESZ
+ jr t9
+
+#else /* ! __PIC__ */
+
+ j JUMPTARGET (__syscall_error)
+#endif /* ! __PIC__ */
+PSEUDO_END (__setcontext)
+
+weak_alias (__setcontext, setcontext)
diff --git a/libc/sysdeps/linux/mips/setjmp.S b/libc/sysdeps/linux/mips/setjmp.S
index 226f75524..59b76cca6 100644
--- a/libc/sysdeps/linux/mips/setjmp.S
+++ b/libc/sysdeps/linux/mips/setjmp.S
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <sys/regdef.h>
#include <sys/asm.h>
@@ -53,6 +52,7 @@ __sigsetjmp:
PTR_LA t9, __sigsetjmp_aux
#if _MIPS_SIM != _MIPS_SIM_ABI32
.cpreturn
+ move a4, gp
#endif
jr t9
#else
diff --git a/libc/sysdeps/linux/mips/setjmp_aux.c b/libc/sysdeps/linux/mips/setjmp_aux.c
index 751b32d7d..4338838d7 100644
--- a/libc/sysdeps/linux/mips/setjmp_aux.c
+++ b/libc/sysdeps/linux/mips/setjmp_aux.c
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <features.h>
#include <setjmp.h>
@@ -27,11 +26,9 @@
pointer. We do things this way because it's difficult to reliably
access them in C. */
-extern int __sigjmp_save (sigjmp_buf, int);
-
int
#if _MIPS_SIM == _MIPS_SIM_ABI64
-__sigsetjmp_aux (jmp_buf env, int savemask, long sp, long fp)
+__sigsetjmp_aux (jmp_buf env, int savemask, long long sp, long long fp, long long gp)
#else /* O32 || N32 */
__sigsetjmp_aux (jmp_buf env, int savemask, int sp, int fp)
#endif /* O32 || N32 */
@@ -65,14 +62,14 @@ __sigsetjmp_aux (jmp_buf env, int savemask, int sp, int fp)
#endif
/* .. and the stack pointer; */
- env[0].__jmpbuf[0].__sp = (void *) sp;
+ env[0].__jmpbuf[0].__sp = (__ptr_size) sp;
/* .. and the FP; it'll be in s8. */
- env[0].__jmpbuf[0].__fp = (void *) fp;
+ env[0].__jmpbuf[0].__fp = (__ptr_size) fp;
/* .. and the GP; */
#if _MIPS_SIM == _MIPS_SIM_ABI64
- __asm__ __volatile__ ("sd $gp, %0" : : "m" (env[0].__jmpbuf[0].__gp));
+ env[0].__jmpbuf[0].__gp = (__ptr_size) gp;
#else
__asm__ __volatile__ ("sw $gp, %0" : : "m" (env[0].__jmpbuf[0].__gp));
#endif
diff --git a/libc/sysdeps/linux/mips/sgidefs.h b/libc/sysdeps/linux/mips/sgidefs.h
index 74509fdbd..37a03b208 100644
--- a/libc/sysdeps/linux/mips/sgidefs.h
+++ b/libc/sysdeps/linux/mips/sgidefs.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SGIDEFS_H
#define _SGIDEFS_H 1
diff --git a/libc/sysdeps/linux/mips/sigaction.c b/libc/sysdeps/linux/mips/sigaction.c
index 39d38b86f..252ffc6e3 100644
--- a/libc/sysdeps/linux/mips/sigaction.c
+++ b/libc/sysdeps/linux/mips/sigaction.c
@@ -13,8 +13,7 @@
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.
+ see <http://www.gnu.org/licenses/>.
Totally hacked up for uClibc by Erik Andersen <andersen@codepoet.org>
*/
@@ -27,109 +26,86 @@
#define SA_RESTORER 0x04000000
-extern __typeof(sigaction) __libc_sigaction;
-
#ifdef __NR_rt_sigaction
-/* Experimentally off - libc_hidden_proto(memcpy) */
-
-#if _MIPS_SIM != _ABIO32
-
-# ifdef __NR_rt_sigreturn
-static void restore_rt (void) __asm__ ("__restore_rt");
-# endif
-# ifdef __NR_sigreturn
-static void restore (void) __asm__ ("__restore");
+# if _MIPS_SIM != _ABIO32
+# ifdef __NR_rt_sigreturn
+static void restore_rt(void) __asm__ ("__restore_rt");
+# endif
+# ifdef __NR_sigreturn
+static void restore(void) __asm__ ("__restore");
+# endif
# endif
-#endif
/* 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 __libc_sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
{
- int result;
- struct kernel_sigaction kact, koact;
-
- 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;
-# ifdef HAVE_SA_RESTORER
-# if _MIPS_SIM == _ABIO32
- kact.sa_restorer = act->sa_restorer;
-# else
- kact.sa_restorer = &restore_rt;
-# endif
-# endif
- }
-
- /* 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;
-# ifdef HAVE_SA_RESTORER
- oact->sa_restorer = koact.sa_restorer;
+# if _MIPS_SIM != _ABIO32
+ struct sigaction kact;
+ if (act) {
+ memcpy(&kact, act, sizeof(kact));
+ kact.sa_restorer = &restore_rt;
+ act = &kact;
+ }
# endif
- }
- return result;
-}
+ /* NB: kernel (as of 2.6.25) will return EINVAL
+ * if sizeof(act->sa_mask) does not match kernel's sizeof(sigset_t) */
+ return __syscall_rt_sigaction(sig, act, oact, sizeof(act->sa_mask));
+}
#else
-extern void restore (void) __asm__ ("__restore") 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 __libc_sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
{
- int result;
- struct old_kernel_sigaction kact, koact;
-
- if (act) {
- kact.k_sa_handler = act->sa_handler;
- kact.sa_mask = act->sa_mask.__val[0];
- kact.sa_flags = act->sa_flags;
-# ifdef HAVE_SA_RESTORER
-# if _MIPS_SIM == _ABIO32
- kact.sa_restorer = act->sa_restorer;
-# else
- kact.sa_restorer = &restore_rt;
-# endif
-# endif
- }
-
- result = __syscall_sigaction(sig, act ? __ptrvalue (&kact) : NULL,
- oact ? __ptrvalue (&koact) : NULL);
-
- if (result < 0) {
- __set_errno(-result);
- return -1;
- }
-
- if (oact) {
- oact->sa_handler = koact.k_sa_handler;
- oact->sa_mask.__val[0] = koact.sa_mask;
- oact->sa_flags = koact.sa_flags;
-# ifdef HAVE_SA_RESTORER
- oact->sa_restorer = koact.sa_restorer;
+ int result;
+ struct old_kernel_sigaction kact, koact;
+
+ if (act) {
+ kact.k_sa_handler = act->sa_handler;
+ kact.sa_mask = act->sa_mask.__val[0];
+ kact.sa_flags = act->sa_flags;
+# if _MIPS_SIM == _ABIO32
+ kact.sa_restorer = act->sa_restorer;
+# else
+ kact.sa_restorer = &restore_rt;
# endif
- }
- return result;
+ }
+ result = __syscall_sigaction(sig,
+ act ? &kact : NULL,
+ oact ? &koact : NULL);
+ if (result < 0) {
+ __set_errno(-result);
+ return -1;
+ }
+ if (oact) {
+ oact->sa_handler = koact.k_sa_handler;
+ oact->sa_mask.__val[0] = koact.sa_mask;
+ oact->sa_flags = koact.sa_flags;
+ oact->sa_restorer = koact.sa_restorer;
+ }
+ return result;
}
#endif
+
#ifndef LIBC_SIGACTION
-libc_hidden_proto(sigaction)
+# ifndef __UCLIBC_HAS_THREADS__
+strong_alias(__libc_sigaction,sigaction)
+libc_hidden_def(sigaction)
+# else
weak_alias(__libc_sigaction,sigaction)
libc_hidden_weak(sigaction)
+# endif
#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
@@ -138,21 +114,21 @@ libc_hidden_weak(sigaction)
If you ever feel the need to make any changes, please notify the
appropriate GDB maintainer. */
-#define RESTORE(name, syscall) RESTORE2 (name, syscall)
+#define RESTORE(name, syscall) RESTORE2(name, syscall)
#define RESTORE2(name, syscall) \
-__asm__ ( \
- ".align 4\n" \
- "__" #name ":\n" \
- " li $2, " #syscall "\n" \
- " syscall\n" \
- );
+__asm__ ( \
+ ".align 4\n" \
+ "__" #name ":\n" \
+ " li $2, " #syscall "\n" \
+ " syscall\n" \
+);
/* The return code for realtime-signals. */
#if _MIPS_SIM != _ABIO32
# ifdef __NR_rt_sigreturn
-RESTORE (restore_rt, __NR_rt_sigreturn)
+RESTORE(restore_rt, __NR_rt_sigreturn)
# endif
# ifdef __NR_sigreturn
-RESTORE (restore, __NR_sigreturn)
+RESTORE(restore, __NR_sigreturn)
# endif
#endif
diff --git a/libc/sysdeps/linux/mips/swapcontext.S b/libc/sysdeps/linux/mips/swapcontext.S
new file mode 100644
index 000000000..c7ac19b9f
--- /dev/null
+++ b/libc/sysdeps/linux/mips/swapcontext.S
@@ -0,0 +1,211 @@
+/* Save and set current context.
+ Copyright (C) 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Maciej W. Rozycki <macro@codesourcery.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. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#include <sys/asm.h>
+#include <sys/fpregdef.h>
+#include <sys/regdef.h>
+
+#include "ucontext_i.h"
+
+/* int swapcontext (ucontext_t *oucp, const ucontext_t *ucp) */
+
+ .text
+LOCALSZ = 0
+ARGSZ = 0
+MASK = 0x00000000
+#ifdef __PIC__
+LOCALSZ = 1 /* save gp */
+#endif
+#if _MIPS_SIM != _ABIO32
+ARGSZ = 1 /* save a1 */
+# ifdef __PIC__
+MASK = 0x10000000
+# endif
+#endif
+FRAMESZ = (((ARGSZ + LOCALSZ) * SZREG) + ALSZ) & ALMASK
+GPOFF = FRAMESZ - ((ARGSZ + 1) * SZREG)
+#if _MIPS_SIM != _ABIO32
+A1OFF = FRAMESZ - (1 * SZREG) /* callee-allocated */
+#else
+A1OFF = FRAMESZ + (1 * SZREG) /* caller-allocated */
+#endif
+
+NESTED (__swapcontext, FRAMESZ, ra)
+ .mask MASK, -(ARGSZ * SZREG)
+ .fmask 0x00000000, 0
+
+#ifdef __PIC__
+ SETUP_GP
+
+ move a2, sp
+# define _SP a2
+
+# if _MIPS_SIM != _ABIO32
+ move a3, gp
+# define _GP a3
+# endif
+
+ PTR_ADDIU sp, -FRAMESZ
+ SETUP_GP64 (GPOFF, __swapcontext)
+ SAVE_GP (GPOFF)
+
+#else /* ! __PIC__ */
+# define _SP sp
+# define _GP gp
+
+#endif /* ! __PIC__ */
+
+#ifdef PROF
+ .set noat
+ move AT, ra
+ jal _mcount
+ .set at
+#endif
+
+ /* Store a magic flag. */
+ li v1, 1
+ REG_S v1, (0 * SZREG + MCONTEXT_GREGS)(a0) /* zero */
+
+ REG_S s0, (16 * SZREG + MCONTEXT_GREGS)(a0)
+ REG_S s1, (17 * SZREG + MCONTEXT_GREGS)(a0)
+ REG_S s2, (18 * SZREG + MCONTEXT_GREGS)(a0)
+ REG_S s3, (19 * SZREG + MCONTEXT_GREGS)(a0)
+ REG_S s4, (20 * SZREG + MCONTEXT_GREGS)(a0)
+ REG_S s5, (21 * SZREG + MCONTEXT_GREGS)(a0)
+ REG_S s6, (22 * SZREG + MCONTEXT_GREGS)(a0)
+ REG_S s7, (23 * SZREG + MCONTEXT_GREGS)(a0)
+#if ! defined (__PIC__) || _MIPS_SIM != _ABIO32
+ REG_S _GP, (28 * SZREG + MCONTEXT_GREGS)(a0)
+#endif
+ REG_S _SP, (29 * SZREG + MCONTEXT_GREGS)(a0)
+ REG_S fp, (30 * SZREG + MCONTEXT_GREGS)(a0)
+ REG_S ra, (31 * SZREG + MCONTEXT_GREGS)(a0)
+ REG_S ra, MCONTEXT_PC(a0)
+
+#ifdef __mips_hard_float
+# if _MIPS_SIM == _ABI64
+ s.d fs0, (24 * SZREG + MCONTEXT_FPREGS)(a0)
+ s.d fs1, (25 * SZREG + MCONTEXT_FPREGS)(a0)
+ s.d fs2, (26 * SZREG + MCONTEXT_FPREGS)(a0)
+ s.d fs3, (27 * SZREG + MCONTEXT_FPREGS)(a0)
+ s.d fs4, (28 * SZREG + MCONTEXT_FPREGS)(a0)
+ s.d fs5, (29 * SZREG + MCONTEXT_FPREGS)(a0)
+ s.d fs6, (30 * SZREG + MCONTEXT_FPREGS)(a0)
+ s.d fs7, (31 * SZREG + MCONTEXT_FPREGS)(a0)
+
+# else /* _MIPS_SIM != _ABI64 */
+ s.d fs0, (20 * SZREG + MCONTEXT_FPREGS)(a0)
+ s.d fs1, (22 * SZREG + MCONTEXT_FPREGS)(a0)
+ s.d fs2, (24 * SZREG + MCONTEXT_FPREGS)(a0)
+ s.d fs3, (26 * SZREG + MCONTEXT_FPREGS)(a0)
+ s.d fs4, (28 * SZREG + MCONTEXT_FPREGS)(a0)
+ s.d fs5, (30 * SZREG + MCONTEXT_FPREGS)(a0)
+
+# endif /* _MIPS_SIM != _ABI64 */
+
+ cfc1 v1, fcr31
+ sw v1, MCONTEXT_FPC_CSR(a0)
+#endif /* __mips_hard_float */
+
+ REG_S a1, A1OFF(sp)
+
+/* rt_sigprocmask (SIG_SETMASK, &ucp->uc_sigmask, &oucp->uc_sigmask, _NSIG8) */
+ li a3, _NSIG8
+ PTR_ADDU a2, a0, UCONTEXT_SIGMASK
+ PTR_ADDU a1, a1, UCONTEXT_SIGMASK
+ li a0, SIG_SETMASK
+
+ li v0, SYS_ify (rt_sigprocmask)
+ syscall
+ bnez a3, 99f
+
+ REG_L v0, A1OFF(sp)
+
+#ifdef __mips_hard_float
+# if _MIPS_SIM == _ABI64
+ l.d fs0, (24 * SZREG + MCONTEXT_FPREGS)(v0)
+ l.d fs1, (25 * SZREG + MCONTEXT_FPREGS)(v0)
+ l.d fs2, (26 * SZREG + MCONTEXT_FPREGS)(v0)
+ l.d fs3, (27 * SZREG + MCONTEXT_FPREGS)(v0)
+ l.d fs4, (28 * SZREG + MCONTEXT_FPREGS)(v0)
+ l.d fs5, (29 * SZREG + MCONTEXT_FPREGS)(v0)
+ l.d fs6, (30 * SZREG + MCONTEXT_FPREGS)(v0)
+ l.d fs7, (31 * SZREG + MCONTEXT_FPREGS)(v0)
+
+# else /* _MIPS_SIM != _ABI64 */
+ l.d fs0, (20 * SZREG + MCONTEXT_FPREGS)(v0)
+ l.d fs1, (22 * SZREG + MCONTEXT_FPREGS)(v0)
+ l.d fs2, (24 * SZREG + MCONTEXT_FPREGS)(v0)
+ l.d fs3, (26 * SZREG + MCONTEXT_FPREGS)(v0)
+ l.d fs4, (28 * SZREG + MCONTEXT_FPREGS)(v0)
+ l.d fs5, (30 * SZREG + MCONTEXT_FPREGS)(v0)
+
+# endif /* _MIPS_SIM != _ABI64 */
+
+ lw v1, MCONTEXT_FPC_CSR(v0)
+ ctc1 v1, fcr31
+#endif /* __mips_hard_float */
+
+ /* Note the contents of argument registers will be random
+ unless makecontext() has been called. */
+ REG_L a0, (4 * SZREG + MCONTEXT_GREGS)(v0)
+ REG_L a1, (5 * SZREG + MCONTEXT_GREGS)(v0)
+ REG_L a2, (6 * SZREG + MCONTEXT_GREGS)(v0)
+ REG_L a3, (7 * SZREG + MCONTEXT_GREGS)(v0)
+#if _MIPS_SIM != _ABIO32
+ REG_L a4, (8 * SZREG + MCONTEXT_GREGS)(v0)
+ REG_L a5, (9 * SZREG + MCONTEXT_GREGS)(v0)
+ REG_L a6, (10 * SZREG + MCONTEXT_GREGS)(v0)
+ REG_L a7, (11 * SZREG + MCONTEXT_GREGS)(v0)
+#endif
+
+ REG_L s0, (16 * SZREG + MCONTEXT_GREGS)(v0)
+ REG_L s1, (17 * SZREG + MCONTEXT_GREGS)(v0)
+ REG_L s2, (18 * SZREG + MCONTEXT_GREGS)(v0)
+ REG_L s3, (19 * SZREG + MCONTEXT_GREGS)(v0)
+ REG_L s4, (20 * SZREG + MCONTEXT_GREGS)(v0)
+ REG_L s5, (21 * SZREG + MCONTEXT_GREGS)(v0)
+ REG_L s6, (22 * SZREG + MCONTEXT_GREGS)(v0)
+ REG_L s7, (23 * SZREG + MCONTEXT_GREGS)(v0)
+#if ! defined (__PIC__) || _MIPS_SIM != _ABIO32
+ REG_L gp, (28 * SZREG + MCONTEXT_GREGS)(v0)
+#endif
+ REG_L sp, (29 * SZREG + MCONTEXT_GREGS)(v0)
+ REG_L fp, (30 * SZREG + MCONTEXT_GREGS)(v0)
+ REG_L ra, (31 * SZREG + MCONTEXT_GREGS)(v0)
+ REG_L t9, MCONTEXT_PC(v0)
+
+ move v0, zero
+ jr t9
+
+99:
+#ifdef __PIC__
+ PTR_LA t9, JUMPTARGET (__syscall_error)
+ RESTORE_GP64
+ PTR_ADDIU sp, FRAMESZ
+ jr t9
+
+#else /* ! __PIC__ */
+
+ j JUMPTARGET (__syscall_error)
+#endif /* ! __PIC__ */
+PSEUDO_END (__swapcontext)
+
+weak_alias (__swapcontext, swapcontext)
diff --git a/libc/sysdeps/linux/mips/sys/asm.h b/libc/sysdeps/linux/mips/sys/asm.h
index 76f6af3e1..809bde406 100644
--- a/libc/sysdeps/linux/mips/sys/asm.h
+++ b/libc/sysdeps/linux/mips/sys/asm.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_ASM_H
#define _SYS_ASM_H
@@ -97,6 +96,7 @@ l: \
# define SETUP_GPX64_L(cp_reg, ra_save, l)
# define RESTORE_GP64
# define USE_ALT_CP(a)
+# define L(label) $L ## label
#else /* (_MIPS_SIM == _MIPS_SIM_ABI64) || (_MIPS_SIM == _MIPS_SIM_NABI32) */
/*
* For callee-saved gp calling convention:
@@ -131,6 +131,7 @@ l: \
/* Use alternate register for context pointer. */
# define USE_ALT_CP(reg) \
.cplocal reg
+# define L(label) .L ## label
#endif /* _MIPS_SIM != _MIPS_SIM_ABI32 */
/*
@@ -324,7 +325,7 @@ symbol = value
# define INT_ADDI addi
# define INT_ADDU addu
# define INT_ADDIU addiu
-# define INT_SUB add
+# define INT_SUB sub
# define INT_SUBI subi
# define INT_SUBU subu
# define INT_SUBIU subu
@@ -337,7 +338,7 @@ symbol = value
# define INT_ADDI daddi
# define INT_ADDU daddu
# define INT_ADDIU daddiu
-# define INT_SUB dadd
+# define INT_SUB dsub
# define INT_SUBI dsubi
# define INT_SUBU dsubu
# define INT_SUBIU dsubu
@@ -353,7 +354,7 @@ symbol = value
# define LONG_ADDI addi
# define LONG_ADDU addu
# define LONG_ADDIU addiu
-# define LONG_SUB add
+# define LONG_SUB sub
# define LONG_SUBI subi
# define LONG_SUBU subu
# define LONG_SUBIU subu
@@ -372,7 +373,7 @@ symbol = value
# define LONG_ADDI daddi
# define LONG_ADDU daddu
# define LONG_ADDIU daddiu
-# define LONG_SUB dadd
+# define LONG_SUB dsub
# define LONG_SUBI dsubi
# define LONG_SUBU dsubu
# define LONG_SUBIU dsubu
@@ -394,7 +395,7 @@ symbol = value
# define PTR_ADDI addi
# define PTR_ADDU addu
# define PTR_ADDIU addiu
-# define PTR_SUB add
+# define PTR_SUB sub
# define PTR_SUBI subi
# define PTR_SUBU subu
# define PTR_SUBIU subu
@@ -416,7 +417,7 @@ symbol = value
# define PTR_ADDI addi
# define PTR_ADDU add /* no u */
# define PTR_ADDIU addi /* no u */
-# define PTR_SUB add
+# define PTR_SUB sub
# define PTR_SUBI subi
# define PTR_SUBU sub /* no u */
# define PTR_SUBIU sub /* no u */
@@ -439,7 +440,7 @@ symbol = value
# define PTR_ADDI daddi
# define PTR_ADDU daddu
# define PTR_ADDIU daddiu
-# define PTR_SUB dadd
+# define PTR_SUB dsub
# define PTR_SUBI dsubi
# define PTR_SUBU dsubu
# define PTR_SUBIU dsubu
@@ -470,4 +471,20 @@ symbol = value
# define MTC0 dmtc0
#endif
+/* The MIPS archtectures do not have a uniform memory model. Particular
+ platforms may provide additional guarantees - for instance, the R4000
+ LL and SC instructions implicitly perform a SYNC, and the 4K promises
+ strong ordering.
+
+ However, in the absence of those guarantees, we must assume weak ordering
+ and SYNC explicitly where necessary.
+
+ Some obsolete MIPS processors may not support the SYNC instruction. This
+ applies to "true" MIPS I processors; most of the processors which compile
+ using MIPS I implement parts of MIPS II. */
+
+#ifndef MIPS_SYNC
+# define MIPS_SYNC sync
+#endif
+
#endif /* sys/asm.h */
diff --git a/libc/sysdeps/linux/mips/sys/cachectl.h b/libc/sysdeps/linux/mips/sys/cachectl.h
index a93e1fb6d..034999e73 100644
--- a/libc/sysdeps/linux/mips/sys/cachectl.h
+++ b/libc/sysdeps/linux/mips/sys/cachectl.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_CACHECTL_H
#define _SYS_CACHECTL_H 1
@@ -29,13 +28,15 @@
__BEGIN_DECLS
#ifdef __USE_MISC
-extern int cachectl (void *addr, __const int nbytes, __const int op) __THROW;
+extern int cachectl (void *addr, const int nbytes, const int op) __THROW;
+#endif
+#if 0
+extern int __cachectl (void *addr, const int nbytes, const int op) __THROW;
#endif
-extern int __cachectl (void *addr, __const int nbytes, __const int op) __THROW;
#ifdef __USE_MISC
-extern int cacheflush (void *addr, __const int nbytes, __const int op) __THROW;
+extern int cacheflush (void *addr, const int nbytes, const int op) __THROW;
#endif
-extern int _flush_cache (char *addr, __const int nbytes, __const int op) __THROW;
+extern int _flush_cache (char *addr, const int nbytes, const int op) __THROW;
__END_DECLS
diff --git a/libc/sysdeps/linux/mips/sys/fpregdef.h b/libc/sysdeps/linux/mips/sys/fpregdef.h
index 378115274..170f96c77 100644
--- a/libc/sysdeps/linux/mips/sys/fpregdef.h
+++ b/libc/sysdeps/linux/mips/sys/fpregdef.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 92, 94, 95, 96, 97, 98 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2015 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
@@ -12,26 +12,56 @@
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. */
+ License along with the GNU C Library. If not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_FPREGDEF_H
#define _SYS_FPREGDEF_H
-/*
- * These definitions only cover the R3000-ish 16/32 register model.
- * But we're trying to be R3000 friendly anyway ...
- */
-#define fv0 $f0 /* return value */
-#define fv0f $f1
+/* Commonalities first, individualities next... */
+
+#define fv0 $f0 /* return value */
#define fv1 $f2
+
+#if _MIPS_SIM == _ABIO32 || _MIPS_SIM == _ABIN32
+#define fs0 $f20 /* callee saved */
+#define fs1 $f22
+#define fs2 $f24
+#define fs3 $f26
+#define fs4 $f28
+#define fs5 $f30
+#endif /* _MIPS_SIM == _ABIO32 || _MIPS_SIM == _ABIN32 */
+
+#if _MIPS_SIM == _ABI64 || _MIPS_SIM == _ABIN32
+#define fa0 $f12 /* argument registers */
+#define fa1 $f13
+#define fa2 $f14
+#define fa3 $f15
+#define fa4 $f16
+#define fa5 $f17
+#define fa6 $f18
+#define fa7 $f19
+
+#define ft0 $f4 /* caller saved */
+#define ft1 $f5
+#define ft2 $f6
+#define ft3 $f7
+#define ft4 $f8
+#define ft5 $f9
+#define ft6 $f10
+#define ft7 $f11
+#endif /* _MIPS_SIM == _ABI64 || _MIPS_SIM == _ABIN32 */
+
+#if _MIPS_SIM == _ABIO32
+#define fv0f $f1 /* return value, high part */
#define fv1f $f3
-#define fa0 $f12 /* argument registers */
+
+#define fa0 $f12 /* argument registers */
#define fa0f $f13
#define fa1 $f14
#define fa1f $f15
-#define ft0 $f4 /* caller saved */
+
+#define ft0 $f4 /* caller saved */
#define ft0f $f5
#define ft1 $f6
#define ft1f $f7
@@ -43,19 +73,44 @@
#define ft4f $f17
#define ft5 $f18
#define ft5f $f19
-#define fs0 $f20 /* callee saved */
-#define fs0f $f21
-#define fs1 $f22
+
+#define fs0f $f21 /* callee saved, high part */
#define fs1f $f23
-#define fs2 $f24
#define fs2f $f25
-#define fs3 $f26
#define fs3f $f27
-#define fs4 $f28
#define fs4f $f29
-#define fs5 $f30
#define fs5f $f31
+#endif /* _MIPS_SIM == _ABIO32 */
+
+#if _MIPS_SIM == _ABI64
+#define ft8 $f20 /* caller saved */
+#define ft9 $f21
+#define ft10 $f22
+#define ft11 $f23
+#define ft12 $f1
+#define ft13 $f3
+
+#define fs0 $f24 /* callee saved */
+#define fs1 $f25
+#define fs2 $f26
+#define fs3 $f27
+#define fs4 $f28
+#define fs5 $f29
+#define fs6 $f30
+#define fs7 $f31
+#endif /* _MIPS_SIM == _ABI64 */
+
+#if _MIPS_SIM == _ABIN32
+#define ft8 $f21 /* caller saved */
+#define ft9 $f23
+#define ft10 $f25
+#define ft11 $f27
+#define ft12 $f29
+#define ft13 $f31
+#define ft14 $f1
+#define ft15 $f3
+#endif /* _MIPS_SIM == _ABIN32 */
-#define fcr31 $31 /* FPU status register */
+#define fcr31 $31 /* FPU status register */
#endif /* sys/fpregdef.h */
diff --git a/libc/sysdeps/linux/mips/sys/procfs.h b/libc/sysdeps/linux/mips/sys/procfs.h
index a21652e1c..d4a61659a 100644
--- a/libc/sysdeps/linux/mips/sys/procfs.h
+++ b/libc/sysdeps/linux/mips/sys/procfs.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_PROCFS_H
#define _SYS_PROCFS_H 1
diff --git a/libc/sysdeps/linux/mips/sys/regdef.h b/libc/sysdeps/linux/mips/sys/regdef.h
index 9d2c4c1c4..51f71675a 100644
--- a/libc/sysdeps/linux/mips/sys/regdef.h
+++ b/libc/sysdeps/linux/mips/sys/regdef.h
@@ -13,13 +13,14 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_REGDEF_H
#define _SYS_REGDEF_H
+#include <sgidefs.h>
+
/*
* Symbolic register names for 32 bit ABI
*/
diff --git a/libc/sysdeps/linux/mips/sys/sysmips.h b/libc/sysdeps/linux/mips/sys/sysmips.h
index 6a63dc2b2..d568aa1fd 100644
--- a/libc/sysdeps/linux/mips/sys/sysmips.h
+++ b/libc/sysdeps/linux/mips/sys/sysmips.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_SYSMIPS_H
#define _SYS_SYSMIPS_H 1
@@ -36,8 +35,8 @@
__BEGIN_DECLS
-extern int sysmips (__const int cmd, __const long arg1,
- __const int arg2, __const int arg3) __THROW;
+extern int sysmips (const int cmd, const long arg1,
+ const int arg2, const int arg3) __THROW;
__END_DECLS
diff --git a/libc/sysdeps/linux/mips/sys/tas.h b/libc/sysdeps/linux/mips/sys/tas.h
index 1183b867b..f00ebab95 100644
--- a/libc/sysdeps/linux/mips/sys/tas.h
+++ b/libc/sysdeps/linux/mips/sys/tas.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_TAS_H
#define _SYS_TAS_H 1
@@ -30,7 +29,7 @@ extern int _test_and_set (int *p, int v) __THROW;
#ifdef __USE_EXTERN_INLINES
# ifndef _EXTERN_INLINE
-# define _EXTERN_INLINE extern __inline
+# define _EXTERN_INLINE __extern_inline
# endif
_EXTERN_INLINE int
diff --git a/libc/sysdeps/linux/mips/sys/ucontext.h b/libc/sysdeps/linux/mips/sys/ucontext.h
index ac496f3d6..0fbe5f3eb 100644
--- a/libc/sysdeps/linux/mips/sys/ucontext.h
+++ b/libc/sysdeps/linux/mips/sys/ucontext.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* Don't rely on this, the interface is currently messed up and may need to
be broken to be fixed. */
diff --git a/libc/sysdeps/linux/mips/sys/user.h b/libc/sysdeps/linux/mips/sys/user.h
index 5d880943e..b41962f3d 100644
--- a/libc/sysdeps/linux/mips/sys/user.h
+++ b/libc/sysdeps/linux/mips/sys/user.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_USER_H
#define _SYS_USER_H 1
diff --git a/libc/sysdeps/linux/mips/syscall.S b/libc/sysdeps/linux/mips/syscall.S
index ff6f3d1b4..79cabc6dc 100644
--- a/libc/sysdeps/linux/mips/syscall.S
+++ b/libc/sysdeps/linux/mips/syscall.S
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <features.h>
#include <sys/asm.h>
@@ -32,7 +31,6 @@ syscall:
#ifdef __PIC__
SETUP_GP
#endif
- .set noreorder
move v0, a0 /* Load system call number from first arg. */
move a0, a1 /* Move the next three args up a register. */
move a1, a2
@@ -59,12 +57,12 @@ syscall:
lw v0,7*4(sp) /* for system call restarts */
#endif
syscall /* Do the system call. */
- bnez a3, 1f
#ifdef __mips64
daddiu sp,sp,16
#else
addiu sp,sp,32
#endif
+ bnez a3, 1f
j ra /* Return to caller. */
1:
move a0,v0 /* Pass return val to C function. */
diff --git a/libc/sysdeps/linux/mips/syscall_error.S b/libc/sysdeps/linux/mips/syscall_error.S
new file mode 100644
index 000000000..2fb56b128
--- /dev/null
+++ b/libc/sysdeps/linux/mips/syscall_error.S
@@ -0,0 +1,83 @@
+/* Copyright (C) 1992, 1993, 1994, 1997, 1998, 1999, 2000, 2002, 2003
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sys/asm.h>
+#include <sysdep.h>
+#include <bits/errno.h>
+
+#ifdef _LIBC_REENTRANT
+
+LOCALSZ= 3
+FRAMESZ= (((NARGSAVE+LOCALSZ)*SZREG)+ALSZ)&ALMASK
+RAOFF= FRAMESZ-(1*SZREG)
+GPOFF= FRAMESZ-(2*SZREG)
+V0OFF= FRAMESZ-(3*SZREG)
+
+ENTRY(__syscall_error)
+#ifdef __PIC__
+ .set noat
+ SETUP_GPX (AT)
+ .set at
+#endif
+ PTR_SUBU sp, FRAMESZ
+ .set noat
+ SETUP_GPX64(GPOFF,AT)
+ .set at
+#ifdef __PIC__
+ SAVE_GP(GPOFF)
+#endif
+ REG_S a0, V0OFF(sp)
+ REG_S ra, RAOFF(sp)
+
+ /* Find our per-thread errno address */
+ jal __errno_location
+
+ /* Store the error value. */
+ REG_L t0, V0OFF(sp)
+ sw t0, 0(v0)
+
+ /* And just kick back a -1. */
+ REG_L ra, RAOFF(sp)
+ RESTORE_GP64
+ PTR_ADDU sp, FRAMESZ
+ li v0, -1
+ j ra
+ END(__syscall_error)
+
+#else /* __LIBC_REENTRANT */
+
+
+ENTRY(__syscall_error)
+#ifdef __PIC__
+ .set noat
+ SETUP_GPX (AT)
+ .set at
+#endif
+ SETUP_GPX64 (t9, AT)
+
+ /* Store it in errno... */
+ sw v0, errno
+
+ /* And just kick back a -1. */
+ li v0, -1
+
+ RESTORE_GP64
+ j ra
+ END(__syscall_error)
+#endif /* _LIBC_REENTRANT*/
diff --git a/libc/sysdeps/linux/mips/sysdep.h b/libc/sysdeps/linux/mips/sysdep.h
new file mode 100644
index 000000000..86873ac7b
--- /dev/null
+++ b/libc/sysdeps/linux/mips/sysdep.h
@@ -0,0 +1,138 @@
+/* Copyright (C) 1992, 1995, 1997, 1999, 2000, 2002, 2003, 2004
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _LINUX_MIPS_SYSDEP_H
+#define _LINUX_MIPS_SYSDEP_H 1
+
+#include <sgidefs.h>
+#include <common/sysdep.h>
+
+/* For Linux we can use the system call table in the header file
+ /usr/include/asm/unistd.h
+ of the kernel. But these symbols do not follow the SYS_* syntax
+ so we have to redefine the `SYS_ify' macro here. */
+
+#undef SYS_ify
+#ifdef __STDC__
+# define SYS_ify(syscall_name) __NR_##syscall_name
+#else
+# define SYS_ify(syscall_name) __NR_/**/syscall_name
+#endif
+
+#ifdef __ASSEMBLER__
+
+#include <sys/regdef.h>
+
+#define ENTRY(name) \
+ .globl name; \
+ .align 2; \
+ .ent name,0; \
+ name##:
+
+#undef END
+#define END(function) \
+ .end function; \
+ .size function,.-function
+
+#define ret j ra ; nop
+
+#undef PSEUDO_END
+#define PSEUDO_END(sym) .end sym; .size sym,.-sym
+
+#define PSEUDO_NOERRNO(name, syscall_name, args) \
+ .align 2; \
+ ENTRY(name) \
+ .set noreorder; \
+ li v0, SYS_ify(syscall_name); \
+ syscall
+
+#undef PSEUDO_END_NOERRNO
+#define PSEUDO_END_NOERRNO(sym) .end sym; .size sym,.-sym
+
+#define ret_NOERRNO ret
+
+#define PSEUDO_ERRVAL(name, syscall_name, args) \
+ .align 2; \
+ ENTRY(name) \
+ .set noreorder; \
+ li v0, SYS_ify(syscall_name); \
+ syscall
+
+#undef PSEUDO_END_ERRVAL
+#define PSEUDO_END_ERRVAL(sym) .end sym; .size sym,.-sym
+
+#define r0 v0
+#define r1 v1
+/* The mips move insn is d,s. */
+#define MOVE(x,y) move y , x
+
+#if _MIPS_SIM == _ABIO32
+# define L(label) $L ## label
+#else
+# define L(label) .L ## label
+#endif
+
+/* Note that while it's better structurally, going back to call __syscall_error
+ can make things confusing if you're debugging---it looks like it's jumping
+ backwards into the previous fn. */
+
+#ifdef __PIC__
+#define PSEUDO(name, syscall_name, args) \
+ .align 2; \
+ 99: move a0, v0; \
+ la t9,__syscall_error; \
+ jr t9; \
+ ENTRY(name) \
+ .set noreorder; \
+ .cpload t9; \
+ li v0, SYS_ify(syscall_name); \
+ syscall; \
+ .set reorder; \
+ bne a3, zero, 99b; \
+L(syse1):
+#else
+#define PSEUDO(name, syscall_name, args) \
+ .set noreorder; \
+ .align 2; \
+ 99: move a0, v0; \
+ j __syscall_error; \
+ nop; \
+ ENTRY(name) \
+ .set noreorder; \
+ li v0, SYS_ify(syscall_name); \
+ syscall; \
+ .set reorder; \
+ bne a3, zero, 99b; \
+L(syse1):
+#endif
+
+/* We don't want the label for the error handler to be visible in the symbol
+ table when we define it here. */
+#ifdef __PIC__
+# define SYSCALL_ERROR_LABEL 99b
+#endif
+
+#else /* ! __ASSEMBLER__ */
+
+/* Pointer mangling is not yet supported for MIPS. */
+#define PTR_MANGLE(var) (void) (var)
+#define PTR_DEMANGLE(var) (void) (var)
+
+#endif /* __ASSEMBLER__ */
+#endif /* _LINUX_MIPS_SYSDEP_H */
diff --git a/libc/sysdeps/linux/mips/sysmips.c b/libc/sysdeps/linux/mips/sysmips.c
index 020f02dd3..1384782b4 100644
--- a/libc/sysdeps/linux/mips/sysmips.c
+++ b/libc/sysdeps/linux/mips/sysmips.c
@@ -3,5 +3,5 @@
#include <sys/sysmips.h>
#ifdef __NR_sysmips
-_syscall4(int, sysmips, const int, cmd, const long, arg1, const int, arg2, const int, arg3);
+_syscall4(int, sysmips, const int, cmd, const long, arg1, const int, arg2, const int, arg3)
#endif
diff --git a/libc/sysdeps/linux/mips/ucontext_i.sym b/libc/sysdeps/linux/mips/ucontext_i.sym
new file mode 100644
index 000000000..f14b88640
--- /dev/null
+++ b/libc/sysdeps/linux/mips/ucontext_i.sym
@@ -0,0 +1,52 @@
+#include <inttypes.h>
+#include <signal.h>
+#include <stddef.h>
+#include <sys/ucontext.h>
+
+#include <kernel_rt_sigframe.h>
+
+-- Constants used by the rt_sigprocmask call.
+
+SIG_BLOCK
+SIG_SETMASK
+
+_NSIG8 (_NSIG / 8)
+
+-- Offsets of the fields in the kernel rt_sigframe_t structure.
+#define rt_sigframe(member) offsetof (kernel_rt_sigframe_t, member)
+
+RT_SIGFRAME_UCONTEXT rt_sigframe (rs_uc)
+
+RT_SIGFRAME_SIZE sizeof (kernel_rt_sigframe_t)
+
+-- Offsets of the fields in the ucontext_t structure.
+#define ucontext(member) offsetof (ucontext_t, member)
+#define stack(member) ucontext (uc_stack.member)
+#define mcontext(member) ucontext (uc_mcontext.member)
+
+UCONTEXT_FLAGS ucontext (uc_flags)
+UCONTEXT_LINK ucontext (uc_link)
+UCONTEXT_STACK ucontext (uc_stack)
+UCONTEXT_MCONTEXT ucontext (uc_mcontext)
+UCONTEXT_SIGMASK ucontext (uc_sigmask)
+
+STACK_SP stack (ss_sp)
+STACK_SIZE stack (ss_size)
+STACK_FLAGS stack (ss_flags)
+
+MCONTEXT_GREGS mcontext (gregs)
+MCONTEXT_FPREGS mcontext (fpregs)
+MCONTEXT_MDHI mcontext (mdhi)
+MCONTEXT_HI1 mcontext (hi1)
+MCONTEXT_HI2 mcontext (hi2)
+MCONTEXT_HI3 mcontext (hi3)
+MCONTEXT_MDLO mcontext (mdlo)
+MCONTEXT_LO1 mcontext (lo1)
+MCONTEXT_LO2 mcontext (lo2)
+MCONTEXT_LO3 mcontext (lo3)
+MCONTEXT_PC mcontext (pc)
+MCONTEXT_FPC_CSR mcontext (fpc_csr)
+MCONTEXT_USED_MATH mcontext (used_math)
+MCONTEXT_DSP mcontext (dsp)
+
+UCONTEXT_SIZE sizeof (ucontext_t)
diff --git a/libc/sysdeps/linux/mips/vfork.S b/libc/sysdeps/linux/mips/vfork.S
new file mode 100644
index 000000000..9311504d2
--- /dev/null
+++ b/libc/sysdeps/linux/mips/vfork.S
@@ -0,0 +1,102 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+/* vfork() is just a special case of clone(). */
+
+#include <sys/syscall.h>
+#include <sys/asm.h>
+#include <sysdep.h>
+
+#ifndef SAVE_PID
+#define SAVE_PID
+#endif
+
+#ifndef RESTORE_PID
+#define RESTORE_PID
+#endif
+
+#ifdef __NR_fork
+
+/* int vfork() */
+
+ .text
+ .hidden __vfork
+LOCALSZ= 1
+FRAMESZ= (((NARGSAVE+LOCALSZ)*SZREG)+ALSZ)&ALMASK
+GPOFF= FRAMESZ-(1*SZREG)
+NESTED(__vfork,FRAMESZ,sp)
+#ifdef __PIC__
+ SETUP_GP
+#endif
+ PTR_SUBU sp, FRAMESZ
+ SETUP_GP64 (a5, __vfork)
+#ifdef __PIC__
+ SAVE_GP (GPOFF)
+#endif
+#ifdef PROF
+# if (_MIPS_SIM != _ABIO32)
+ PTR_S a5, GPOFF(sp)
+# endif
+ .set noat
+ move $1, ra
+# if (_MIPS_SIM == _ABIO32)
+ subu sp,sp,8
+# endif
+ jal _mcount
+ .set at
+# if (_MIPS_SIM != _ABIO32)
+ PTR_L a5, GPOFF(sp)
+# endif
+#endif
+
+ PTR_ADDU sp, FRAMESZ
+
+ SAVE_PID
+
+ li a0, 0x4112 /* CLONE_VM | CLONE_VFORK | SIGCHLD */
+ move a1, sp
+
+ /* Do the system call */
+ li v0,__NR_clone
+ syscall
+
+ RESTORE_PID
+
+ bnez a3,L(error)
+
+ /* Successful return from the parent or child. */
+ RESTORE_GP64
+ j ra
+ nop
+
+ /* Something bad happened -- no child created. */
+L(error):
+ move a0, v0
+#ifdef __PIC__
+ PTR_LA t9, __syscall_error
+ RESTORE_GP64
+ jr t9
+#else
+ RESTORE_GP64
+ j __syscall_error
+#endif
+ END(__vfork)
+
+weak_alias(__vfork,vfork)
+libc_hidden_def(vfork)
+
+#endif
diff --git a/libc/sysdeps/linux/nios/Makefile.arch b/libc/sysdeps/linux/nios/Makefile.arch
deleted file mode 100644
index 9bcd0be7e..000000000
--- a/libc/sysdeps/linux/nios/Makefile.arch
+++ /dev/null
@@ -1,14 +0,0 @@
-# Makefile 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.
-#
-
-CSRC := brk.c crtbegin.c crtend.c
-
-SSRC := \
- __longjmp.S bsd-_setjmp.S bsd-setjmp.S setjmp.S \
- clone.S vfork.S
-
-include $(top_srcdir)libc/sysdeps/linux/Makefile.commonarch
diff --git a/libc/sysdeps/linux/nios/NM_Macros.S b/libc/sysdeps/linux/nios/NM_Macros.S
deleted file mode 100644
index da6136593..000000000
--- a/libc/sysdeps/linux/nios/NM_Macros.S
+++ /dev/null
@@ -1,473 +0,0 @@
-
-;------------------------------
-; Macros I: Faux Instructions
-;
-; The following "faux instructions" are
-; implemented here as macros:
-;
-; MOVIP register,constant MOVI with optional PFX & MOVHI, or BGEN
-; ADDIP register,constant PFX and ADDI with optional PFX
-; SUBIP register,constant PFX and SUBI with optional PFX
-; CMPIP register,constant PFX and CMPI with optional PFX
-;
-; MOVI16 register,constant PFX and MOVI
-; MOVI32 register,constant PFX, MOVI, PFX, and MOVHI
-; MOVIA register,constant PFX and MOVHI on Nios32, and PFX and MOVI
-;
-; ANDIP register,constant PFX and ANDI
-; ANDNIP register,constant PFX and ANDN
-; ORIP register,constant PFX and ORI
-; XORIP register,constant PFX and XORI
-;
-; _BSR address MOVIP address to %g7, and CALL
-; _BR address MOVIP address to %g7, and JMP
-;
-; BEQ address SKPS cc_nz and BR, has delay slot
-; BNE address SKPS cc_z and BR, has delay slot
-; BLE address SKPS cc_gt and BR, has delay slot
-; BLT address SKPS cc_ge and BR, has delay slot
-; RESTRET RESTORE and JMP %i7
-;
-;-------------------------------
-; Macros II: Printing
-;
-; These macros are guaranteed *not*
-; to have branch delay slot after them.
-;
-; NM_PrintChar char
-; NM_Print "string"
-; NM_PrintLn "string" Follows it with a carriage return
-; NM_PrintRegister reg For debugging, prints register name & value
-;
-;-------------------------------
-; Macros III: Inline Debugging
-;
-; These macros print various information
-; using large sections of expanded inline code.
-; They each use either few or no registers.
-; Thus, they may be safely used in interrupt handlers.
-;
-; NM_D_TxChar char print char to UART, affects no registers
-; NM_D_TxRegister char,char,register prints the two characters, and the hex register value
-
-; --------------------------------------
-
-
- .macro _pfx_op OP,reg,val,pForce=0
- .if (\pForce) || ((\val) > (31)) || ((\val) < (0))
- PFX %hi(\val)
- .endif
- \OP \reg,%lo(\val)
- .endm
-
- .macro _bgen reg,val,bit
- .if ((\val)==(1<<\bit))
- BGEN \reg,\bit
- .equ _bgenBit,1
- .endif
- .endm
-
- ;------------------------
- ; MOVIP %reg,32-bit-value
- .macro MOVIP reg,val
- ; Methodically test every BGEN possibility...
- .equ _bgenBit,0
-.if 1
- _bgen \reg,\val,0
- _bgen \reg,\val,1
- _bgen \reg,\val,2
- _bgen \reg,\val,3
- _bgen \reg,\val,4
- _bgen \reg,\val,5
- _bgen \reg,\val,6
- _bgen \reg,\val,7
- _bgen \reg,\val,8
- _bgen \reg,\val,9
- _bgen \reg,\val,10
- _bgen \reg,\val,11
- _bgen \reg,\val,12
- _bgen \reg,\val,13
- _bgen \reg,\val,14
- _bgen \reg,\val,15
- _bgen \reg,\val,16
- _bgen \reg,\val,17
- _bgen \reg,\val,18
- _bgen \reg,\val,19
- _bgen \reg,\val,20
- _bgen \reg,\val,21
- _bgen \reg,\val,22
- _bgen \reg,\val,23
- _bgen \reg,\val,24
- _bgen \reg,\val,25
- _bgen \reg,\val,26
- _bgen \reg,\val,27
- _bgen \reg,\val,28
- _bgen \reg,\val,29
- _bgen \reg,\val,30
- _bgen \reg,\val,31
-
- ; If no bgen fit...
-.endif
- .if !_bgenBit
- .if ((\val) & 0xFFE0)
- PFX %hi(\val)
- .endif
- MOVI \reg,%lo(\val)
- .if __nios32__
- .if ((\val) & 0xffff0000)
- .if ((\val) & 0xFFE00000)
- PFX %xhi(\val)
- .endif
- MOVHI \reg,%xlo(\val)
- .endif
- .endif
- .endif
-
- .endm
-
- ; ADDIP %reg,16-bit-value
- .macro ADDIP reg,val
- _pfx_op ADDI,\reg,\val
- .endm
-
- ; SUBIP %reg,16-bit-value
- .macro SUBIP reg,val
- _pfx_op SUBI,\reg,\val
- .endm
-
- ; CMPIP %reg,16-bit-value
- .macro CMPIP reg,val
- _pfx_op CMPI,\reg,\val
- .endm
-
- ; ANDIP %reg,16-bit-value
- .macro ANDIP reg,val
- PFX %hi(\val)
- AND \reg,%lo(\val)
- .endm
-
- ; ANDNIP %reg,16-bit-value
- .macro ANDNIP reg,val
- PFX %hi(\val)
- ANDN \reg,%lo(\val)
- .endm
-
- ; ORIP %reg,16-bit-value
- .macro ORIP reg,val
- PFX %hi(\val)
- OR \reg,%lo(\val)
- .endm
-
- ; XORIP %reg,16-bit-value
- .macro XORIP reg,val
- PFX %hi(\val)
- XOR \reg,%lo(\val)
- .endm
-
- ; BEQ addr
- .macro BEQ addr
- IFS cc_eq
- BR \addr
- .endm
-
- ; BNE addr
- .macro BNE addr
- IFS cc_ne
- BR \addr
- .endm
-
- ; BLE addr
- .macro BLE addr
- SKPS cc_gt
- BR \addr
- .endm
-
- ; BLT addr
- .macro BLT addr
- SKPS cc_ge
- BR \addr
- .endm
-
- .macro digitToChar reg
- ANDIP \reg,0x000f
- CMPI \reg,10
- SKPS cc_lt
- ADDI \reg,'A'-'0'-10
- PFX %hi('0')
- ADDI \reg,%lo('0')
- .endm
-
-; PUSHRET == dec sp, and stash return addr
- .macro PUSHRET
- SUBI %sp,2
- ST [%sp],%o7
- .endm
-; POPRET == pop and jump
- .macro POPRET
- LD %o7,[%sp]
- JMP %o7
- ADDI %sp,2 ; branch delay slot
- .endm
-
-; RESTRET = restore & return
- .macro RESTRET
- JMP %i7
- RESTORE
- .endm
-
- ;--------------------
- ; MOVI16 %reg,Address
- ;
- .macro MOVI16 reg,val
- PFX %hi(\val)
- MOVI \reg,%lo(\val)
- .endm
-
- ;--------------------
- ; MOVI32 %reg,Address
- ;
- .macro MOVI32 reg,val
- PFX %hi(\val)
- MOVI \reg,%lo(\val)
- PFX %xhi(\val)
- MOVHI \reg,%xlo(\val)
- .endm
-
- ;--------------------
- ; MOVIA %reg,Address
- ;
- .macro MOVIA reg,val
- .if __nios32__
- MOVI32 \reg,\val
- .else
- MOVI16 \reg,\val
- .endif
- .endm
-
- ;--------------------
- ; _BR
-
- .macro _BR target,viaRegister=%g7
- MOVIA \viaRegister,\target@h
- JMP \viaRegister
- .endm
-
- ;--------------------
- ; _BSR
-
- .macro _BSR target,viaRegister=%g7
- MOVIA \viaRegister,\target@h
- CALL \viaRegister
- .endm
-
- ;---------------------
- ; NM_Print "Your String Here"
- ;
- .macro NM_Print string
-
- BR pastStringData\@
- NOP
-
-stringData\@:
- .asciz "\string"
- .align 1 ; aligns by 2^n
-pastStringData\@:
- MOVIA %o0,stringData\@
- _BSR NR_TxString
- NOP
- .endm
-
- .macro NM_PrintLn string
- NM_Print "\string"
- _BSR NR_TxCR
- NOP
- .endm
-
- .macro NM_PrintRegister reg ; affects %g0 & %g1 & %g7, but thrashes the CWP a bit
- SAVE %sp,-16
- NM_Print "\reg = "
- RESTORE
- MOV %g0,\reg
- SAVE %sp,-16
- MOV %o0,%g0
- _BSR NR_TxHex
- NOP
- _BSR NR_TxCR
- NOP
- RESTORE
- .endm
-
- .macro NM_PrintChar char
- MOVIP %o0,\char
- _BSR NR_TxChar
- NOP
- .endm
-
- .macro NM_Print2Chars char1,char2
- MOVIP %o0,(\char2<<8)+\char1
- _BSR NR_TxChar
- NOP
- _BSR NR_TxChar
- LSRI %o0,8
- .endm
-
-
-
-; ---------------------------
-; Completely inline UART sends
-; Send the char, or %g7 if not there.
-; Trashes %g5 and %g6 and %g7...
-
- .macro NM_TxChar char=0
-;NM_D_Delay 1000
- MOVIA %g6,NA_UARTBase
-txCharLoop\@:
- PFX 2
-.if \char
- LD %g7,[%g6]
- SKP1 %g7,6
-.else
- LD %g5,[%g6]
- SKP1 %g5,6
-.endif
- BR txCharLoop\@
- NOP
-.if \char
- MOVIP %g7,\char
-.endif
- PFX 1
- ST [%g6],%g7
-;NM_D_Delay 4
- .endm
-
- .macro NM_TxCR
- NM_TxChar 13
- NM_TxChar 10
- .endm
-
- .macro NM_TxHexDigit,reg,shift
- MOV %g7,\reg
- LSRI %g7,\shift
- ANDIP %g7,0x000f
- CMPI %g7,10
- SKPS cc_lt
- ADDIP %g7,'A'-'0'-10
- ADDIP %g7,'0'
- NM_TxChar
- .endm
-
- .macro NM_TxHex
-
- .if __nios32__
- NM_TxHexDigit %g0,28
- NM_TxHexDigit %g0,24
- NM_TxHexDigit %g0,20
- NM_TxHexDigit %g0,16
- .endif
-
- NM_TxHexDigit %g0,12
- NM_TxHexDigit %g0,8
- NM_TxHexDigit %g0,4
- NM_TxHexDigit %g0,0
- .endm
-
-
-
-
-
-
-
-
-
-
-; ----------------------
-; The following macros are
-; rather mighty. They expand
-; to large inline code for
-; printing various things to
-; the serial port. They are
-; useful for debugging
-; trap handlers, where you
-; can't just go and call
-; NR_TxChar and such, because,
-; well, the CWP might be
-; off limits!
-;
-; They do, however, presume
-; that the stack is in good
-; working order.
-
-
-.macro NM_D_PushGRegisters
- SUBIP %sp,16+69 ; oddball number so if we accidentally see it, it looks funny.
- STS [%sp,16+0],%g0
- STS [%sp,16+1],%g1
- STS [%sp,16+2],%g2
- STS [%sp,16+3],%g3
- STS [%sp,16+4],%g4
- STS [%sp,16+5],%g5
- STS [%sp,16+6],%g6
- STS [%sp,16+7],%g7
- .endm
-
-.macro NM_D_PopGRegisters
- LDS %g0,[%sp,16+0]
- LDS %g1,[%sp,16+1]
- LDS %g2,[%sp,16+2]
- LDS %g3,[%sp,16+3]
- LDS %g4,[%sp,16+4]
- LDS %g5,[%sp,16+5]
- LDS %g6,[%sp,16+6]
- LDS %g7,[%sp,16+7]
- ADDIP %sp,16+69 ; must match the push
- .endm
-
-
-.macro NM_D_TxChar c
- SUBI %sp,16+8 ; 32 or 16 bit, that's enough space
- STS [%sp,16+0],%g6
- STS [%sp,16+0],%g7
- NM_TxChar \c
- LDS %g6,[%sp,16+0]
- LDS %g7,[%sp,16+1]
- ADDI %sp,16+8
- .endm
-
-.macro NM_D_TxChar3 c1,c2,c3
- NM_D_TxChar '<'
- NM_D_TxChar \c1
- NM_D_TxChar \c2
- NM_D_TxChar \c3
- NM_D_TxChar '>'
-.endm
-
-.macro NM_D_TxRegister r,n,reg
- NM_D_PushGRegisters
- NM_TxChar '('
- NM_TxChar \r
- NM_TxChar \n
- NM_TxChar ':'
- MOV %g0,\reg
- NM_TxHex
- NM_TxChar ')'
- NM_D_PopGRegisters
-.endm
-
-.macro NM_D_TxReg r,n,reg
- NM_D_TxRegister \r,\n,\reg
-.endm
-
-; Do a delay loop, affects no registers.
-
-.macro NM_D_Delay d
- SUBI %sp,16+4
- STS [%sp,16+0],%g0
- MOVIP %g0,\d
-NM_D_DelayLoop\@:
- IFRnz %g0
- BR NM_D_DelayLoop\@
- SUBI %g0,1
- LDS %g0,[%sp,16+0]
- ADDI %sp,16+4
-.endm
-
diff --git a/libc/sysdeps/linux/nios/NR_Math1.S b/libc/sysdeps/linux/nios/NR_Math1.S
deleted file mode 100644
index 5d5169ba8..000000000
--- a/libc/sysdeps/linux/nios/NR_Math1.S
+++ /dev/null
@@ -1,63 +0,0 @@
-
-
- .include "NM_Macros.S"
-
- .file "okmul.c"
-gcc2_compiled.:
- .text
- .p2align 1
- .globl __mulsi3
- .type __mulsi3,@function
-__mulsi3:
-
- ;SKP0 %o0,31
- ;NEG %o1
- ;ABS %o0
-
- .MACRO ZSTEP bit
- SKP0 %o0,\bit
- ADD %g0,%o1
- LSLI %o1,1
- .ENDM
-
- MOVI %g0,0
- ZSTEP 0
- ZSTEP 1
- ZSTEP 2
- ZSTEP 3
- ZSTEP 4
- ZSTEP 5
- ZSTEP 6
- ZSTEP 7
- ZSTEP 8
- ZSTEP 9
- ZSTEP 10
- ZSTEP 11
- ZSTEP 12
- ZSTEP 13
- ZSTEP 14
- ZSTEP 15
- ZSTEP 16
- ZSTEP 17
- ZSTEP 18
- ZSTEP 19
- ZSTEP 20
- ZSTEP 21
- ZSTEP 22
- ZSTEP 23
- ZSTEP 24
- ZSTEP 25
- ZSTEP 26
- ZSTEP 27
- ZSTEP 28
- ZSTEP 29
- ZSTEP 30
- ZSTEP 31
- ; No bit 31: we already set %o0 to positive
-
- JMP %o7
- MOV %o0,%g0
-
-.Lfe1:
- .size __mulsi3,.Lfe1-__mulsi3
-
diff --git a/libc/sysdeps/linux/nios/__longjmp.S b/libc/sysdeps/linux/nios/__longjmp.S
deleted file mode 100644
index d7d1cdd86..000000000
--- a/libc/sysdeps/linux/nios/__longjmp.S
+++ /dev/null
@@ -1,103 +0,0 @@
-/* Copyright (C) 1997, 1998 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. */
-
-#include <features.h>
-#define _ASM
-#define _SETJMP_H
-#include <bits/setjmp.h>
-
-
-;----------------------------------------
-; Name: __longjmp
-; Description: Restore the current context
-; as saved by a previous nr_setjmp
-; Input: %o0: jmp_buf (ptr to) array to restore context from
-; %o1: integer to return
-; Output: %o0 = 0 the first time we're called, or
-; whatever longjmp returns later
-; Side Effects: uses %g0, %g1 & %g2
-; CWP Depth: 0
-;
-
- .align 2
- .global __longjmp
-__longjmp:
- ;
- ; The way we'll do this is by executing
- ; RESTORE instructions until the old
- ; return address matches. Then we'll
- ; jump to where setjmp was called from.
- ;
- ; Since we're moving the window pointer
- ; all over the place, we'll naturally
- ; only use the %g registers.
- ;
-
- mov %g0,%o0 ; %g0 -> jmp_buf
- mov %g1,%o1 ; %g1 = return value
- pfx jmpbuf_callersret
- ld %g2,[%g0] ; %g2 = old return address
-__longjmp_loop:
- cmp %g2,%i7 ; Are we there yet?
- skps cc_ne
- br __longjmp_done
- nop ; (delay slot)
-
- br __longjmp_loop
- restore ; (delay slot)
- ;
- ; One might put in a watchdog counter here, to
- ; prevent a runaway stack crawl... but what would that
- ; accomplish? What error can we throw? To whom?
- ;
-
-__longjmp_done:
- pfx jmpbuf_l0 ; Restore local register l0
- ld %l0,[%g0]
- pfx jmpbuf_l1 ; Restore local register l1
- ld %l1,[%g0]
- pfx jmpbuf_l2 ; Restore local register l2
- ld %l2,[%g0]
- pfx jmpbuf_l3 ; Restore local register l3
- ld %l3,[%g0]
- pfx jmpbuf_l4 ; Restore local register l4
- ld %l4,[%g0]
- pfx jmpbuf_l5 ; Restore local register l5
- ld %l5,[%g0]
- pfx jmpbuf_l6 ; Restore local register l6
- ld %l6,[%g0]
- pfx jmpbuf_l7 ; Restore local register l7
- ld %l7,[%g0]
- pfx jmpbuf_i0 ; Restore input register i0
- ld %i0,[%g0]
- pfx jmpbuf_i1 ; Restore input register i1
- ld %i1,[%g0]
- pfx jmpbuf_i2 ; Restore input register i2
- ld %i2,[%g0]
- pfx jmpbuf_i3 ; Restore input register i3
- ld %i3,[%g0]
- pfx jmpbuf_i4 ; Restore input register i4
- ld %i4,[%g0]
- pfx jmpbuf_i5 ; Restore input register i5
- ld %i5,[%g0]
- pfx jmpbuf_jmpret
- ld %o7,[%g0] ; set fake return address
- jmp %o7 ; and kinda return there.
- mov %o0,%g1 ; (delay slot) return value
-
-libc_hidden_def(__longjmp)
diff --git a/libc/sysdeps/linux/nios/bits/endian.h b/libc/sysdeps/linux/nios/bits/endian.h
deleted file mode 100644
index 252597931..000000000
--- a/libc/sysdeps/linux/nios/bits/endian.h
+++ /dev/null
@@ -1,8 +0,0 @@
-/* nios is little-endian. */
-
-#ifndef _ENDIAN_H
-# error "Never use <bits/endian.h> directly; include <endian.h> instead."
-#endif
-
-//mle
-#define __BYTE_ORDER __LITTLE_ENDIAN
diff --git a/libc/sysdeps/linux/nios/bits/mman.h b/libc/sysdeps/linux/nios/bits/mman.h
deleted file mode 100644
index 7f644b99b..000000000
--- a/libc/sysdeps/linux/nios/bits/mman.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* Definitions for POSIX memory map interface. Linux/m68k version.
- Copyright (C) 1997 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_MMAN_H
-# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
-#endif
-
-/* The following definitions basically come from the kernel headers.
- But the kernel header is not namespace clean. */
-
-
-/* Protections are chosen from these bits, OR'd together. The
- implementation does not necessarily support PROT_EXEC or PROT_WRITE
- without PROT_READ. The only guarantees are that no writing will be
- allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
-
-#define PROT_READ 0x1 /* Page can be read. */
-#define PROT_WRITE 0x2 /* Page can be written. */
-#define PROT_EXEC 0x4 /* Page can be executed. */
-#define PROT_NONE 0x0 /* Page can not be accessed. */
-
-/* Sharing types (must choose one and only one of these). */
-#define MAP_SHARED 0x01 /* Share changes. */
-#define MAP_PRIVATE 0x02 /* Changes are private. */
-#ifdef __USE_MISC
-# define MAP_TYPE 0x0f /* Mask for type of mapping. */
-#endif
-
-/* Other flags. */
-#define MAP_FIXED 0x10 /* Interpret addr exactly. */
-#ifdef __USE_MISC
-# define MAP_FILE 0
-# define MAP_ANONYMOUS 0x20 /* Don't use a file. */
-# define MAP_ANON MAP_ANONYMOUS
-#endif
-
-/* These are Linux-specific. */
-#ifdef __USE_MISC
-# define MAP_GROWSDOWN 0x0100 /* Stack-like segment. */
-# define MAP_DENYWRITE 0x0800 /* ETXTBSY */
-# define MAP_EXECUTABLE 0x1000 /* Mark it as an executable. */
-# define MAP_LOCKED 0x2000 /* Lock the mapping. */
-# define MAP_NORESERVE 0x4000 /* Don't check for reservations. */
-#endif
-
-/* Flags to `msync'. */
-#define MS_ASYNC 1 /* Sync memory asynchronously. */
-#define MS_SYNC 4 /* Synchronous memory sync. */
-#define MS_INVALIDATE 2 /* Invalidate the caches. */
-
-/* Flags for `mlockall'. */
-#define MCL_CURRENT 1 /* Lock all currently mapped pages. */
-#define MCL_FUTURE 2 /* Lock all additions to address
- space. */
-
-/* Flags for `mremap'. */
-#ifdef __USE_GNU
-# define MREMAP_MAYMOVE 1
-# define MREMAP_FIXED 2
-#endif
diff --git a/libc/sysdeps/linux/nios/bits/setjmp.h b/libc/sysdeps/linux/nios/bits/setjmp.h
deleted file mode 100644
index 807ebea02..000000000
--- a/libc/sysdeps/linux/nios/bits/setjmp.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* Copyright (C) 1997, 1998 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 the machine-dependent type `jmp_buf'. Nios version. */
-#ifndef _BITS_SETJMP_H
-#define _BITS_SETJMP_H 1
-
-#if !defined _SETJMP_H && !defined _PTHREAD_H
-# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
-#endif
-
-#ifndef _ASM
-
-#include <signal.h>
-
-typedef struct
- {
- /* There are eight 4-byte local registers saved. */
- long int __lregs[8];
-
- /* There are six 4-byte input registers saved. */
- long int __iregs[6];
-
- /* The SP, return address to caller (also for longjmp)
- and return address of caller are saved. */
- int *__sp;
- int *__jmpret;
- int *__callersret;
-
- } __jmp_buf[1];
-
-/* Test if longjmp to JMPBUF would unwind the frame
- containing a local variable at ADDRESS. */
-#define _JMPBUF_UNWINDS(jmpbuf, address) \
- ((void *) (address) < (void *) (jmpbuf)->__sp)
-
-#else /* _ASM */
-
-#define jmpbuf_l0 0x00
-#define jmpbuf_l1 0x01
-#define jmpbuf_l2 0x02
-#define jmpbuf_l3 0x03
-#define jmpbuf_l4 0x04
-#define jmpbuf_l5 0x05
-#define jmpbuf_l6 0x06
-#define jmpbuf_l7 0x07
-
-#define jmpbuf_i0 0x08
-#define jmpbuf_i1 0x09
-#define jmpbuf_i2 0x0a
-#define jmpbuf_i3 0x0b
-#define jmpbuf_i4 0x0c
-#define jmpbuf_i5 0x0d
-
-#define jmpbuf_sp 0x0e
-#define jmpbuf_jmpret 0x0f
-#define jmpbuf_callersret 0x10
-
-#endif /* _ASM */
-
-#endif /* bits/setjmp.h */
diff --git a/libc/sysdeps/linux/nios/bits/stat.h b/libc/sysdeps/linux/nios/bits/stat.h
deleted file mode 100644
index 213dbe267..000000000
--- a/libc/sysdeps/linux/nios/bits/stat.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/* Copyright (C) 1992,95,96,97,98,99,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_STAT_H
-# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
-#endif
-
-/* Versions of the `struct stat' data structure. */
-#define _STAT_VER_LINUX_OLD 1
-#define _STAT_VER_KERNEL 1
-#define _STAT_VER_SVR4 2
-#define _STAT_VER_LINUX 3
-#define _STAT_VER _STAT_VER_LINUX /* The one defined below. */
-
-/* Versions of the `xmknod' interface. */
-#define _MKNOD_VER_LINUX 1
-#define _MKNOD_VER_SVR4 2
-#define _MKNOD_VER _MKNOD_VER_LINUX /* The bits defined below. */
-
-
-struct stat
- {
- __dev_t st_dev; /* Device. */
- unsigned short int __pad1;
-#ifndef __USE_FILE_OFFSET64
- __ino_t st_ino; /* File serial number. */
-#else
- __ino_t __st_ino; /* 32bit file serial number. */
-#endif
- __mode_t st_mode; /* File mode. */
- __nlink_t st_nlink; /* Link count. */
- __uid_t st_uid; /* User ID of the file's owner. */
- __gid_t st_gid; /* Group ID of the file's group.*/
- __dev_t st_rdev; /* Device number, if device. */
- unsigned short int __pad2;
-#ifndef __USE_FILE_OFFSET64
- __off_t st_size; /* Size of file, in bytes. */
-#else
- __off64_t st_size; /* Size of file, in bytes. */
-#endif
- __blksize_t st_blksize; /* Optimal block size for I/O. */
-
-#ifndef __USE_FILE_OFFSET64
- __blkcnt_t st_blocks; /* Number 512-byte blocks allocated. */
-#else
- __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
-#endif
- __time_t st_atime; /* Time of last access. */
- unsigned long int __unused1;
- __time_t st_mtime; /* Time of last modification. */
- unsigned long int __unused2;
- __time_t st_ctime; /* Time of last status change. */
- unsigned long int __unused3;
-#ifndef __USE_FILE_OFFSET64
- unsigned long int __unused4;
- unsigned long int __unused5;
-#else
- __ino64_t st_ino; /* File serial number. */
-#endif
- };
-
-#ifdef __USE_LARGEFILE64
-struct stat64
- {
- __dev_t st_dev; /* Device. */
- unsigned short int __pad1;
-
- __ino_t __st_ino; /* 32bit file serial number. */
- __mode_t st_mode; /* File mode. */
- __nlink_t st_nlink; /* Link count. */
- __uid_t st_uid; /* User ID of the file's owner. */
- __gid_t st_gid; /* Group ID of the file's group.*/
- __dev_t st_rdev; /* Device number, if device. */
- unsigned short int __pad2;
- __off64_t st_size; /* Size of file, in bytes. */
- __blksize_t st_blksize; /* Optimal block size for I/O. */
-
- __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
- __time_t st_atime; /* Time of last access. */
- unsigned long int __unused1;
- __time_t st_mtime; /* Time of last modification. */
- unsigned long int __unused2;
- __time_t st_ctime; /* Time of last status change. */
- unsigned long int __unused3;
- __ino64_t st_ino; /* File serial number. */
- };
-#endif
-
-/* Tell code we have these members. */
-#define _STATBUF_ST_BLKSIZE
-#define _STATBUF_ST_RDEV
-
-/* Encoding of the file mode. */
-
-#define __S_IFMT 0170000 /* These bits determine file type. */
-
-/* File types. */
-#define __S_IFDIR 0040000 /* Directory. */
-#define __S_IFCHR 0020000 /* Character device. */
-#define __S_IFBLK 0060000 /* Block device. */
-#define __S_IFREG 0100000 /* Regular file. */
-#define __S_IFIFO 0010000 /* FIFO. */
-#define __S_IFLNK 0120000 /* Symbolic link. */
-#define __S_IFSOCK 0140000 /* Socket. */
-
-/* POSIX.1b objects. Note that these macros always evaluate to zero. But
- they do it by enforcing the correct use of the macros. */
-#define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode)
-#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
-#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
-
-/* Protection bits. */
-
-#define __S_ISUID 04000 /* Set user ID on execution. */
-#define __S_ISGID 02000 /* Set group ID on execution. */
-#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
-#define __S_IREAD 0400 /* Read by owner. */
-#define __S_IWRITE 0200 /* Write by owner. */
-#define __S_IEXEC 0100 /* Execute by owner. */
diff --git a/libc/sysdeps/linux/nios/bits/syscalls.h b/libc/sysdeps/linux/nios/bits/syscalls.h
deleted file mode 100644
index c2b6b9735..000000000
--- a/libc/sysdeps/linux/nios/bits/syscalls.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef _BITS_SYSCALLS_H
-#define _BITS_SYSCALLS_H
-#ifndef _SYSCALL_H
-# error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
-#endif
-
-#include <features.h>
-/* Do something very evil for now. Until we include our out syscall
- * macros, short circuit bits/syscall.h and use asm/unistd.h instead */
-#include <asm/unistd.h>
-
-#endif /* _BITS_SYSCALLS_H */
-
diff --git a/libc/sysdeps/linux/nios/bsd-_setjmp.S b/libc/sysdeps/linux/nios/bsd-_setjmp.S
deleted file mode 100644
index f2f0f2396..000000000
--- a/libc/sysdeps/linux/nios/bsd-_setjmp.S
+++ /dev/null
@@ -1 +0,0 @@
-/* _setjmp in setjmp.S */ \ No newline at end of file
diff --git a/libc/sysdeps/linux/nios/bsd-setjmp.S b/libc/sysdeps/linux/nios/bsd-setjmp.S
deleted file mode 100644
index 36f2bab1c..000000000
--- a/libc/sysdeps/linux/nios/bsd-setjmp.S
+++ /dev/null
@@ -1 +0,0 @@
-/* setjmp in setjmp.S */ \ No newline at end of file
diff --git a/libc/sysdeps/linux/nios/clone.S b/libc/sysdeps/linux/nios/clone.S
deleted file mode 100644
index 39eb54035..000000000
--- a/libc/sysdeps/linux/nios/clone.S
+++ /dev/null
@@ -1,88 +0,0 @@
-/* Copyright (C) 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Richard Henderson (rth@tamu.edu).
-
- 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. */
-
-/* clone() is even more special than fork() as it mucks with stacks
- and invokes a function in the right context after its all over. */
-
-#include <asm/errno.h>
-#include <sys/syscall.h>
-#include "NM_Macros.S"
-
-/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */
-
- .text
- .align 2
- .globl clone
- .type clone,@function
-
-clone:
- save %sp,-16
-
- MOVIP %l0, -EINVAL
- /* sanity check arguments */
- skprnz %i0 /* no NULL function pointers */
- br CLONE_ERROR_LABEL
- mov %o0, %i2
-
- skprnz %i1 /* no NULL stack pointers */
- br CLONE_ERROR_LABEL
- mov %o1, %i1
-
- /* Do the system call */
- MOVIP %g1, __NR_clone
- trap 63
-
- /* if ret >=0? */
- cmpi %o0, 0
- skps cc_pl
- br CLONE_ERROR_LABEL
- mov %l0, %o0
-
- /* Start thread */
- skprz %o1
- br __thread_start
- nop
- mov %i0, %o0
- ret
- restore
-
-CLONE_ERROR_LABEL:
- neg %l0
- MOVIA %g1, __errno_location@h
- call %g1
- nop
- st [%o0], %l0 /* store errno */
-
- xor %i0, %i0
- dec %i0 /* retval=-1 */
- ret
- restore
-
- .size clone, .-clone
-
- .type __thread_start,@function
-
-__thread_start:
- call %i0
- mov %o0, %i3
- MOVIA %g1, _exit@h
- call %g1
- nop
-
- .size __thread_start, .-__thread_start
diff --git a/libc/sysdeps/linux/nios/crt1.S b/libc/sysdeps/linux/nios/crt1.S
deleted file mode 100644
index 98777e831..000000000
--- a/libc/sysdeps/linux/nios/crt1.S
+++ /dev/null
@@ -1,59 +0,0 @@
-/* Copyright (C) 1991, 1992 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., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
-
-#include <features.h>
-#include <asm/unistd.h>
-#include "NM_Macros.S"
-#define __ASSEMBLY__
-#include <asm/ptrace.h> /* for REGWIN_SZ */
-
- .global _start
- .type __start,@function
- .weak _init
- .weak _fini
- .type main,@function
- .type __uClibc_main,@function
- .type __h_errno_location, @function
- .type _stdio_init, @function
- .type _stdio_term, @function
-
- .text
-
-_start:
- nop
- nop
-
- MOVIA %o0, main@h
- lds %o1,[%sp, (REGWIN_SZ / 4) + 0] // main's argc
- lds %o2,[%sp, (REGWIN_SZ / 4) + 1] // main's argv
-
- MOVIA %o3, _init@h
- MOVIA %o4, _fini@h
- mov %o5, %i0 /* rtld_fini */
- mov %o6, %sp /* stack_end */
- MOVIA %o7, __uClibc_main@h
-
- call %o7
- nop
-
-
- /* If that didn't kill us, ... */
-__exit:
- MOVIP %g1, __NR_exit
- trap 63
diff --git a/libc/sysdeps/linux/nios/crtbegin.c b/libc/sysdeps/linux/nios/crtbegin.c
deleted file mode 100644
index ac3f23f84..000000000
--- a/libc/sysdeps/linux/nios/crtbegin.c
+++ /dev/null
@@ -1,37 +0,0 @@
-#include <errno.h>
-#include <stdlib.h>
-/*
-static void (*__CTOR_LIST__[1]) __P((void))
- __attribute__((__unused__))
- __attribute__((section(".ctors"))) = { (void *)0 };
-
-static void (*__DTOR_LIST__[1]) __P((void))
- __attribute__((section(".dtors"))) = { (void *)-1 };
-*/
-extern void (*__DTOR_LIST__[]) __P((void));
-static void __do_global_dtors_aux __P((void));
-
-static void
-__do_global_dtors_aux()
-{
- void (**p)(void) = __DTOR_LIST__ + 1;
-
- while (*p)
- (**p++)();
-}
-
-static void dummy_fini(void) __attribute__((section(".trash")));
-
-void
-dummy_fini(void)
-{
- static void (* volatile call__dtors)(void) = __do_global_dtors_aux;
- /*
- * Call global destructors.
- */
- /* prevent function pointer constant propagation */
- __asm__ __volatile__ (".section .fini");
- (*call__dtors)();
- __asm__ __volatile__ (".section .trash");
-
-}
diff --git a/libc/sysdeps/linux/nios/crtend.c b/libc/sysdeps/linux/nios/crtend.c
deleted file mode 100644
index 775eb0f9d..000000000
--- a/libc/sysdeps/linux/nios/crtend.c
+++ /dev/null
@@ -1,44 +0,0 @@
-#include <errno.h>
-#include <stdlib.h>
-#include <unistd.h>
-/*
-static void (*__CTOR_END__[1]) __P((void))
- __attribute__((section(".ctors"))) = { (void *)-1 };
-
-static void (*__DTOR_END__[1]) __P((void))
- __attribute__((__unused__))
- __attribute__((section(".dtors"))) = { (void *)0 };
-*/
-extern void (*__CTOR_END__[]) __P((void));
-static void __do_global_ctors_aux __P((void));
-
-static void
-__do_global_ctors_aux()
-{
- void (**p)(void) = __CTOR_END__ - 1;
-
- while (*p)
- (**p--)();
-}
-
-static void dummy_init(void) __attribute__((section(".trash")));
-
-void
-dummy_init(void)
-{
- static smallint initialized;
- static void (*volatile call__ctors)(void) = __do_global_ctors_aux;
- /*
- * Call global constructors.
- * Arrange to call global destructors at exit.
- */
- /* prevent function pointer constant propagation */
- __asm__ __volatile__ (".section .init");
-
- if (!initialized) {
- initialized = 1;
- (*call__ctors)();
- }
- __asm__ __volatile__ (".section .trash");
-
-} \ No newline at end of file
diff --git a/libc/sysdeps/linux/nios/fpu_control.h b/libc/sysdeps/linux/nios/fpu_control.h
deleted file mode 100644
index 9c3174574..000000000
--- a/libc/sysdeps/linux/nios/fpu_control.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* FPU control word bits. Nios2 version.
- Copyright (C) 1996, 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. */
-
-#ifndef _FPU_CONTROL_H
-#define _FPU_CONTROL_H
-
-/* MIPS FPU floating point control register bits.
- *
- * 31-25 -> floating point conditions code bits 7-1. These bits are only
- * available in MIPS IV.
- * 24 -> flush denormalized results to zero instead of
- * causing unimplemented operation exception. This bit is only
- * available for MIPS III and newer.
- * 23 -> Condition bit
- * 22-18 -> reserved (read as 0, write with 0)
- * 17 -> cause bit for unimplemented operation
- * 16 -> cause bit for invalid exception
- * 15 -> cause bit for division by zero exception
- * 14 -> cause bit for overflow exception
- * 13 -> cause bit for underflow exception
- * 12 -> cause bit for inexact exception
- * 11 -> enable exception for invalid exception
- * 10 -> enable exception for division by zero exception
- * 9 -> enable exception for overflow exception
- * 8 -> enable exception for underflow exception
- * 7 -> enable exception for inexact exception
- * 6 -> flag invalid exception
- * 5 -> flag division by zero exception
- * 4 -> flag overflow exception
- * 3 -> flag underflow exception
- * 2 -> flag inexact exception
- * 1-0 -> rounding control
- *
- *
- * Rounding Control:
- * 00 - rounding to nearest (RN)
- * 01 - rounding toward zero (RZ)
- * 10 - rounding (up) toward plus infinity (RP)
- * 11 - rounding (down)toward minus infinity (RM)
- */
-
-#include <features.h>
-
-/* masking of interrupts */
-#define _FPU_MASK_V 0x0800 /* Invalid operation */
-#define _FPU_MASK_Z 0x0400 /* Division by zero */
-#define _FPU_MASK_O 0x0200 /* Overflow */
-#define _FPU_MASK_U 0x0100 /* Underflow */
-#define _FPU_MASK_I 0x0080 /* Inexact operation */
-
-/* flush denormalized numbers to zero */
-#define _FPU_FLUSH_TZ 0x1000000
-
-/* rounding control */
-#define _FPU_RC_NEAREST 0x0 /* RECOMMENDED */
-#define _FPU_RC_ZERO 0x1
-#define _FPU_RC_UP 0x2
-#define _FPU_RC_DOWN 0x3
-
-#define _FPU_RESERVED 0xfe3c0000 /* Reserved bits in cw */
-
-
-/* The fdlibm code requires strict IEEE double precision arithmetic,
- and no interrupts for exceptions, rounding to nearest. */
-
-#define _FPU_DEFAULT 0x00000000
-
-/* IEEE: same as above, but exceptions */
-#define _FPU_IEEE 0x00000F80
-
-/* Type of the control word. */
-typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__SI__)));
-
-/* Macros for accessing the hardware control word. */
-#define _FPU_GETCW(cw) __asm__ ("cfc1 %0,$31" : "=r" (cw))
-#define _FPU_SETCW(cw) __asm__ ("ctc1 %0,$31" : : "r" (cw))
-
-#if 0
-/* Default control word set at startup. */
-extern fpu_control_t __fpu_control;
-#endif
-
-#endif /* fpu_control.h */
diff --git a/libc/sysdeps/linux/nios/setjmp.S b/libc/sysdeps/linux/nios/setjmp.S
deleted file mode 100644
index c2851461c..000000000
--- a/libc/sysdeps/linux/nios/setjmp.S
+++ /dev/null
@@ -1,102 +0,0 @@
-/* Copyright (C) 1997, 1998 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. */
-
-#include <features.h>
-#define _ASM
-#define _SETJMP_H
-#include <bits/setjmp.h>
-#include "NM_Macros.S"
-
-;----------------------------------------
-; Name: __sigsetjmp
-; Description: Save the current context so
-; a nr_longjmp works later.
-; Input: %o0: jmp_buf: (ptr to) array to store context in
-; Output: %o0 = 0 the first time we're called, or
-; whatever longjmp returns later
-; Side Effects: Uses %g0
-; CWP Depth: 0
-;
-
- .align 2
- .global _setjmp
-
-_setjmp:
- br __sigsetjmp
- movi %o1,0 ; (Delay slot) Set signal mask to zero
-
- .align 2
- .global setjmp
-
-setjmp:
- MOVIP %o1,1 ; Set signal mask to 1 to save mask
-
- .align 2
- .global __sigsetjmp
-
-__sigsetjmp:
- pfx jmpbuf_callersret ; present return address
- st [%o0],%i7
- pfx jmpbuf_jmpret ; where the longjmp will later execute from
- st [%o0],%o7
- pfx jmpbuf_sp ; Save stack pointer
- st [%o0],%o6
- pfx jmpbuf_l0 ; Save local register l0
- st [%o0],%l0
- pfx jmpbuf_l1 ; Save local register l1
- st [%o0],%l1
- pfx jmpbuf_l2 ; Save local register l2
- st [%o0],%l2
- pfx jmpbuf_l3 ; Save local register l3
- st [%o0],%l3
- pfx jmpbuf_l4 ; Save local register l4
- st [%o0],%l4
- pfx jmpbuf_l5 ; Save local register l5
- st [%o0],%l5
- pfx jmpbuf_l6 ; Save local register l6
- st [%o0],%l6
- pfx jmpbuf_l7 ; Save local register l7
- st [%o0],%l7
- pfx jmpbuf_i0 ; Save input register i0
- st [%o0],%i0
- pfx jmpbuf_i1 ; Save input register i1
- st [%o0],%i1
- pfx jmpbuf_i2 ; Save input register i2
- st [%o0],%i2
- pfx jmpbuf_i3 ; Save input register i3
- st [%o0],%i3
- pfx jmpbuf_i4 ; Save input register i4
- st [%o0],%i4
- pfx jmpbuf_i5 ; Save input register i5
- st [%o0],%i5
- pfx %hi(__sigjmp_save@h) ; Load up %g0 with address
- movi %g0,%lo(__sigjmp_save@h)
- pfx %xhi(__sigjmp_save@h)
- movhi %g0,%xlo(__sigjmp_save@h)
- jmp %g0
- nop ; (delay slot)
-
-
-
-
-
-
-
-
-
-
diff --git a/libc/sysdeps/linux/nios/sys/ucontext.h b/libc/sysdeps/linux/nios/sys/ucontext.h
deleted file mode 100644
index 1805b4eac..000000000
--- a/libc/sysdeps/linux/nios/sys/ucontext.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/* Copyright (C) 1998, 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. */
-
-#ifndef _SYS_UCONTEXT_H
-#define _SYS_UCONTEXT_H 1
-
-#include <features.h>
-#include <signal.h>
-/*
- * Location of the users' stored registers relative to R0.
- * Usage is as an index into a gregset_t array or as u.u_ar0[XX].
- */
-#define REG_PSR (0)
-#define REG_PC (1)
-#define REG_SPARE (2)
-#define REG_WVALID (3)
-#define REG_G1 (4)
-#define REG_G2 (5)
-#define REG_G3 (6)
-#define REG_G4 (7)
-#define REG_G5 (8)
-#define REG_G6 (9)
-#define REG_G7 (10)
-#define REG_O0 (11)
-#define REG_O1 (12)
-#define REG_O2 (13)
-#define REG_O3 (14)
-#define REG_O4 (15)
-#define REG_O5 (16)
-#define REG_O6 (17)
-#define REG_O7 (18)
-#define REG_GLOBALS (19)
-
-/*
- * A gregset_t is defined as an array type for compatibility with the reference
- * source. This is important due to differences in the way the C language
- * treats arrays and structures as parameters.
- *
- * Note that NGREG is really (sizeof (struct regs) / sizeof (greg_t)),
- * but that the ABI defines it absolutely to be 21 (resp. 19).
- */
-
-#define NGREG 20
-typedef int greg_t;
-
-typedef greg_t gregset_t[NGREG];
-
-/*
- * The following structures define how a register window can appear on the
- * stack. This structure is available (when required) through the `gwins'
- * field of an mcontext (nested within ucontext). NIOS_MAXWINDOW is the
- * maximum number of outstanding register windows defined in the NIOS
- * architecture (*not* implementation).
- */
-#define NIOS_MAXREGWINDOW 31 /* max windows in NIOS arch. */
-struct rwindow
- {
- greg_t rw_local[8]; /* locals */
- greg_t rw_in[8]; /* ins */
- };
-
-#define rw_fp rw_in[6] /* frame pointer */
-#define rw_rtn rw_in[7] /* return address */
-
-typedef struct gwindows
- {
- int wbcnt;
- int *spbuf[NIOS_MAXREGWINDOW];
- struct rwindow wbuf[NIOS_MAXREGWINDOW];
- } gwindows_t;
-
-typedef struct
- {
- gregset_t gregs; /* general register set */
- gwindows_t *gwins; /* POSSIBLE pointer to register windows */
- } mcontext_t;
-
-
-/* Userlevel context. */
-typedef struct ucontext
- {
- unsigned long uc_flags;
- struct ucontext *uc_link;
- __sigset_t uc_sigmask;
- stack_t uc_stack;
- mcontext_t uc_mcontext;
- } ucontext_t;
-
-#endif /* sys/ucontext.h */
diff --git a/libc/sysdeps/linux/nios/vfork.S b/libc/sysdeps/linux/nios/vfork.S
deleted file mode 100644
index f8a6d031c..000000000
--- a/libc/sysdeps/linux/nios/vfork.S
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * libc/sysdeps/linux/nios/vfork.S -- `vfork' syscall for linux/nios
- *
- * Copyright (C) 2004 Microtronix Datacom Ltd
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- *
- * Written by Wentao Xu <wentao@microtronix.com>
- */
-
-#include <features.h>
-
-#include <bits/errno.h>
-#include <sys/syscall.h>
-#include "NM_Macros.S"
-
-#ifndef __NR_vfork
-#define __NR_vfork __NR_fork /* uClinux-2.0 only has fork which is vfork */
-#endif
-
- .text
- .align 2
- .globl __vfork
- .hidden __vfork
- .type __vfork,@function
-__vfork:
- MOVIP %g1, __NR_vfork
- trap 63
-
- bgen %g1, 12
- not %g1 /* (unsigned long) -4096 */
- cmp %o0, %g1
- skps cc_hi
- jmp %o7
- nop
-
-fix_errno:
- neg %o0
- save %sp, -16
- MOVIA %g1, __errno_location@h
- call %g1
- nop
- st [%o0], %i0 /* store errno */
-
- xor %i0, %i0
- subi %i0, 1 /* retval=-1 */
- ret
- restore
-
-.size __vfork,.-__vfork
-weak_alias(__vfork,vfork)
-libc_hidden_weak(vfork)
diff --git a/libc/sysdeps/linux/nios2/Makefile.arch b/libc/sysdeps/linux/nios2/Makefile.arch
index fadde953e..e36e06b52 100644
--- a/libc/sysdeps/linux/nios2/Makefile.arch
+++ b/libc/sysdeps/linux/nios2/Makefile.arch
@@ -5,10 +5,8 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-CSRC := brk.c syscall.c
+CSRC-y := brk.c syscall.c
-SSRC := \
+SSRC-y := \
__longjmp.S bsd-_setjmp.S bsd-setjmp.S setjmp.S \
vfork.S clone.S
-
-include $(top_srcdir)libc/sysdeps/linux/Makefile.commonarch
diff --git a/libc/sysdeps/linux/nios2/__longjmp.S b/libc/sysdeps/linux/nios2/__longjmp.S
index 4b6508e5d..7df599768 100644
--- a/libc/sysdeps/linux/nios2/__longjmp.S
+++ b/libc/sysdeps/linux/nios2/__longjmp.S
@@ -12,9 +12,7 @@
*/
#include <features.h>
-#define _ASM
-#define _SETJMP_H
-#include <bits/setjmp.h>
+#include <jmpbuf-offsets.h>
.globl __longjmp
.type __longjmp,@function
@@ -39,7 +37,7 @@ __longjmp:
ldw gp, JB_GP(r4)
ldw sp, JB_SP(r4)
-#if defined(__HAVE_FPU__)
+#ifdef __UCLIBC_HAS_FPU__
RESTORE_FPU r4 JB_FPREGS
#endif
diff --git a/libc/sysdeps/linux/nios2/bits/endian.h b/libc/sysdeps/linux/nios2/bits/endian.h
index 54bd9d14b..de60addbc 100644
--- a/libc/sysdeps/linux/nios2/bits/endian.h
+++ b/libc/sysdeps/linux/nios2/bits/endian.h
@@ -1,4 +1,4 @@
-/* i386 is little-endian. */
+/* Nios II is little-endian. */
#ifndef _ENDIAN_H
# error "Never use <bits/endian.h> directly; include <endian.h> instead."
diff --git a/libc/sysdeps/linux/nios2/bits/fcntl.h b/libc/sysdeps/linux/nios2/bits/fcntl.h
index 7e32a04e9..d8386d65c 100644
--- a/libc/sysdeps/linux/nios2/bits/fcntl.h
+++ b/libc/sysdeps/linux/nios2/bits/fcntl.h
@@ -1,5 +1,5 @@
/* O_*, F_*, FD_* bit values for Linux.
- Copyright (C) 2000 Free Software Foundation, Inc.
+ Copyright (C) 2000, 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
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FCNTL_H
# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
@@ -48,7 +47,9 @@
# define O_DIRECTORY 040000 /* Must be a directory. */
# define O_NOFOLLOW 0100000 /* Do not follow links. */
# define O_DIRECT 0200000 /* Direct disk access. */
-# define O_STREAMING 04000000/* streaming access */
+# define O_NOATIME 01000000 /* Do not set atime. */
+# define O_CLOEXEC 02000000 /* set close_on_exec */
+# define O_PATH 010000000 /* Resolve pathname but do not open file. */
#endif
/* For now Linux has synchronisity options for data and read operations.
@@ -82,7 +83,7 @@
#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
+#if defined __USE_BSD || defined __USE_UNIX98
# define F_SETOWN 8 /* Get owner of socket (receiver of SIGIO). */
# define F_GETOWN 9 /* Set owner of socket (receiver of SIGIO). */
#endif
@@ -98,6 +99,8 @@
# define F_NOTIFY 1026 /* Request notfications on a directory. */
# define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with
close-on-exit set on new fd. */
+# define F_SETPIPE_SZ 1031 /* Set pipe page size array. */
+# define F_GETPIPE_SZ 1032 /* Get pipe page size array. */
#endif
/* For F_[GET|SET]FL. */
@@ -185,7 +188,7 @@ struct flock64
#endif
-#ifdef __USE_GNU
+#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
@@ -208,7 +211,7 @@ struct flock64
__BEGIN_DECLS
-#ifdef __USE_GNU
+#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)
diff --git a/libc/sysdeps/linux/nios2/bits/kernel_stat.h b/libc/sysdeps/linux/nios2/bits/kernel_stat.h
index 9be9d115d..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... */
@@ -22,12 +18,9 @@ struct kernel_stat {
unsigned long st_size;
unsigned long st_blksize;
unsigned long st_blocks;
- unsigned long st_atime;
- unsigned long __unused1;
- unsigned long st_mtime;
- unsigned long __unused2;
- unsigned long st_ctime;
- unsigned long __unused3;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
unsigned long __unused4;
unsigned long __unused5;
};
@@ -47,12 +40,9 @@ struct kernel_stat64 {
unsigned long st_blksize;
unsigned long st_blocks; /* Number 512-byte blocks allocated. */
unsigned long __pad4; /* future possible st_blocks high bits */
- unsigned long st_atime;
- unsigned long __pad5;
- unsigned long st_mtime;
- unsigned long __pad6;
- unsigned long st_ctime;
- unsigned long __pad7; /* will be high 32 bits of ctime someday */
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
unsigned long long st_ino;
};
diff --git a/libc/sysdeps/linux/nios2/bits/kernel_types.h b/libc/sysdeps/linux/nios2/bits/kernel_types.h
index 3fcd1af05..004f9c746 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_GENERIC_POSIX_TYPES_H
+#define __ASM_GENERIC_POSIX_TYPES_H
typedef unsigned long __kernel_dev_t;
typedef unsigned long __kernel_ino_t;
@@ -14,8 +14,8 @@ typedef unsigned short __kernel_nlink_t;
typedef long __kernel_off_t;
typedef int __kernel_pid_t;
typedef unsigned short __kernel_ipc_pid_t;
-typedef unsigned short __kernel_uid_t;
-typedef unsigned short __kernel_gid_t;
+typedef unsigned int __kernel_uid_t;
+typedef unsigned int __kernel_gid_t;
typedef unsigned int __kernel_size_t;
typedef int __kernel_ssize_t;
typedef int __kernel_ptrdiff_t;
@@ -28,9 +28,11 @@ typedef unsigned short __kernel_uid16_t;
typedef unsigned short __kernel_gid16_t;
typedef unsigned int __kernel_uid32_t;
typedef unsigned int __kernel_gid32_t;
-typedef unsigned short __kernel_old_uid_t;
-typedef unsigned short __kernel_old_gid_t;
-typedef unsigned short __kernel_old_dev_t;
+typedef unsigned int __kernel_old_uid_t;
+typedef unsigned int __kernel_old_gid_t;
+typedef unsigned int __kernel_old_dev_t;
+typedef long __kernel_long_t;
+typedef unsigned long __kernel_ulong_t;
typedef long long __kernel_loff_t;
typedef struct {
@@ -41,4 +43,4 @@ typedef struct {
#endif
} __kernel_fsid_t;
-#endif /* __ARCH_NIOS2_POSIX_TYPES_H */
+#endif /* __ASM_GENERIC_POSIX_TYPES_H */
diff --git a/libc/sysdeps/linux/nios2/bits/mathdef.h b/libc/sysdeps/linux/nios2/bits/mathdef.h
index e013e74b7..478ceed15 100644
--- a/libc/sysdeps/linux/nios2/bits/mathdef.h
+++ b/libc/sysdeps/linux/nios2/bits/mathdef.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#if !defined _MATH_H && !defined _COMPLEX_H
# error "Never use <bits/mathdef.h> directly; include <math.h> instead"
diff --git a/libc/sysdeps/linux/nios2/bits/mman.h b/libc/sysdeps/linux/nios2/bits/mman.h
deleted file mode 100644
index 2fa35e663..000000000
--- a/libc/sysdeps/linux/nios2/bits/mman.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* Definitions for POSIX memory map interface. Linux/m68k version.
- Copyright (C) 1997 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_MMAN_H
-# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
-#endif
-
-/* The following definitions basically come from the kernel headers.
- But the kernel header is not namespace clean. */
-
-
-/* Protections are chosen from these bits, OR'd together. The
- implementation does not necessarily support PROT_EXEC or PROT_WRITE
- without PROT_READ. The only guarantees are that no writing will be
- allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
-
-#define PROT_READ 0x1 /* Page can be read. */
-#define PROT_WRITE 0x2 /* Page can be written. */
-#define PROT_EXEC 0x4 /* Page can be executed. */
-#define PROT_NONE 0x0 /* Page can not be accessed. */
-
-/* Sharing types (must choose one and only one of these). */
-#define MAP_SHARED 0x01 /* Share changes. */
-#define MAP_PRIVATE 0x02 /* Changes are private. */
-#ifdef __USE_MISC
-# define MAP_TYPE 0x0f /* Mask for type of mapping. */
-#endif
-
-/* Other flags. */
-#define MAP_FIXED 0x10 /* Interpret addr exactly. */
-#ifdef __USE_MISC
-# define MAP_FILE 0
-# define MAP_ANONYMOUS 0x20 /* Don't use a file. */
-# define MAP_ANON MAP_ANONYMOUS
-#endif
-
-/* These are Linux-specific. */
-#ifdef __USE_MISC
-# define MAP_GROWSDOWN 0x0100 /* Stack-like segment. */
-# define MAP_DENYWRITE 0x0800 /* ETXTBSY */
-# define MAP_EXECUTABLE 0x1000 /* Mark it as an executable. */
-# define MAP_LOCKED 0x2000 /* Lock the mapping. */
-# define MAP_NORESERVE 0x4000 /* Don't check for reservations. */
-#endif
-
-/* Advice to `madvise'. */
-#ifdef __USE_BSD
-# define MADV_NORMAL 0 /* No further special treatment. */
-# define MADV_RANDOM 1 /* Expect random page references. */
-# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
-# define MADV_WILLNEED 3 /* Will need these pages. */
-# define MADV_DONTNEED 4 /* Don't need these pages. */
-#endif
-
-/* Flags to `msync'. */
-#define MS_ASYNC 1 /* Sync memory asynchronously. */
-#define MS_SYNC 4 /* Synchronous memory sync. */
-#define MS_INVALIDATE 2 /* Invalidate the caches. */
-
-/* Flags for `mlockall'. */
-#define MCL_CURRENT 1 /* Lock all currently mapped pages. */
-#define MCL_FUTURE 2 /* Lock all additions to address
- space. */
-
-/* Flags for `mremap'. */
-#ifdef __USE_GNU
-# define MREMAP_MAYMOVE 1
-# define MREMAP_FIXED 2
-#endif
diff --git a/libc/sysdeps/linux/nios2/bits/setjmp.h b/libc/sysdeps/linux/nios2/bits/setjmp.h
index fcff0316d..bc6f30848 100644
--- a/libc/sysdeps/linux/nios2/bits/setjmp.h
+++ b/libc/sysdeps/linux/nios2/bits/setjmp.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _BITS_SETJMP_H
#define _BITS_SETJMP_H 1
@@ -24,7 +23,6 @@
# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
#endif
-#ifndef _ASM
typedef struct
{
/* Callee-saved registers r16 through r23. */
@@ -43,30 +41,9 @@ typedef struct
unsigned long __gp;
/* floating point regs, if any */
-#if defined __HAVE_FPU__
+#ifdef __UCLIBC_HAS_FPU__
unsigned long __fpregs[64];
#endif
} __jmp_buf[1];
-#endif
-
-#define JB_REGS 0
-#define JB_PC 32
-#define JB_SP 36
-#define JB_FP 40
-#define JB_GP 44
-#define JB_FPREGS 48
-
-#if defined __HAVE_FPU__
-# define JB_SIZE 304
-#else
-# define JB_SIZE 48
-#endif
-
-
-/* Test if longjmp to JMPBUF would unwind the frame
- containing a local variable at ADDRESS. */
-#define _JMPBUF_UNWINDS(jmpbuf, address) \
- ((void *) (address) < (void*)(jmpbuf)->__sp)
-
#endif /* bits/setjmp.h */
diff --git a/libc/sysdeps/linux/nios2/bits/sigcontextinfo.h b/libc/sysdeps/linux/nios2/bits/sigcontextinfo.h
index d6383b970..7908e63f0 100644
--- a/libc/sysdeps/linux/nios2/bits/sigcontextinfo.h
+++ b/libc/sysdeps/linux/nios2/bits/sigcontextinfo.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#define SIGCONTEXT struct sigcontext *
#define SIGCONTEXT_EXTRA_ARGS
diff --git a/libc/sysdeps/linux/nios2/bits/stackinfo.h b/libc/sysdeps/linux/nios2/bits/stackinfo.h
index e7fbf5633..0d4eeb8a4 100644
--- a/libc/sysdeps/linux/nios2/bits/stackinfo.h
+++ b/libc/sysdeps/linux/nios2/bits/stackinfo.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* This file contains a bit of information about the stack allocation
of the processor. */
diff --git a/libc/sysdeps/linux/nios2/bits/stat.h b/libc/sysdeps/linux/nios2/bits/stat.h
index f446a91db..6e3b0198c 100644
--- a/libc/sysdeps/linux/nios2/bits/stat.h
+++ b/libc/sysdeps/linux/nios2/bits/stat.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_STAT_H
# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
@@ -60,12 +59,27 @@ struct stat
#else
__blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
#endif
+#ifdef __USE_MISC
+ /* Nanosecond resolution timestamps are stored in a format
+ equivalent to 'struct timespec'. This is the type used
+ whenever possible but the Unix namespace rules do not allow the
+ identifier 'timespec' to appear in the <sys/stat.h> header.
+ Therefore we have to handle the use of this header in strictly
+ standard-compliant sources special. */
+ struct timespec st_atim; /* Time of last access. */
+ struct timespec st_mtim; /* Time of last modification. */
+ struct timespec st_ctim; /* Time of last status change. */
+# define st_atime st_atim.tv_sec /* Backward compatibility. */
+# define st_mtime st_mtim.tv_sec
+# define st_ctime st_ctim.tv_sec
+#else
__time_t st_atime; /* Time of last access. */
- unsigned long int __unused1;
+ unsigned long int st_atimensec; /* Nscecs of last access. */
__time_t st_mtime; /* Time of last modification. */
- unsigned long int __unused2;
+ unsigned long int st_mtimensec; /* Nsecs of last modification. */
__time_t st_ctime; /* Time of last status change. */
- unsigned long int __unused3;
+ unsigned long int st_ctimensec; /* Nsecs of last status change. */
+#endif
#ifndef __USE_FILE_OFFSET64
unsigned long int __unused4;
unsigned long int __unused5;
@@ -91,12 +105,24 @@ struct stat64
__blksize_t st_blksize; /* Optimal block size for I/O. */
__blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
+#ifdef __USE_MISC
+ /* Nanosecond resolution timestamps are stored in a format
+ equivalent to 'struct timespec'. This is the type used
+ whenever possible but the Unix namespace rules do not allow the
+ identifier 'timespec' to appear in the <sys/stat.h> header.
+ Therefore we have to handle the use of this header in strictly
+ standard-compliant sources special. */
+ struct timespec st_atim; /* Time of last access. */
+ struct timespec st_mtim; /* Time of last modification. */
+ struct timespec st_ctim; /* Time of last status change. */
+#else
__time_t st_atime; /* Time of last access. */
- unsigned long int __unused1;
+ unsigned long int st_atimensec; /* Nscecs of last access. */
__time_t st_mtime; /* Time of last modification. */
- unsigned long int __unused2;
+ unsigned long int st_mtimensec; /* Nsecs of last modification. */
__time_t st_ctime; /* Time of last status change. */
- unsigned long int __unused3;
+ unsigned long int st_ctimensec; /* Nsecs of last status change. */
+#endif
__ino64_t st_ino; /* File serial number. */
};
#endif
@@ -104,6 +130,8 @@ struct stat64
/* Tell code we have these members. */
#define _STATBUF_ST_BLKSIZE
#define _STATBUF_ST_RDEV
+/* Nanosecond resolution time values are supported. */
+#define _STATBUF_ST_NSEC
/* Encoding of the file mode. */
@@ -132,3 +160,8 @@ struct stat64
#define __S_IREAD 0400 /* Read by owner. */
#define __S_IWRITE 0200 /* Write by owner. */
#define __S_IEXEC 0100 /* Execute by owner. */
+
+#ifdef __USE_ATFILE
+# define UTIME_NOW ((1l << 30) - 1l)
+# define UTIME_OMIT ((1l << 30) - 2l)
+#endif
diff --git a/libc/sysdeps/linux/nios2/bits/syscalls.h b/libc/sysdeps/linux/nios2/bits/syscalls.h
index ec5370712..5be5d4d86 100644
--- a/libc/sysdeps/linux/nios2/bits/syscalls.h
+++ b/libc/sysdeps/linux/nios2/bits/syscalls.h
@@ -4,292 +4,106 @@
# error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
#endif
+#define TRAP_ID_SYSCALL 0
+
#ifndef __ASSEMBLER__
#include <errno.h>
-#include <asm/traps.h>
-#define __syscall_return(type, res) \
-do { \
- if ((unsigned long)(res) >= (unsigned long)(-125)) { \
- \
- /* avoid using res which is declared to be in \
- register r2; errno might expand to a function \
- call and clobber it. */ \
- \
- int __err = -(res); \
- errno = __err; \
- res = -1; \
- } \
- return (type) (res); \
-} while (0)
+#define __syscall_return(type, res) \
+ do { \
+ if (unlikely(INTERNAL_SYSCALL_ERROR_P(res, ))) { \
+ __set_errno(INTERNAL_SYSCALL_ERRNO(res, )); \
+ res = (unsigned long) -1; \
+ } \
+ return (type) (res); \
+ } while (0)
+
+#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+(__extension__ \
+ ({ \
+ long __res; \
+ __asm__ __volatile__ ( \
+ "movi r2, %2\n\t" /* TRAP_ID_SYSCALL */ \
+ "movi r3, %1\n\t" /* __NR_##name */ \
+ ASM_ARGS_##nr \
+ "trap\n\t" \
+ "mov %0, r2\n\t" /* syscall return */ \
+ : "=r" (__res) /* %0 */ \
+ : "i" (name) /* %1 */ \
+ , "i" (TRAP_ID_SYSCALL) /* %2 */ \
+ MAP_ARGS_##nr (args) /* %3-%8 */ \
+ : "r2" \
+ , "r3" \
+ CLOB_ARGS_##nr /* Clobbered */ \
+ ); \
+ __res; \
+ }) \
+)
-#define _syscall0(type,name) \
-type name(void) \
-{ \
- long __res; \
- \
- __asm__ __volatile__ ( \
- \
- " \n\t" \
- \
- " movi r2, %2\n\t" /* TRAP_ID_SYSCALL */ \
- " movi r3, %1\n\t" /* __NR_##name */ \
- \
- " trap\n\t" \
- " mov %0, r2\n\t" /* syscall rtn */ \
- \
- " \n\t" \
- \
- : "=r" (__res) /* %0 */ \
- \
- : "i" (__NR_##name) /* %1 */ \
- , "i" (TRAP_ID_SYSCALL) /* %2 */ \
- \
- : "r2" /* Clobbered */ \
- , "r3" /* Clobbered */ \
- ); \
- \
-__syscall_return(type,__res); \
-}
+#define INTERNAL_SYSCALL_ERROR_P(val, err) \
+ ((unsigned long)(val) >= (unsigned long)(-125))
-#define _syscall1(type,name,atype,a) \
-type name(atype a) \
-{ \
- long __res; \
- \
- __asm__ __volatile__ ( \
- \
- " \n\t" \
- \
- " movi r2, %2\n\t" /* TRAP_ID_SYSCALL */ \
- " movi r3, %1\n\t" /* __NR_##name */ \
- " mov r4, %3\n\t" /* (long) a */ \
- \
- " trap\n\t" \
- " mov %0, r2\n\t" /* syscall rtn */ \
- \
- " \n\t" \
- \
- : "=r" (__res) /* %0 */ \
- \
- : "i" (__NR_##name) /* %1 */ \
- , "i" (TRAP_ID_SYSCALL) /* %2 */ \
- , "r" ((long) a) /* %3 */ \
- \
- : "r2" /* Clobbered */ \
- , "r3" /* Clobbered */ \
- , "r4" /* Clobbered */ \
- ); \
- \
-__syscall_return(type,__res); \
-}
+#define ASM_ARGS_0
+#define MAP_ARGS_0()
+#define CLOB_ARGS_0
-#define _syscall2(type,name,atype,a,btype,b) \
-type name(atype a,btype b) \
-{ \
- long __res; \
- \
- __asm__ __volatile__ ( \
- \
- " \n\t" \
- \
- " movi r2, %2\n\t" /* TRAP_ID_SYSCALL */ \
- " movi r3, %1\n\t" /* __NR_##name */ \
- " mov r4, %3\n\t" /* (long) a */ \
- " mov r5, %4\n\t" /* (long) b */ \
- \
- " trap\n\t" \
- " mov %0, r2\n\t" /* syscall rtn */ \
- \
- " \n\t" \
- \
- : "=r" (__res) /* %0 */ \
- \
- : "i" (__NR_##name) /* %1 */ \
- , "i" (TRAP_ID_SYSCALL) /* %2 */ \
- , "r" ((long) a) /* %3 */ \
- , "r" ((long) b) /* %4 */ \
- \
- : "r2" /* Clobbered */ \
- , "r3" /* Clobbered */ \
- , "r4" /* Clobbered */ \
- , "r5" /* Clobbered */ \
- ); \
- \
-__syscall_return(type,__res); \
-}
+#define ASM_ARGS_1 \
+ "mov r4, %3\n\t"
+#define MAP_ARGS_1(a) \
+ , "r" ((long) a)
+#define CLOB_ARGS_1 \
+ , "r4"
-#define _syscall3(type,name,atype,a,btype,b,ctype,c) \
-type name(atype a,btype b,ctype c) \
-{ \
- long __res; \
- \
- __asm__ __volatile__ ( \
- \
- " \n\t" \
- \
- " movi r2, %2\n\t" /* TRAP_ID_SYSCALL */ \
- " movi r3, %1\n\t" /* __NR_##name */ \
- " mov r4, %3\n\t" /* (long) a */ \
- " mov r5, %4\n\t" /* (long) b */ \
- " mov r6, %5\n\t" /* (long) c */ \
- \
- " trap\n\t" \
- " mov %0, r2\n\t" /* syscall rtn */ \
- \
- " \n\t" \
- \
- : "=r" (__res) /* %0 */ \
- \
- : "i" (__NR_##name) /* %1 */ \
- , "i" (TRAP_ID_SYSCALL) /* %2 */ \
- , "r" ((long) a) /* %3 */ \
- , "r" ((long) b) /* %4 */ \
- , "r" ((long) c) /* %5 */ \
- \
- : "r2" /* Clobbered */ \
- , "r3" /* Clobbered */ \
- , "r4" /* Clobbered */ \
- , "r5" /* Clobbered */ \
- , "r6" /* Clobbered */ \
- ); \
- \
-__syscall_return(type,__res); \
-}
+#define ASM_ARGS_2 \
+ ASM_ARGS_1 \
+ "mov r5, %4\n\t"
+#define MAP_ARGS_2(a, b) \
+ MAP_ARGS_1(a) \
+ , "r" ((long) b)
+#define CLOB_ARGS_2 \
+ CLOB_ARGS_1 \
+ , "r5"
-#define _syscall4(type,name,atype,a,btype,b,ctype,c,dtype,d) \
-type name (atype a, btype b, ctype c, dtype d) \
-{ \
- long __res; \
- \
- __asm__ __volatile__ ( \
- \
- " \n\t" \
- \
- " movi r2, %2\n\t" /* TRAP_ID_SYSCALL */ \
- " movi r3, %1\n\t" /* __NR_##name */ \
- " mov r4, %3\n\t" /* (long) a */ \
- " mov r5, %4\n\t" /* (long) b */ \
- " mov r6, %5\n\t" /* (long) c */ \
- " mov r7, %6\n\t" /* (long) d */ \
- \
- " trap\n\t" \
- " mov %0, r2\n\t" /* syscall rtn */ \
- \
- " \n\t" \
- \
- : "=r" (__res) /* %0 */ \
- \
- : "i" (__NR_##name) /* %1 */ \
- , "i" (TRAP_ID_SYSCALL) /* %2 */ \
- , "r" ((long) a) /* %3 */ \
- , "r" ((long) b) /* %4 */ \
- , "r" ((long) c) /* %5 */ \
- , "r" ((long) d) /* %6 */ \
- \
- : "r2" /* Clobbered */ \
- , "r3" /* Clobbered */ \
- , "r4" /* Clobbered */ \
- , "r5" /* Clobbered */ \
- , "r6" /* Clobbered */ \
- , "r7" /* Clobbered */ \
- ); \
- \
-__syscall_return(type,__res); \
-}
+#define ASM_ARGS_3 \
+ ASM_ARGS_2 \
+ "mov r6, %5\n\t"
+#define MAP_ARGS_3(a, b, c) \
+ MAP_ARGS_2(a, b) \
+ , "r" ((long) c)
+#define CLOB_ARGS_3 \
+ CLOB_ARGS_2 \
+ , "r6"
-#define _syscall5(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
-type name (atype a,btype b,ctype c,dtype d,etype e) \
-{ \
- long __res; \
- \
- __asm__ __volatile__ ( \
- \
- " \n\t" \
- \
- " movi r2, %2\n\t" /* TRAP_ID_SYSCALL */ \
- " movi r3, %1\n\t" /* __NR_##name */ \
- " mov r4, %3\n\t" /* (long) a */ \
- " mov r5, %4\n\t" /* (long) b */ \
- " mov r6, %5\n\t" /* (long) c */ \
- " mov r7, %6\n\t" /* (long) c */ \
- " mov r8, %7\n\t" /* (long) e */ \
- \
- " trap\n\t" \
- " mov %0, r2\n\t" /* syscall rtn */ \
- \
- " \n\t" \
- \
- : "=r" (__res) /* %0 */ \
- \
- : "i" (__NR_##name) /* %1 */ \
- , "i" (TRAP_ID_SYSCALL) /* %2 */ \
- , "r" ((long) a) /* %3 */ \
- , "r" ((long) b) /* %4 */ \
- , "r" ((long) c) /* %5 */ \
- , "r" ((long) d) /* %6 */ \
- , "r" ((long) e) /* %7 */ \
- \
- : "r2" /* Clobbered */ \
- , "r3" /* Clobbered */ \
- , "r4" /* Clobbered */ \
- , "r5" /* Clobbered */ \
- , "r6" /* Clobbered */ \
- , "r7" /* Clobbered */ \
- , "r8" /* Clobbered */ \
- ); \
- \
-__syscall_return(type,__res); \
-}
+#define ASM_ARGS_4 \
+ ASM_ARGS_3 \
+ "mov r7, %6\n\t"
+#define MAP_ARGS_4(a, b, c, d) \
+ MAP_ARGS_3(a, b, c) \
+ , "r" ((long) d)
+#define CLOB_ARGS_4 \
+ CLOB_ARGS_3 \
+ , "r7"
-#define _syscall6(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e,ftype,f) \
-type name (atype a,btype b,ctype c,dtype d,etype e,ftype f) \
-{ \
- long __res; \
- \
- __asm__ __volatile__ ( \
- \
- " \n\t" \
- \
- " movi r2, %2\n\t" /* TRAP_ID_SYSCALL */ \
- " movi r3, %1\n\t" /* __NR_##name */ \
- " mov r4, %3\n\t" /* (long) a */ \
- " mov r5, %4\n\t" /* (long) b */ \
- " mov r6, %5\n\t" /* (long) c */ \
- " mov r7, %6\n\t" /* (long) c */ \
- " mov r8, %7\n\t" /* (long) e */ \
- " mov r9, %8\n\t" /* (long) f */ \
- \
- " trap\n\t" \
- " mov %0, r2\n\t" /* syscall rtn */ \
- \
- " \n\t" \
- \
- : "=r" (__res) /* %0 */ \
- \
- : "i" (__NR_##name) /* %1 */ \
- , "i" (TRAP_ID_SYSCALL) /* %2 */ \
- , "r" ((long) a) /* %3 */ \
- , "r" ((long) b) /* %4 */ \
- , "r" ((long) c) /* %5 */ \
- , "r" ((long) d) /* %6 */ \
- , "r" ((long) e) /* %7 */ \
- , "r" ((long) f) /* %8 */ \
- \
- : "r2" /* Clobbered */ \
- , "r3" /* Clobbered */ \
- , "r4" /* Clobbered */ \
- , "r5" /* Clobbered */ \
- , "r6" /* Clobbered */ \
- , "r7" /* Clobbered */ \
- , "r8" /* Clobbered */ \
- , "r9" /* Clobbered */ \
- ); \
- \
-__syscall_return(type,__res); \
-}
+#define ASM_ARGS_5 \
+ ASM_ARGS_4 \
+ "mov r8, %7\n\t"
+#define MAP_ARGS_5(a, b, c, d, e) \
+ MAP_ARGS_4(a, b, c, d) \
+ , "r" ((long) e)
+#define CLOB_ARGS_5 \
+ CLOB_ARGS_4 \
+ , "r8"
+
+#define ASM_ARGS_6 \
+ ASM_ARGS_5 \
+ "mov r9, %8\n\t"
+#define MAP_ARGS_6(a, b, c, d, e, f) \
+ MAP_ARGS_5(a, b, c, d, e) \
+ , "r" ((long) f)
+#define CLOB_ARGS_6 \
+ CLOB_ARGS_5 \
+ , "r9"
#endif /* __ASSEMBLER__ */
#endif /* _BITS_SYSCALLS_H */
-
diff --git a/libc/sysdeps/linux/nios2/bits/uClibc_arch_features.h b/libc/sysdeps/linux/nios2/bits/uClibc_arch_features.h
index f4adaf5ad..293cc9b00 100644
--- a/libc/sysdeps/linux/nios2/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/nios2/bits/uClibc_arch_features.h
@@ -12,28 +12,31 @@
/* can your target use syscall6() for mmap ? */
#undef __UCLIBC_MMAP_HAS_6_ARGS__
-/* does your target use syscall4() for truncate64 ? (32bit arches only) */
-#undef __UCLIBC_TRUNCATE64_HAS_4_ARGS__
+/* does your target align 64bit values in register pairs ? (32bit arches only) */
+#undef __UCLIBC_SYSCALL_ALIGN_64BIT__
/* 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 */
+#undef __UCLIBC_ASM_LINE_SEP__
+
#endif /* _BITS_UCLIBC_ARCH_FEATURES_H */
diff --git a/libc/sysdeps/linux/nios2/bits/wordsize.h b/libc/sysdeps/linux/nios2/bits/wordsize.h
index ba643b60a..ca82fd7d4 100644
--- a/libc/sysdeps/linux/nios2/bits/wordsize.h
+++ b/libc/sysdeps/linux/nios2/bits/wordsize.h
@@ -12,8 +12,7 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#define __WORDSIZE 32
diff --git a/libc/sysdeps/linux/nios2/brk.c b/libc/sysdeps/linux/nios2/brk.c
index 0420798bc..42261eeac 100644
--- a/libc/sysdeps/linux/nios2/brk.c
+++ b/libc/sysdeps/linux/nios2/brk.c
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <unistd.h>
#include <sys/syscall.h>
@@ -24,7 +23,6 @@
/* This must be initialized data because commons can't have aliases. */
void *__curbrk attribute_hidden = 0;
-libc_hidden_proto(brk)
int brk (void *addr)
{
void *newbrk;
diff --git a/libc/sysdeps/linux/nios2/bsd-_setjmp.S b/libc/sysdeps/linux/nios2/bsd-_setjmp.S
index ed4061cd4..e1350f55e 100644
--- a/libc/sysdeps/linux/nios2/bsd-_setjmp.S
+++ b/libc/sysdeps/linux/nios2/bsd-_setjmp.S
@@ -11,9 +11,8 @@
*
*/
-#define _ASM
-#define _SETJMP_H
-#include <bits/setjmp.h>
+#include <features.h>
+#include <jmpbuf-offsets.h>
.globl _setjmp
.type _setjmp,@function
@@ -34,7 +33,7 @@ _setjmp:
stw fp, JB_FP(r4)
stw gp, JB_GP(r4)
-#if defined(__HAVE_FPU__)
+#ifdef __UCLIBC_HAS_FPU__
SAVE_FPU r4 JB_FPREGS
#endif
stw r0, JB_SIZE(r4) /* signal mask is not saved */
diff --git a/libc/sysdeps/linux/nios2/bsd-setjmp.S b/libc/sysdeps/linux/nios2/bsd-setjmp.S
index ac99bfe0a..f533754dc 100644
--- a/libc/sysdeps/linux/nios2/bsd-setjmp.S
+++ b/libc/sysdeps/linux/nios2/bsd-setjmp.S
@@ -12,9 +12,8 @@
*/
-#define _ASM
-#define _SETJMP_H
-#include <bits/setjmp.h>
+#include <features.h>
+#include <jmpbuf-offsets.h>
.globl setjmp
.type setjmp,@function
@@ -35,7 +34,7 @@ setjmp:
stw fp, JB_FP(r4)
stw gp, JB_GP(r4)
-#if defined(__HAVE_FPU__)
+#ifdef __UCLIBC_HAS_FPU__
SAVE_FPU r4 JB_FPREGS
#endif
diff --git a/libc/sysdeps/linux/nios2/crt1.S b/libc/sysdeps/linux/nios2/crt1.S
index 0ba8d59e6..c178452ae 100644
--- a/libc/sysdeps/linux/nios2/crt1.S
+++ b/libc/sysdeps/linux/nios2/crt1.S
@@ -14,6 +14,7 @@
#include <features.h>
#include <asm/unistd.h>
+#define TRAP_ID_SYSCALL 0
.global _start
.type _start,@function
@@ -25,9 +26,6 @@
#endif
.type main,@function
.type __uClibc_main,@function
- .type __h_errno_location, @function
- .type _stdio_init, @function
- .type _stdio_term, @function
.text
.balign 4
_start:
diff --git a/libc/sysdeps/linux/nios2/fpu_control.h b/libc/sysdeps/linux/nios2/fpu_control.h
index 9c3174574..4ba51b5eb 100644
--- a/libc/sysdeps/linux/nios2/fpu_control.h
+++ b/libc/sysdeps/linux/nios2/fpu_control.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FPU_CONTROL_H
#define _FPU_CONTROL_H
diff --git a/libc/sysdeps/linux/nios2/jmpbuf-offsets.h b/libc/sysdeps/linux/nios2/jmpbuf-offsets.h
new file mode 100644
index 000000000..b7d19cafb
--- /dev/null
+++ b/libc/sysdeps/linux/nios2/jmpbuf-offsets.h
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <features.h>
+
+#define JB_REGS 0
+#define JB_PC 32
+#define JB_SP 36
+#define JB_FP 40
+#define JB_GP 44
+#define JB_FPREGS 48
+
+#ifdef __UCLIBC_HAS_FPU__
+# define JB_SIZE 304
+#else
+# define JB_SIZE 48
+#endif
diff --git a/libc/sysdeps/linux/nios2/jmpbuf-unwind.h b/libc/sysdeps/linux/nios2/jmpbuf-unwind.h
new file mode 100644
index 000000000..64cd55fab
--- /dev/null
+++ b/libc/sysdeps/linux/nios2/jmpbuf-unwind.h
@@ -0,0 +1,11 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+#include <setjmp.h>
+
+/* Test if longjmp to JMPBUF would unwind the frame
+ containing a local variable at ADDRESS. */
+#define _JMPBUF_UNWINDS(jmpbuf, address) \
+ ((void *) (address) < (void *) (jmpbuf)->__sp)
diff --git a/libc/sysdeps/linux/nios2/setjmp.S b/libc/sysdeps/linux/nios2/setjmp.S
index 8acd22044..6071685b0 100644
--- a/libc/sysdeps/linux/nios2/setjmp.S
+++ b/libc/sysdeps/linux/nios2/setjmp.S
@@ -12,9 +12,7 @@
*/
#include <features.h>
-#define _ASM
-#define _SETJMP_H
-#include <bits/setjmp.h>
+#include <jmpbuf-offsets.h>
.globl __sigsetjmp
.type __sigsetjmp,@function
@@ -35,7 +33,7 @@ __sigsetjmp:
stw fp, JB_FP(r4)
stw gp, JB_GP(r4)
-#if defined(__HAVE_FPU__)
+#ifdef __UCLIBC_HAS_FPU__
SAVE_FPU r4 JB_FPREGS
#endif
diff --git a/libc/sysdeps/linux/nios2/sys/procfs.h b/libc/sysdeps/linux/nios2/sys/procfs.h
index 8cbaa41c5..edbd5a5ba 100644
--- a/libc/sysdeps/linux/nios2/sys/procfs.h
+++ b/libc/sysdeps/linux/nios2/sys/procfs.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_PROCFS_H
#define _SYS_PROCFS_H 1
diff --git a/libc/sysdeps/linux/nios2/sys/ucontext.h b/libc/sysdeps/linux/nios2/sys/ucontext.h
index 1805b4eac..02781c7b2 100644
--- a/libc/sysdeps/linux/nios2/sys/ucontext.h
+++ b/libc/sysdeps/linux/nios2/sys/ucontext.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_UCONTEXT_H
#define _SYS_UCONTEXT_H 1
diff --git a/libc/sysdeps/linux/nios2/sys/user.h b/libc/sysdeps/linux/nios2/sys/user.h
new file mode 100644
index 000000000..b34e93e97
--- /dev/null
+++ b/libc/sysdeps/linux/nios2/sys/user.h
@@ -0,0 +1,93 @@
+#ifndef _SYS_USER_H
+#define _SYS_USER_H 1
+
+/*
+ This file was taken from the nios2 port of the Linux Kernel.
+
+ Copyright (c) 2008 Atle Nissestad <atle@nissestad.no>
+ Copyright (c) 2010 Tobias Klauser <tklauser@distanz.ch>
+
+ This file is licensed under the terms of the GNU General Public License,
+ Version 2.
+ */
+
+#include <bits/uClibc_page.h>
+
+/* Core file format: The core file is written in such a way that gdb
+ can understand it and provide useful information to the user (under
+ linux we use the 'trad-core' bfd). There are quite a number of
+ obstacles to being able to view the contents of the floating point
+ registers, and until these are solved you will not be able to view the
+ contents of them. Actually, you can read in the core file and look at
+ the contents of the user struct to find out what the floating point
+ registers contain.
+ The actual file contents are as follows:
+ UPAGE: 1 page consisting of a user struct that tells gdb what is present
+ in the file. Directly after this is a copy of the task_struct, which
+ is currently not used by gdb, but it may come in useful at some point.
+ All of the registers are stored as part of the upage. The upage should
+ always be only one page.
+ DATA: The data area is stored. We use current->end_text to
+ current->brk to pick up all of the user variables, plus any memory
+ that may have been malloced. No attempt is made to determine if a page
+ is demand-zero or if a page is totally unused, we just cover the entire
+ range. All of the addresses are rounded in such a way that an integral
+ number of pages is written.
+ STACK: We need the stack information in order to get a meaningful
+ backtrace. We need to write the data from (esp) to
+ current->start_stack, so we round each of these off in order to be able
+ to write an integer number of pages.
+ The minimum core file size is 3 pages, or 12288 bytes.
+*/
+
+struct user_nios2fp_struct {
+};
+
+/* This is the old layout of "struct pt_regs" as of Linux 1.x, and
+ is still the layout used by user (the new pt_regs doesn't have
+ all registers). */
+struct user_regs_struct {
+ long r1,r2,r3,r4,r5,r6,r7,r8;
+ long r9,r10,r11,r12,r13,r14,r15;
+ long r16,r17,r18,r19,r20,r21,r22,r23;
+ long gp;
+ long sp;
+ long ra;
+ long fp;
+ long orig_r2;
+ long estatus;
+ long status_extension;
+ long ea;
+};
+
+/* When the kernel dumps core, it starts by dumping the user struct -
+ this will be used by gdb to figure out where the data and stack segments
+ are within the file, and what virtual addresses to use. */
+struct user {
+/* We start with the registers, to mimic the way that "memory" is returned
+ from the ptrace(3,...) function. */
+ struct user_regs_struct regs; /* Where the registers are actually stored */
+
+/* The rest of this junk is to help gdb figure out what goes where */
+ unsigned long int u_tsize; /* Text segment size (pages). */
+ unsigned long int u_dsize; /* Data segment size (pages). */
+ unsigned long int u_ssize; /* Stack segment size (pages). */
+ unsigned long start_code; /* Starting virtual address of text. */
+ unsigned long start_stack; /* Starting virtual address of stack area.
+ This is actually the bottom of the stack,
+ the top of the stack is always found in the
+ esp register. */
+ long int signal; /* Signal that caused the core dump. */
+ int reserved; /* No longer used */
+ unsigned long u_ar0; /* Used by gdb to help find the values for */
+ /* the registers. */
+ unsigned long magic; /* To uniquely identify a core file */
+ char u_comm[32]; /* User command that was responsible */
+};
+
+#define NBPG PAGE_SIZE
+#define UPAGES 1
+#define HOST_TEXT_START_ADDR (u.start_code)
+#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
+
+#endif
diff --git a/libc/sysdeps/linux/nios2/syscall.c b/libc/sysdeps/linux/nios2/syscall.c
index c3eb0022c..60ddd02a6 100644
--- a/libc/sysdeps/linux/nios2/syscall.c
+++ b/libc/sysdeps/linux/nios2/syscall.c
@@ -14,8 +14,8 @@
* 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
+ * along with this program; see the file COPYING.LIB. If not, see
+ * <http://www.gnu.org/licenses/>.
*/
#include <features.h>
diff --git a/libc/sysdeps/linux/nios2/vfork.S b/libc/sysdeps/linux/nios2/vfork.S
index 5d275ffdd..2aee81e6c 100644
--- a/libc/sysdeps/linux/nios2/vfork.S
+++ b/libc/sysdeps/linux/nios2/vfork.S
@@ -10,15 +10,9 @@
* Written by Wentao Xu <wentao@microtronix.com>
*/
-#include <features.h>
+#include <sys/syscall.h>
-#define _ERRNO_H
-#include <bits/errno.h>
-#include <asm/unistd.h>
-
-#ifndef __NR_vfork
-#define __NR_vfork __NR_fork /* uClinux-2.0 only has fork which is vfork */
-#endif
+#define __NR_vfork 1071
.text
.global __vfork
@@ -53,4 +47,4 @@ fix_errno:
.size __vfork,.-__vfork
weak_alias(__vfork,vfork)
-libc_hidden_weak(vfork)
+libc_hidden_def(vfork)
diff --git a/libc/sysdeps/linux/sh64/Makefile b/libc/sysdeps/linux/or1k/Makefile
index ecbf14228..633c91f3e 100644
--- a/libc/sysdeps/linux/sh64/Makefile
+++ b/libc/sysdeps/linux/or1k/Makefile
@@ -1,9 +1,9 @@
# Makefile for uClibc
#
-# Copyright (C) 2001 SuperH (UK) Ltd.
-# Copyright (C) 2003 Paul Mundt <lethal@linux-sh.org>
+# 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=../../../../
@@ -11,5 +11,3 @@ all: objs
include $(top_builddir)Rules.mak
include Makefile.arch
include $(top_srcdir)Makerules
-TOPDIR=../../../../
-include $(TOPDIR)Rules.mak
diff --git a/libc/sysdeps/linux/or1k/Makefile.arch b/libc/sysdeps/linux/or1k/Makefile.arch
new file mode 100644
index 000000000..53d4ed576
--- /dev/null
+++ b/libc/sysdeps/linux/or1k/Makefile.arch
@@ -0,0 +1,9 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2010 Jonas Bonn <jonas@southpole.se>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+CSRC-y := __syscall_error.c __init_brk.c brk.c sbrk.c clone.c
+SSRC-y := __longjmp.S setjmp.S
diff --git a/libc/sysdeps/linux/sh64/__init_brk.c b/libc/sysdeps/linux/or1k/__init_brk.c
index bb0692448..4c6763fdd 100644
--- a/libc/sysdeps/linux/sh64/__init_brk.c
+++ b/libc/sysdeps/linux/or1k/__init_brk.c
@@ -4,19 +4,21 @@
#include <unistd.h>
#include <sys/syscall.h>
-void * __curbrk attribute_hidden = 0;
+void * ___brk_addr = 0;
+
+int __init_brk (void);
+void *_brk(void *ptr);
#define __NR__brk __NR_brk
-attribute_hidden _syscall1(void *, _brk, void *, ptr);
+_syscall1(void *, _brk, void *, ptr);
-extern int __init_brk (void) attribute_hidden;
int
__init_brk (void)
{
- if (__curbrk == 0)
+ if (___brk_addr == 0)
{
- __curbrk = _brk(0);
- if (__curbrk == 0)
+ ___brk_addr = _brk(0);
+ if (___brk_addr == 0)
{
__set_errno(ENOMEM);
return -1;
diff --git a/libc/sysdeps/linux/or1k/__longjmp.S b/libc/sysdeps/linux/or1k/__longjmp.S
new file mode 100644
index 000000000..1eb5bb403
--- /dev/null
+++ b/libc/sysdeps/linux/or1k/__longjmp.S
@@ -0,0 +1,81 @@
+/* longjmp for or1k
+
+ Based on:
+ longjmp for PowerPC.
+ Copyright (C) 1995, 1996, 1997, 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. */
+
+#include <jmpbuf-offsets.h>
+
+#ifdef __UCLIBC_HAS_FLOATS__
+#define FP(x...) x
+#else
+#define FP(x...)
+#endif
+
+.globl __longjmp;
+.type __longjmp,@function;
+.align 2;
+
+__longjmp:
+# l.lwz r11,(JB_SR*4)(r3)
+# l.mtspr r0,r11,SPR_SR
+ l.lwz r1,((JB_GPRS+0)*4)(r3)
+ l.lwz r2,((JB_GPRS+1)*4)(r3)
+ /* pass through "value" to r11, then restore r4, for what it's worth" */
+#if 1
+ /* if r4 is 0, something wrong, so set it to 1 */
+ l.sfeqi r4, 0x0
+ l.bnf 1f /* r4 != 0, longjmp value sensible */
+ l.nop
+ l.ori r4, r0, 0x1 /* make nonzero */
+1:
+#endif
+ l.addi r11, r4, 0
+ l.lwz r4,((JB_GPRS+3)*4)(r3)
+ l.lwz r5,((JB_GPRS+4)*4)(r3)
+ l.lwz r6,((JB_GPRS+5)*4)(r3)
+ l.lwz r7,((JB_GPRS+6)*4)(r3)
+ l.lwz r8,((JB_GPRS+7)*4)(r3)
+ l.lwz r9,((JB_GPRS+8)*4)(r3)
+ l.lwz r10,((JB_GPRS+9)*4)(r3)
+ l.lwz r12,((JB_GPRS+11)*4)(r3)
+ l.lwz r13,((JB_GPRS+12)*4)(r3)
+ l.lwz r14,((JB_GPRS+13)*4)(r3)
+ l.lwz r15,((JB_GPRS+14)*4)(r3)
+ l.lwz r16,((JB_GPRS+15)*4)(r3)
+ l.lwz r17,((JB_GPRS+16)*4)(r3)
+ l.lwz r18,((JB_GPRS+17)*4)(r3)
+ l.lwz r19,((JB_GPRS+18)*4)(r3)
+ l.lwz r20,((JB_GPRS+19)*4)(r3)
+ l.lwz r21,((JB_GPRS+20)*4)(r3)
+ l.lwz r22,((JB_GPRS+21)*4)(r3)
+ l.lwz r23,((JB_GPRS+22)*4)(r3)
+ l.lwz r24,((JB_GPRS+23)*4)(r3)
+ l.lwz r25,((JB_GPRS+24)*4)(r3)
+ l.lwz r26,((JB_GPRS+25)*4)(r3)
+ l.lwz r27,((JB_GPRS+26)*4)(r3)
+ l.lwz r28,((JB_GPRS+27)*4)(r3)
+ l.lwz r29,((JB_GPRS+28)*4)(r3)
+ l.lwz r30,((JB_GPRS+29)*4)(r3)
+ l.lwz r31,((JB_GPRS+30)*4)(r3)
+ l.jr r9
+ l.nop
+.size __longjmp,.-__longjmp
+
+libc_hidden_def(__longjmp)
diff --git a/libc/sysdeps/linux/or1k/__syscall_error.c b/libc/sysdeps/linux/or1k/__syscall_error.c
new file mode 100644
index 000000000..ef8307893
--- /dev/null
+++ b/libc/sysdeps/linux/or1k/__syscall_error.c
@@ -0,0 +1,30 @@
+/* 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. */
+
+#include <errno.h>
+
+int __syscall_error (int err_no);
+
+/* This routine is jumped to by all the syscall handlers, to stash
+ * an error number into errno. */
+int __syscall_error (int err_no)
+{
+ __set_errno (err_no);
+ return -1;
+}
+
diff --git a/libc/sysdeps/linux/or1k/bits/endian.h b/libc/sysdeps/linux/or1k/bits/endian.h
new file mode 100644
index 000000000..799e27a6b
--- /dev/null
+++ b/libc/sysdeps/linux/or1k/bits/endian.h
@@ -0,0 +1,25 @@
+/* Copyright (C) 1997, 1998 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. */
+
+/* or1k can be little or big endian. Hopefully gcc will know... */
+
+#ifndef _ENDIAN_H
+# error "Never use <bits/endian.h> directly; include <endian.h> instead."
+#endif
+
+#define __BYTE_ORDER __BIG_ENDIAN
diff --git a/libc/sysdeps/linux/or1k/bits/fcntl.h b/libc/sysdeps/linux/or1k/bits/fcntl.h
new file mode 100644
index 000000000..234415e05
--- /dev/null
+++ b/libc/sysdeps/linux/or1k/bits/fcntl.h
@@ -0,0 +1,237 @@
+/* O_*, F_*, FD_* bit values for Linux.
+ Copyright (C) 1995-1998, 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
+
+#ifdef __USE_GNU
+# define O_DIRECT 040000 /* Direct disk access. */
+# define O_DIRECTORY 0200000 /* Must be a directory. */
+# define O_NOFOLLOW 0400000 /* Do not follow links. */
+# define O_NOATIME 01000000 /* Do not set atime. */
+# define O_CLOEXEC 02000000 /* Set close_on_exec. */
+# define O_PATH 010000000 /* Resolve pathname but do not open file. */
+#endif
+
+#ifdef __USE_LARGEFILE64
+# define O_LARGEFILE 0100000
+#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
+
+/* 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/or1k/bits/kernel_stat.h b/libc/sysdeps/linux/or1k/bits/kernel_stat.h
new file mode 100644
index 000000000..9c8abf658
--- /dev/null
+++ b/libc/sysdeps/linux/or1k/bits/kernel_stat.h
@@ -0,0 +1,59 @@
+/* taken from linux/include/asm-or1k/stat.h */
+
+#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. */
+ 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 long st_atime;
+ unsigned long __unused1;
+ unsigned long st_mtime;
+ unsigned long __unused2;
+ unsigned long st_ctime;
+ unsigned long __unused3;
+ */
+ unsigned int __unused4;
+ unsigned int __unused5;
+};
+
+/* This matches struct stat64 in glibc2.1.
+ */
+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
diff --git a/libc/sysdeps/linux/or1k/bits/kernel_types.h b/libc/sysdeps/linux/or1k/bits/kernel_types.h
new file mode 100644
index 000000000..4c5fe3ea6
--- /dev/null
+++ b/libc/sysdeps/linux/or1k/bits/kernel_types.h
@@ -0,0 +1 @@
+#include <asm/posix_types.h>
diff --git a/libc/sysdeps/linux/or1k/bits/machine-gmon.h b/libc/sysdeps/linux/or1k/bits/machine-gmon.h
new file mode 100644
index 000000000..15a1773d6
--- /dev/null
+++ b/libc/sysdeps/linux/or1k/bits/machine-gmon.h
@@ -0,0 +1,31 @@
+/* or1k-specific implementation of profiling support.
+ Copyright (C) 1997 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. */
+
+/* We need a special version of the `mcount' function because it has
+ to preserve more registers than your usual function. */
+
+void __mcount_internal (unsigned long frompc, unsigned long selfpc);
+
+#define _MCOUNT_DECL(frompc, selfpc) \
+void __mcount_internal (unsigned long frompc, unsigned long selfpc)
+
+
+/* Define MCOUNT as empty since we have the implementation in another
+ file. */
+#define MCOUNT
diff --git a/libc/sysdeps/linux/or1k/bits/setjmp.h b/libc/sysdeps/linux/or1k/bits/setjmp.h
new file mode 100644
index 000000000..ad93b1991
--- /dev/null
+++ b/libc/sysdeps/linux/or1k/bits/setjmp.h
@@ -0,0 +1,32 @@
+/* Copyright (C) 1997, 1998, 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. */
+
+/* Define the machine-dependent type `jmp_buf'. or1k version. */
+
+#ifndef _BITS_SETJMP_H
+#define _BITS_SETJMP_H 1
+
+#ifndef _SETJMP_H
+# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
+#endif
+
+#ifndef _ASM
+typedef long int __jmp_buf[32];
+#endif
+
+#endif
diff --git a/libc/sysdeps/linux/nios/bits/sigcontextinfo.h b/libc/sysdeps/linux/or1k/bits/sigcontextinfo.h
index caf1cf4ce..369738a99 100644
--- a/libc/sysdeps/linux/nios/bits/sigcontextinfo.h
+++ b/libc/sysdeps/linux/or1k/bits/sigcontextinfo.h
@@ -1,6 +1,5 @@
-/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
- Contributed by Jakub Jelinek <jakub@redhat.com>, 1999.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -17,11 +16,9 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
+#include <signal.h>
+
#define SIGCONTEXT struct sigcontext *
#define SIGCONTEXT_EXTRA_ARGS
-#define GET_PC(ctx) ((void *) ((ctx)->regs.pc))
-
-/* now way for nios to do GET_FRAME(ctx), it is not saved in ctx */
-#define GET_STACK(ctx) ((void *) (ctx)->regs.u_regs[14])
#define CALL_SIGHANDLER(handler, signo, ctx) \
(handler)((signo), SIGCONTEXT_EXTRA_ARGS (ctx))
diff --git a/libc/sysdeps/linux/nios/bits/stackinfo.h b/libc/sysdeps/linux/or1k/bits/stackinfo.h
index e7fbf5633..12d46a026 100644
--- a/libc/sysdeps/linux/nios/bits/stackinfo.h
+++ b/libc/sysdeps/linux/or1k/bits/stackinfo.h
@@ -22,7 +22,7 @@
#ifndef _STACKINFO_H
#define _STACKINFO_H 1
-/* On nios II the stack grows down. */
+/* On or1k the stack grows down. */
#define _STACK_GROWS_DOWN 1
#endif /* stackinfo.h */
diff --git a/libc/sysdeps/linux/or1k/bits/syscalls.h b/libc/sysdeps/linux/or1k/bits/syscalls.h
new file mode 100644
index 000000000..6a08d3cd1
--- /dev/null
+++ b/libc/sysdeps/linux/or1k/bits/syscalls.h
@@ -0,0 +1,101 @@
+/*
+ * Based on arm/bits/syscalls.h
+ */
+
+#ifndef _BITS_SYSCALLS_H
+#define _BITS_SYSCALLS_H
+#ifndef _SYSCALL_H
+# error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
+#endif
+
+/*
+ Some of the sneaky macros in the code were taken from
+ glibc-2.3.2/sysdeps/unix/sysv/linux/arm/sysdep.h
+*/
+
+#ifdef __ASSEMBLER__
+
+/* TODO: recheck this */
+
+/* Call a given syscall, with arguments loaded. Unlike the DO_CALL
+ macro in glibc, this macro does not load syscall arguments. */
+#undef DO_CALL
+#define DO_CALL(syscall_name) \
+ l.lwz r11, =SYS_ify (syscall_name); \
+ l.sys 1 \
+ l.nop
+
+#else
+
+#include <errno.h>
+
+#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+ ({ unsigned long __sys_result; \
+ { \
+ register long __sc_ret __asm__ ("r11") = name; \
+ LOAD_ARGS_##nr (args) \
+ __asm__ __volatile__ ("l.sys 1" \
+ : "=r" (__sc_ret) ASM_ARGS_OUT_##nr \
+ : "0" (__sc_ret) ASM_ARGS_IN_##nr \
+ : ASM_CLOBBERS_##nr \
+ "r12", "r13", "r15", "r17", "r19", \
+ "r21", "r23", "r25", "r27", "r29", \
+ "r31"); \
+ __asm__ __volatile__ ("l.nop"); \
+ __sys_result = __sc_ret; \
+ } \
+ (long) __sys_result; })
+
+/* : "0", "1", "2", "3", "4", "5", "6", \ */
+/* : ASM_CLOBBERS_##nr, \ */
+
+#define LOAD_ARGS_0()
+
+#define ASM_ARGS_OUT_0
+#define ASM_ARGS_IN_0
+#define ASM_CLOBBERS_0 "r3", ASM_CLOBBERS_1
+
+#define LOAD_ARGS_1(a) \
+ LOAD_ARGS_0 () \
+ register long __a __asm__ ("r3") = (long)(a);
+#define ASM_ARGS_OUT_1 ASM_ARGS_OUT_0, "=r" (__a)
+#define ASM_ARGS_IN_1 ASM_ARGS_IN_0, "1" (__a)
+#define ASM_CLOBBERS_1 "r4", ASM_CLOBBERS_2
+
+#define LOAD_ARGS_2(a, b) \
+ LOAD_ARGS_1 (a) \
+ register long __b __asm__ ("r4") = (long)(b);
+#define ASM_ARGS_OUT_2 ASM_ARGS_OUT_1, "=r" (__b)
+#define ASM_ARGS_IN_2 ASM_ARGS_IN_1, "2" (__b)
+#define ASM_CLOBBERS_2 "r5", ASM_CLOBBERS_3
+
+#define LOAD_ARGS_3(a, b, c) \
+ LOAD_ARGS_2 (a, b) \
+ register long __c __asm__ ("r5") = (long)(c);
+#define ASM_ARGS_OUT_3 ASM_ARGS_OUT_2, "=r" (__c)
+#define ASM_ARGS_IN_3 ASM_ARGS_IN_2, "3" (__c)
+#define ASM_CLOBBERS_3 "r6", ASM_CLOBBERS_4
+
+#define LOAD_ARGS_4(a, b, c, d) \
+ LOAD_ARGS_3 (a, b, c) \
+ register long __d __asm__ ("r6") = (long)(d);
+#define ASM_ARGS_OUT_4 ASM_ARGS_OUT_3, "=r" (__d)
+#define ASM_ARGS_IN_4 ASM_ARGS_IN_3, "4" (__d)
+#define ASM_CLOBBERS_4 "r7", ASM_CLOBBERS_5
+
+#define LOAD_ARGS_5(a, b, c, d, e) \
+ LOAD_ARGS_4 (a, b, c, d) \
+ register long __e __asm__ ("r7") = (long)(e);
+#define ASM_ARGS_OUT_5 ASM_ARGS_OUT_4, "=r" (__e)
+#define ASM_ARGS_IN_5 ASM_ARGS_IN_4, "5" (__e)
+#define ASM_CLOBBERS_5 "r8", ASM_CLOBBERS_6
+
+#define LOAD_ARGS_6(a, b, c, d, e, f) \
+ LOAD_ARGS_5 (a, b, c, d, e) \
+ register long __f __asm__ ("r8") = (long)(f);
+#define ASM_ARGS_OUT_6 ASM_ARGS_OUT_5, "=r" (__f)
+#define ASM_ARGS_IN_6 ASM_ARGS_IN_5, "6" (__f)
+#define ASM_CLOBBERS_6
+
+#endif /* __ASSEMBLER__ */
+#endif /* _BITS_SYSCALLS_H */
diff --git a/libc/sysdeps/linux/vax/bits/uClibc_arch_features.h b/libc/sysdeps/linux/or1k/bits/uClibc_arch_features.h
index eda49b81c..f4b2169c2 100644
--- a/libc/sysdeps/linux/vax/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/or1k/bits/uClibc_arch_features.h
@@ -5,8 +5,11 @@
#ifndef _BITS_UCLIBC_ARCH_FEATURES_H
#define _BITS_UCLIBC_ARCH_FEATURES_H
+#undef _ERRNO_H
+#undef EDEADLOCK /*Use Linux*/
+
/* instruction used when calling abort() to kill yourself */
-#define __UCLIBC_ABORT_INSTRUCTION__ "halt"
+#define __UCLIBC_ABORT_INSTRUCTION__ ".long 0xbfffffff"
/* can your target use syscall6() for mmap ? */
#define __UCLIBC_MMAP_HAS_6_ARGS__
@@ -17,22 +20,19 @@
/* 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 IEEE signed zero floats */
-#undef __UCLIBC_HAVE_SIGNED_ZERO__
+#define __UCLIBC_HAVE_SIGNED_ZERO__
#endif /* _BITS_UCLIBC_ARCH_FEATURES_H */
diff --git a/libc/sysdeps/linux/xtensa/bits/uClibc_page.h b/libc/sysdeps/linux/or1k/bits/uClibc_page.h
index 74a9f60ba..80c3bd9a1 100644
--- a/libc/sysdeps/linux/xtensa/bits/uClibc_page.h
+++ b/libc/sysdeps/linux/or1k/bits/uClibc_page.h
@@ -21,11 +21,15 @@
#ifndef _UCLIBC_PAGE_H
#define _UCLIBC_PAGE_H
-#include <bits/xtensa-config.h>
-
/* PAGE_SHIFT determines the page size -- in this case 4096 */
-#define PAGE_SHIFT XCHAL_MMU_MIN_PTE_PAGE_SIZE
+#define PAGE_SHIFT 13
#define PAGE_SIZE (1UL << PAGE_SHIFT)
#define PAGE_MASK (~(PAGE_SIZE-1))
+/* Some architectures always use 12 as page shift for mmap2() eventhough the
+ * real PAGE_SHIFT != 12. Other architectures use the same value as
+ * PAGE_SHIFT...
+ */
+#define MMAP2_PAGE_SHIFT PAGE_SHIFT
+
#endif /* _UCLIBC_PAGE_H */
diff --git a/libc/sysdeps/linux/nios/bits/wordsize.h b/libc/sysdeps/linux/or1k/bits/wordsize.h
index ba643b60a..ba643b60a 100644
--- a/libc/sysdeps/linux/nios/bits/wordsize.h
+++ b/libc/sysdeps/linux/or1k/bits/wordsize.h
diff --git a/libc/sysdeps/linux/or1k/brk.c b/libc/sysdeps/linux/or1k/brk.c
new file mode 100644
index 000000000..f8183dbc1
--- /dev/null
+++ b/libc/sysdeps/linux/or1k/brk.c
@@ -0,0 +1,23 @@
+/* From libc-5.3.12 */
+
+#include <errno.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+libc_hidden_proto(brk)
+extern void * ___brk_addr;
+
+extern int __init_brk (void);
+extern void *_brk(void *ptr);
+
+int brk(void * end_data_seg)
+{
+ if (__init_brk () == 0)
+ {
+ ___brk_addr = _brk(end_data_seg);
+ if (___brk_addr == end_data_seg)
+ return 0;
+ __set_errno(ENOMEM);
+ }
+ return -1;
+}
+libc_hidden_def(brk)
diff --git a/libc/sysdeps/linux/or1k/clone.c b/libc/sysdeps/linux/or1k/clone.c
new file mode 100644
index 000000000..ebb048ad4
--- /dev/null
+++ b/libc/sysdeps/linux/or1k/clone.c
@@ -0,0 +1,88 @@
+/*
+ * clone syscall for OpenRISC
+ *
+ * Copyright (c) 2010 Jonas Bonn <jonas@southpole.se>
+ * Copyright (C) 2003 John Williams <jwilliams@itee.uq.edu.au>
+ * Copyright (C) 2002,03 NEC Electronics Corporation
+ * Copyright (C) 2002,03 Miles Bader <miles@gnu.org>
+ *
+ * This file is subject to the terms and conditions of the GNU Lesser
+ * General Public License. See the file COPYING.LIB in the main
+ * directory of this archive for more details.
+ *
+ * OpenRISC port by Jonas Bonn <jonas@southpole.se>
+ */
+
+#include <errno.h>
+#include <sys/syscall.h>
+#include <sched.h>
+#include <unistd.h>
+
+/* The userland implementation is:
+ int clone (int (*fn)(void *arg), void *child_stack, int flags, void *arg, ...)
+ the kernel entry is:
+ int clone (long flags, void *child_stack)
+*/
+
+int
+clone (int (*fn)(void *arg), void *child_stack, int flags, void *arg, ...)
+{
+ int err;
+
+ /* OK, here's the skinny on this one...
+ * OR1K GCC does weird things with varargs functions... the last
+ * parameter is NEVER passed on the stack -- i.e. arg, in this case.
+ * So we need to push at least 'arg' onto the child stack so that
+ * the new thread can find it. Just to be totally safe, we'll
+ * push both 'fn' and 'arg'; that way we don't need to care what
+ * GCC does with parameters, whether they are passed in registers
+ * or on stack.
+ */
+
+ /* Put 'fn' and 'arg' on child stack */
+ __asm__ __volatile__ (
+ "l.sw -4(%0),%1;"
+ "l.sw -8(%0),%2;"
+ :
+ : "r" (child_stack), "r" (fn), "r" (arg)
+ );
+
+ /* Sanity check the arguments */
+ err = -EINVAL;
+ if (!fn)
+ goto syscall_error;
+ if (!child_stack)
+ goto syscall_error;
+
+ err = INLINE_SYSCALL(clone, 2, flags, child_stack);
+
+ /* NB: from here you are in child thread or parent thread.
+ *
+ * Do not use any functions here that may write data _up_
+ * onto the stack because they will overwrite the child's
+ * thread descriptor... i.e. don't use printf
+ */
+
+ if (err < 0)
+ goto syscall_error;
+ else if (err != 0) {
+ return err;
+ }
+
+ /* NB: from here you exclusively in child thread */
+
+ /* Grab 'fn' and 'arg' from child stack */
+ __asm__ __volatile__ (
+ "l.lwz %0,-4(%2);"
+ "l.lwz %1,-8(%2);"
+ : "=&r" (fn), "=r" (arg)
+ : "r" (child_stack)
+ : "0", "1"
+ );
+
+ _exit(fn(arg));
+
+syscall_error:
+ __set_errno (-err);
+ return -1;
+}
diff --git a/libc/sysdeps/linux/or1k/crt1.S b/libc/sysdeps/linux/or1k/crt1.S
new file mode 100644
index 000000000..c1926bef2
--- /dev/null
+++ b/libc/sysdeps/linux/or1k/crt1.S
@@ -0,0 +1,144 @@
+/* Copyright (C) 1995, 1996, 1997, 1998, 2001, 2002, 2005
+ Free Software Foundation, Inc.
+
+ Copyright (C) 2010 Embecosm Limited
+
+ Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
+ Contributor Joern Rennecke <joern.rennecke@embecosm.com>
+ With other contributions from the OpenCores community.
+
+ 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.)
+
+ Note that people who make modified versions of this file are not
+ obligated to grant this special exception for their modified
+ versions; it is their choice whether to do so. The GNU Lesser
+ General Public License gives permission to release a modified
+ version without this exception; this exception also makes it
+ possible to release a modified version which carries forward this
+ exception.
+
+ 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. */
+
+/* Stick in a dummy reference to main(), so that if an application
+ * is linking when the main() function is in a static library (.a)
+ * we can be sure that main() actually gets linked in */
+.type main,%function
+
+/* This is the canonical entry point, usually the first thing in the text
+ segment.
+
+ sp The stack contains the arguments and environment:
+ 0(sp) argc
+ 4(sp) argv[0]
+ ...
+ (4*argc)(sp) NULL
+ (4*(argc+1))(sp) envp[0]
+ ...
+ NULL
+*/
+
+#include <features.h>
+
+.text
+ .globl _start
+ .type _start,%function
+
+.global _start
+_start:
+
+#ifdef __PIC__
+ /* Obtain a pointer to .got in r16 */
+ l.jal .LPC0
+#ifndef __OR1K_NODELAY__
+ l.nop
+#endif
+.LPC0:
+ l.movhi r16, gotpchi(_GLOBAL_OFFSET_TABLE_+(.-.LPC0))
+ l.ori r16, r16, gotpclo(_GLOBAL_OFFSET_TABLE_+(.-.LPC0))
+ l.add r16, r16, r9
+#endif
+
+ /* Push stack limit onto the stack */
+ /* Provides highest stack address to user code (as stack grows
+ * downwards
+ * This is the seventh argument to __uClibc_main and thus needs to
+ * be passed on the stack
+ */
+ l.sw -4(r1),r1
+
+ /* Take values for argc and argv off the stack.
+ * These will be passed as arguments two and three to __uClibc_main
+ * and thus go in registers r4 and r5, respectively
+ */
+ l.lwz r4,0(r1)
+ l.addi r5,r1,4
+
+#ifdef __PIC__
+ l.lwz r3,got(main)(r16)
+#else
+ l.movhi r3,hi(main)
+ l.ori r3,r3,lo(main)
+#endif
+
+ /* Put the constructor and destructor initialization as args four and
+ five into r6 and r7 */
+#ifdef __PIC__
+ l.lwz r6, got(_init)(r16)
+ l.lwz r7, got(_fini)(r16)
+#else
+ l.movhi r6,hi(_init)
+ l.ori r6,r6,lo(_init)
+ l.movhi r7,hi(_fini)
+ l.ori r7,r7,lo(_fini)
+#endif
+
+ /* rtld_fini = NULL */
+ l.movhi r8, 0
+
+ /* Adjust stack to account for a total of 7 args (i.e. the last one is
+ on the stack. */
+ l.addi r1,r1,-4
+
+ /* Clear the frame pointer and link register since this is the
+ * outermost frame.
+ */
+ l.add r2,r0,r0
+ l.add r9,r0,r0
+
+ /* Let the libc call main and exit with its return code. */
+#ifdef __PIC__
+ l.j plt(__uClibc_main)
+#else
+ l.j __uClibc_main
+#endif
+ l.nop
+
+/* Define a symbol for the first piece of initialized data. */
+ .data
+ .globl __data_start
+__data_start:
+ .long 0
+ .weak data_start
+ data_start = __data_start
diff --git a/libc/sysdeps/linux/or1k/crti.S b/libc/sysdeps/linux/or1k/crti.S
new file mode 100644
index 000000000..a96476b5e
--- /dev/null
+++ b/libc/sysdeps/linux/or1k/crti.S
@@ -0,0 +1,11 @@
+ .section .init
+ .global _init
+_init:
+ l.addi r1,r1,-4
+ l.sw 0(r1),r9
+
+ .section .fini
+ .global _fini
+_fini:
+ l.addi r1,r1,-4
+ l.sw 0(r1),r9
diff --git a/libc/sysdeps/linux/or1k/crtn.S b/libc/sysdeps/linux/or1k/crtn.S
new file mode 100644
index 000000000..b3e8688ef
--- /dev/null
+++ b/libc/sysdeps/linux/or1k/crtn.S
@@ -0,0 +1,9 @@
+ .section .init
+ l.lwz r9,0(r1)
+ l.jr r9
+ l.addi r1,r1,4
+
+ .section .fini
+ l.lwz r9,0(r1)
+ l.jr r9
+ l.addi r1,r1,4
diff --git a/libc/sysdeps/linux/or1k/jmpbuf-offsets.h b/libc/sysdeps/linux/or1k/jmpbuf-offsets.h
new file mode 100644
index 000000000..8cd82a104
--- /dev/null
+++ b/libc/sysdeps/linux/or1k/jmpbuf-offsets.h
@@ -0,0 +1,8 @@
+#include <features.h>
+
+#define JB_SR 0
+#define JB_GPRS 1
+#define JB_SP 1
+#define JB_LR 9
+#define JB_RV 11
+#define JB_SIZE (32*4)
diff --git a/libc/sysdeps/linux/or1k/jmpbuf-unwind.h b/libc/sysdeps/linux/or1k/jmpbuf-unwind.h
new file mode 100644
index 000000000..436073b60
--- /dev/null
+++ b/libc/sysdeps/linux/or1k/jmpbuf-unwind.h
@@ -0,0 +1,24 @@
+/* Copyright (C) 2005,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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <setjmp.h>
+#include <jmpbuf-offsets.h>
+
+/* Test if longjmp to JMPBUF would unwind the frame
+ containing a local variable at ADDRESS. */
+#define _JMPBUF_UNWINDS(jmpbuf, address) \
+ ((void *) (address) < (void *) (jmpbuf)[JB_SP])
diff --git a/libc/sysdeps/linux/sh64/sbrk.c b/libc/sysdeps/linux/or1k/sbrk.c
index a1ff2a148..bd0635fcd 100644
--- a/libc/sysdeps/linux/sh64/sbrk.c
+++ b/libc/sysdeps/linux/or1k/sbrk.c
@@ -3,20 +3,21 @@
#include <errno.h>
#include <unistd.h>
#include <sys/syscall.h>
+libc_hidden_proto(sbrk)
-extern void * __curbrk attribute_hidden;
-extern int __init_brk (void) attribute_hidden;
-extern void *_brk(void *ptr) attribute_hidden;
+extern void * ___brk_addr;
+
+extern int __init_brk (void);
+extern void *_brk(void *ptr);
-libc_hidden_proto(sbrk)
void *
sbrk(intptr_t increment)
{
if (__init_brk () == 0)
{
- char * tmp = (char*)__curbrk+increment;
- __curbrk = _brk(tmp);
- if (__curbrk == tmp)
+ char * tmp = (char*)___brk_addr+increment;
+ ___brk_addr = _brk(tmp);
+ if (___brk_addr == tmp)
return tmp-increment;
__set_errno(ENOMEM);
return ((void *) -1);
diff --git a/libc/sysdeps/linux/or1k/setjmp.S b/libc/sysdeps/linux/or1k/setjmp.S
new file mode 100644
index 000000000..2814f2f24
--- /dev/null
+++ b/libc/sysdeps/linux/or1k/setjmp.S
@@ -0,0 +1,96 @@
+/* setjmp for or1k
+
+ Based on:
+ setjmp for PowerPC.
+ Copyright (C) 1995, 1996, 1997, 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. */
+
+#include "spr_defs.h"
+#include <jmpbuf-offsets.h>
+
+#ifdef __UCLIBC_HAS_FLOATS__
+#define FP(x...) x
+#else
+#define FP(x...)
+#endif
+
+.globl _setjmp
+.type _setjmp, @function
+.align 2
+
+_setjmp:
+ l.addi r4,r0,0 /* Set second argument to 0. */
+ l.j .Local_sigsetjmp
+ l.nop
+.size _setjmp,.-_setjmp
+
+.globl __setjmp
+.type __setjmp, @function
+.align 2
+
+__setjmp:
+ l.addi r4,r0,1 /* Set second argument to 1. */
+ l.j .Local_sigsetjmp
+ l.nop
+.size __setjmp,.-__setjmp
+
+.globl setjmp
+.set setjmp,__setjmp
+
+.globl __sigsetjmp
+.type __sigsetjmp, @function
+.align 2
+
+__sigsetjmp:
+.Local_sigsetjmp:
+# l.mfspr r11,r0,SPR_SR
+# l.sw (JB_SR*4)(r3),r11
+ l.sw ((JB_GPRS+0)*4)(r3),r1
+ l.sw ((JB_GPRS+1)*4)(r3),r2
+/* l.sw ((JB_GPRS+2)*4)(r3),r3*/
+ l.sw ((JB_GPRS+3)*4)(r3),r4
+ l.sw ((JB_GPRS+4)*4)(r3),r5
+ l.sw ((JB_GPRS+5)*4)(r3),r6
+ l.sw ((JB_GPRS+6)*4)(r3),r7
+ l.sw ((JB_GPRS+7)*4)(r3),r8
+ l.sw ((JB_GPRS+8)*4)(r3),r9
+ l.sw ((JB_GPRS+9)*4)(r3),r10
+ l.sw ((JB_GPRS+10)*4)(r3),r11
+ l.sw ((JB_GPRS+11)*4)(r3),r12
+ l.sw ((JB_GPRS+12)*4)(r3),r13
+ l.sw ((JB_GPRS+13)*4)(r3),r14
+ l.sw ((JB_GPRS+14)*4)(r3),r15
+ l.sw ((JB_GPRS+15)*4)(r3),r16
+ l.sw ((JB_GPRS+16)*4)(r3),r17
+ l.sw ((JB_GPRS+17)*4)(r3),r18
+ l.sw ((JB_GPRS+18)*4)(r3),r19
+ l.sw ((JB_GPRS+19)*4)(r3),r20
+ l.sw ((JB_GPRS+20)*4)(r3),r21
+ l.sw ((JB_GPRS+21)*4)(r3),r22
+ l.sw ((JB_GPRS+22)*4)(r3),r23
+ l.sw ((JB_GPRS+23)*4)(r3),r24
+ l.sw ((JB_GPRS+24)*4)(r3),r25
+ l.sw ((JB_GPRS+25)*4)(r3),r26
+ l.sw ((JB_GPRS+26)*4)(r3),r27
+ l.sw ((JB_GPRS+27)*4)(r3),r28
+ l.sw ((JB_GPRS+28)*4)(r3),r29
+ l.sw ((JB_GPRS+29)*4)(r3),r30
+ l.sw ((JB_GPRS+30)*4)(r3),r31
+ l.j __sigjmp_save
+ l.nop
+.size __sigsetjmp,.-__sigsetjmp
diff --git a/libc/sysdeps/linux/or1k/spr_defs.h b/libc/sysdeps/linux/or1k/spr_defs.h
new file mode 100644
index 000000000..263d3e43a
--- /dev/null
+++ b/libc/sysdeps/linux/or1k/spr_defs.h
@@ -0,0 +1,429 @@
+/* spr_defs.h -- Defines OR1K architecture specific special-purpose registers
+ Copyright (C) 1999 Damjan Lampret, lampret@opencores.org
+
+This file is part of OpenRISC 1000 Architectural Simulator.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+/* This file is also used by microkernel test bench. Among
+others it is also used in assembly file(s). */
+
+/* Definition of special-purpose registers (SPRs) */
+
+#define MAX_GRPS (32)
+#define MAX_SPRS_PER_GRP_BITS (11)
+#define MAX_SPRS_PER_GRP (1 << MAX_SPRS_PER_GRP_BITS)
+#define MAX_SPRS (0x10000)
+
+/* Base addresses for the groups */
+#define SPRGROUP_SYS (0<< MAX_SPRS_PER_GRP_BITS)
+#define SPRGROUP_DMMU (1<< MAX_SPRS_PER_GRP_BITS)
+#define SPRGROUP_IMMU (2<< MAX_SPRS_PER_GRP_BITS)
+#define SPRGROUP_DC (3<< MAX_SPRS_PER_GRP_BITS)
+#define SPRGROUP_IC (4<< MAX_SPRS_PER_GRP_BITS)
+#define SPRGROUP_MAC (5<< MAX_SPRS_PER_GRP_BITS)
+#define SPRGROUP_D (6<< MAX_SPRS_PER_GRP_BITS)
+#define SPRGROUP_PC (7<< MAX_SPRS_PER_GRP_BITS)
+#define SPRGROUP_PM (8<< MAX_SPRS_PER_GRP_BITS)
+#define SPRGROUP_PIC (9<< MAX_SPRS_PER_GRP_BITS)
+#define SPRGROUP_TT (10<< MAX_SPRS_PER_GRP_BITS)
+
+/* System control and status group */
+#define SPR_VR (SPRGROUP_SYS + 0)
+#define SPR_UPR (SPRGROUP_SYS + 1)
+#define SPR_CPUCFGR (SPRGROUP_SYS + 2)
+#define SPR_DMMUCFGR (SPRGROUP_SYS + 3)
+#define SPR_IMMUCFGR (SPRGROUP_SYS + 4)
+#define SPR_DCCFGR (SPRGROUP_SYS + 5)
+#define SPR_ICCFGR (SPRGROUP_SYS + 6)
+#define SPR_DCFGR (SPRGROUP_SYS + 7)
+#define SPR_PCCFGR (SPRGROUP_SYS + 8)
+#define SPR_NPC (SPRGROUP_SYS + 16) /* CZ 21/06/01 */
+#define SPR_SR (SPRGROUP_SYS + 17) /* CZ 21/06/01 */
+#define SPR_PPC (SPRGROUP_SYS + 18) /* CZ 21/06/01 */
+#define SPR_EPCR_BASE (SPRGROUP_SYS + 32) /* CZ 21/06/01 */
+#define SPR_EPCR_LAST (SPRGROUP_SYS + 47) /* CZ 21/06/01 */
+#define SPR_EEAR_BASE (SPRGROUP_SYS + 48)
+#define SPR_EEAR_LAST (SPRGROUP_SYS + 63)
+#define SPR_ESR_BASE (SPRGROUP_SYS + 64)
+#define SPR_ESR_LAST (SPRGROUP_SYS + 79)
+
+/* Data MMU group */
+#define SPR_DMMUCR (SPRGROUP_DMMU + 0)
+#define SPR_DTLBMR_BASE(WAY) (SPRGROUP_DMMU + 0x200 + (WAY) * 0x100)
+#define SPR_DTLBMR_LAST(WAY) (SPRGROUP_DMMU + 0x27f + (WAY) * 0x100)
+#define SPR_DTLBTR_BASE(WAY) (SPRGROUP_DMMU + 0x280 + (WAY) * 0x100)
+#define SPR_DTLBTR_LAST(WAY) (SPRGROUP_DMMU + 0x2ff + (WAY) * 0x100)
+
+/* Instruction MMU group */
+#define SPR_IMMUCR (SPRGROUP_IMMU + 0)
+#define SPR_ITLBMR_BASE(WAY) (SPRGROUP_IMMU + 0x200 + (WAY) * 0x100)
+#define SPR_ITLBMR_LAST(WAY) (SPRGROUP_IMMU + 0x27f + (WAY) * 0x100)
+#define SPR_ITLBTR_BASE(WAY) (SPRGROUP_IMMU + 0x280 + (WAY) * 0x100)
+#define SPR_ITLBTR_LAST(WAY) (SPRGROUP_IMMU + 0x2ff + (WAY) * 0x100)
+
+/* Data cache group */
+#define SPR_DCCR (SPRGROUP_DC + 0)
+#define SPR_DCBPR (SPRGROUP_DC + 1)
+#define SPR_DCBFR (SPRGROUP_DC + 2)
+#define SPR_DCBIR (SPRGROUP_DC + 3)
+#define SPR_DCBWR (SPRGROUP_DC + 4)
+#define SPR_DCBLR (SPRGROUP_DC + 5)
+#define SPR_DCR_BASE(WAY) (SPRGROUP_DC + 0x200 + (WAY) * 0x200)
+#define SPR_DCR_LAST(WAY) (SPRGROUP_DC + 0x3ff + (WAY) * 0x200)
+
+/* Instruction cache group */
+#define SPR_ICCR (SPRGROUP_IC + 0)
+#define SPR_ICBPR (SPRGROUP_IC + 1)
+#define SPR_ICBIR (SPRGROUP_IC + 2)
+#define SPR_ICBLR (SPRGROUP_IC + 3)
+#define SPR_ICR_BASE(WAY) (SPRGROUP_IC + 0x200 + (WAY) * 0x200)
+#define SPR_ICR_LAST(WAY) (SPRGROUP_IC + 0x3ff + (WAY) * 0x200)
+
+/* MAC group */
+#define SPR_MACLO (SPRGROUP_MAC + 1)
+#define SPR_MACHI (SPRGROUP_MAC + 2)
+
+/* Debug group */
+#define SPR_DVR(N) (SPRGROUP_D + (N))
+#define SPR_DCR(N) (SPRGROUP_D + 8 + (N))
+#define SPR_DMR1 (SPRGROUP_D + 16)
+#define SPR_DMR2 (SPRGROUP_D + 17)
+#define SPR_DWCR0 (SPRGROUP_D + 18)
+#define SPR_DWCR1 (SPRGROUP_D + 19)
+#define SPR_DSR (SPRGROUP_D + 20)
+#define SPR_DRR (SPRGROUP_D + 21)
+
+/* Performance counters group */
+#define SPR_PCCR(N) (SPRGROUP_PC + (N))
+#define SPR_PCMR(N) (SPRGROUP_PC + 8 + (N))
+
+/* Power management group */
+#define SPR_PMR (SPRGROUP_PM + 0)
+
+/* PIC group */
+#define SPR_PICMR (SPRGROUP_PIC + 0)
+#define SPR_PICPR (SPRGROUP_PIC + 1)
+#define SPR_PICSR (SPRGROUP_PIC + 2)
+
+/* Tick Timer group */
+#define SPR_TTMR (SPRGROUP_TT + 0)
+#define SPR_TTCR (SPRGROUP_TT + 1)
+
+/*
+ * Bit definitions for the Version Register
+ *
+ */
+#define SPR_VR_VER 0xffff0000 /* Processor version */
+#define SPR_VR_REV 0x0000003f /* Processor revision */
+
+/*
+ * Bit definitions for the Unit Present Register
+ *
+ */
+#define SPR_UPR_UP 0x00000001 /* UPR present */
+#define SPR_UPR_DCP 0x00000002 /* Data cache present */
+#define SPR_UPR_ICP 0x00000004 /* Instruction cache present */
+#define SPR_UPR_DMP 0x00000008 /* Data MMU present */
+#define SPR_UPR_IMP 0x00000010 /* Instruction MMU present */
+#define SPR_UPR_OB32P 0x00000020 /* ORBIS32 present */
+#define SPR_UPR_OB64P 0x00000040 /* ORBIS64 present */
+#define SPR_UPR_OF32P 0x00000080 /* ORFPX32 present */
+#define SPR_UPR_OF64P 0x00000100 /* ORFPX64 present */
+#define SPR_UPR_OV32P 0x00000200 /* ORVDX32 present */
+#define SPR_UPR_OV64P 0x00000400 /* ORVDX64 present */
+#define SPR_UPR_DUP 0x00000800 /* Debug unit present */
+#define SPR_UPR_PCUP 0x00001000 /* Performance counters unit present */
+#define SPR_UPR_PMP 0x00002000 /* Power management present */
+#define SPR_UPR_PICP 0x00004000 /* PIC present */
+#define SPR_UPR_TTP 0x00008000 /* Tick timer present */
+#define SPR_UPR_SRP 0x00010000 /* Shadow registers present */
+#define SPR_UPR_RES 0x00fe0000 /* ORVDX32 present */
+#define SPR_UPR_CUST 0xff000000 /* Custom units */
+
+/*
+ * Bit definitions for the Supervision Register
+ *
+ */
+#define SPR_SR_CID 0xf0000000 /* Context ID */
+#define SPR_SR_SUMRA 0x00010000 /* Supervisor SPR read access */
+#define SPR_SR_FO 0x00008000 /* Fixed one */
+#define SPR_SR_EPH 0x00004000 /* Exception Prefix High */
+#define SPR_SR_DSX 0x00002000 /* Delay Slot Exception */
+#define SPR_SR_OVE 0x00001000 /* Overflow flag Exception */
+#define SPR_SR_OV 0x00000800 /* Overflow flag */
+#define SPR_SR_CY 0x00000400 /* Carry flag */
+#define SPR_SR_F 0x00000200 /* Condition Flag */
+#define SPR_SR_CE 0x00000100 /* CID Enable */
+#define SPR_SR_LEE 0x00000080 /* Little Endian Enable */
+#define SPR_SR_IME 0x00000040 /* Instruction MMU Enable */
+#define SPR_SR_DME 0x00000020 /* Data MMU Enable */
+#define SPR_SR_ICE 0x00000010 /* Instruction Cache Enable */
+#define SPR_SR_DCE 0x00000008 /* Data Cache Enable */
+#define SPR_SR_IEE 0x00000004 /* Interrupt Exception Enable */
+#define SPR_SR_TEE 0x00000002 /* Tick timer Exception Enable */
+#define SPR_SR_SM 0x00000001 /* Supervisor Mode */
+
+/*
+ * Bit definitions for the Data MMU Control Register
+ *
+ */
+#define SPR_DMMUCR_P2S 0x0000003e /* Level 2 Page Size */
+#define SPR_DMMUCR_P1S 0x000007c0 /* Level 1 Page Size */
+#define SPR_DMMUCR_VADDR_WIDTH 0x0000f800 /* Virtual ADDR Width */
+#define SPR_DMMUCR_PADDR_WIDTH 0x000f0000 /* Physical ADDR Width */
+
+/*
+ * Bit definitions for the Instruction MMU Control Register
+ *
+ */
+#define SPR_IMMUCR_P2S 0x0000003e /* Level 2 Page Size */
+#define SPR_IMMUCR_P1S 0x000007c0 /* Level 1 Page Size */
+#define SPR_IMMUCR_VADDR_WIDTH 0x0000f800 /* Virtual ADDR Width */
+#define SPR_IMMUCR_PADDR_WIDTH 0x000f0000 /* Physical ADDR Width */
+
+/*
+ * Bit definitions for the Data TLB Match Register
+ *
+ */
+#define SPR_DTLBMR_V 0x00000001 /* Valid */
+#define SPR_DTLBMR_PL1 0x00000002 /* Page Level 1 (if 0 then PL2) */
+#define SPR_DTLBMR_CID 0x0000003c /* Context ID */
+#define SPR_DTLBMR_LRU 0x000000c0 /* Least Recently Used */
+#define SPR_DTLBMR_VPN 0xfffff000 /* Virtual Page Number */
+
+/*
+ * Bit definitions for the Data TLB Translate Register
+ *
+ */
+#define SPR_DTLBTR_CC 0x00000001 /* Cache Coherency */
+#define SPR_DTLBTR_CI 0x00000002 /* Cache Inhibit */
+#define SPR_DTLBTR_WBC 0x00000004 /* Write-Back Cache */
+#define SPR_DTLBTR_WOM 0x00000008 /* Weakly-Ordered Memory */
+#define SPR_DTLBTR_A 0x00000010 /* Accessed */
+#define SPR_DTLBTR_D 0x00000020 /* Dirty */
+#define SPR_DTLBTR_URE 0x00000040 /* User Read Enable */
+#define SPR_DTLBTR_UWE 0x00000080 /* User Write Enable */
+#define SPR_DTLBTR_SRE 0x00000100 /* Supervisor Read Enable */
+#define SPR_DTLBTR_SWE 0x00000200 /* Supervisor Write Enable */
+#define SPR_DTLBTR_PPN 0xfffff000 /* Physical Page Number */
+
+/*
+ * Bit definitions for the Instruction TLB Match Register
+ *
+ */
+#define SPR_ITLBMR_V 0x00000001 /* Valid */
+#define SPR_ITLBMR_PL1 0x00000002 /* Page Level 1 (if 0 then PL2) */
+#define SPR_ITLBMR_CID 0x0000003c /* Context ID */
+#define SPR_ITLBMR_LRU 0x000000c0 /* Least Recently Used */
+#define SPR_ITLBMR_VPN 0xfffff000 /* Virtual Page Number */
+
+/*
+ * Bit definitions for the Instruction TLB Translate Register
+ *
+ */
+#define SPR_ITLBTR_CC 0x00000001 /* Cache Coherency */
+#define SPR_ITLBTR_CI 0x00000002 /* Cache Inhibit */
+#define SPR_ITLBTR_WBC 0x00000004 /* Write-Back Cache */
+#define SPR_ITLBTR_WOM 0x00000008 /* Weakly-Ordered Memory */
+#define SPR_ITLBTR_A 0x00000010 /* Accessed */
+#define SPR_ITLBTR_D 0x00000020 /* Dirty */
+#define SPR_ITLBTR_SXE 0x00000040 /* User Read Enable */
+#define SPR_ITLBTR_UXE 0x00000080 /* User Write Enable */
+#define SPR_ITLBTR_PPN 0xfffff000 /* Physical Page Number */
+
+/*
+ * Bit definitions for Data Cache Control register
+ *
+ */
+#define SPR_DCCR_EW 0x000000ff /* Enable ways */
+
+/*
+ * Bit definitions for Insn Cache Control register
+ *
+ */
+#define SPR_ICCR_EW 0x000000ff /* Enable ways */
+
+/*
+ * Bit definitions for Debug Control registers
+ *
+ */
+#define SPR_DCR_DP 0x00000001 /* DVR/DCR present */
+#define SPR_DCR_CC 0x0000000e /* Compare condition */
+#define SPR_DCR_SC 0x00000010 /* Signed compare */
+#define SPR_DCR_CT 0x000000e0 /* Compare to */
+
+/* Bit results with SPR_DCR_CC mask */
+#define SPR_DCR_CC_MASKED 0x00000000
+#define SPR_DCR_CC_EQUAL 0x00000001
+#define SPR_DCR_CC_LESS 0x00000002
+#define SPR_DCR_CC_LESSE 0x00000003
+#define SPR_DCR_CC_GREAT 0x00000004
+#define SPR_DCR_CC_GREATE 0x00000005
+#define SPR_DCR_CC_NEQUAL 0x00000006
+
+/* Bit results with SPR_DCR_CT mask */
+#define SPR_DCR_CT_DISABLED 0x00000000
+#define SPR_DCR_CT_IFEA 0x00000020
+#define SPR_DCR_CT_LEA 0x00000040
+#define SPR_DCR_CT_SEA 0x00000060
+#define SPR_DCR_CT_LD 0x00000080
+#define SPR_DCR_CT_SD 0x000000a0
+#define SPR_DCR_CT_LSEA 0x000000c0
+
+/*
+ * Bit definitions for Debug Mode 1 register
+ *
+ */
+#define SPR_DMR1_CW0 0x00000003 /* Chain watchpoint 0 */
+#define SPR_DMR1_CW1 0x0000000c /* Chain watchpoint 1 */
+#define SPR_DMR1_CW2 0x00000030 /* Chain watchpoint 2 */
+#define SPR_DMR1_CW3 0x000000c0 /* Chain watchpoint 3 */
+#define SPR_DMR1_CW4 0x00000300 /* Chain watchpoint 4 */
+#define SPR_DMR1_CW5 0x00000c00 /* Chain watchpoint 5 */
+#define SPR_DMR1_CW6 0x00003000 /* Chain watchpoint 6 */
+#define SPR_DMR1_CW7 0x0000c000 /* Chain watchpoint 7 */
+#define SPR_DMR1_CW8 0x00030000 /* Chain watchpoint 8 */
+#define SPR_DMR1_CW9 0x000c0000 /* Chain watchpoint 9 */
+#define SPR_DMR1_CW10 0x00300000 /* Chain watchpoint 10 */
+#define SPR_DMR1_ST 0x00400000 /* Single-step trace*/
+#define SPR_DMR1_BT 0x00800000 /* Branch trace */
+#define SPR_DMR1_DXFW 0x01000000 /* Disable external force watchpoint */
+
+/*
+ * Bit definitions for Debug Mode 2 register
+ *
+ */
+#define SPR_DMR2_WCE0 0x00000001 /* Watchpoint counter 0 enable */
+#define SPR_DMR2_WCE1 0x00000002 /* Watchpoint counter 0 enable */
+#define SPR_DMR2_AWTC 0x00001ffc /* Assign watchpoints to counters */
+#define SPR_DMR2_WGB 0x00ffe000 /* Watchpoints generating breakpoint */
+
+/*
+ * Bit definitions for Debug watchpoint counter registers
+ *
+ */
+#define SPR_DWCR_COUNT 0x0000ffff /* Count */
+#define SPR_DWCR_MATCH 0xffff0000 /* Match */
+
+/*
+ * Bit definitions for Debug stop register
+ *
+ */
+#define SPR_DSR_RSTE 0x00000001 /* Reset exception */
+#define SPR_DSR_BUSEE 0x00000002 /* Bus error exception */
+#define SPR_DSR_DPFE 0x00000004 /* Data Page Fault exception */
+#define SPR_DSR_IPFE 0x00000008 /* Insn Page Fault exception */
+#define SPR_DSR_TTE 0x00000010 /* iTick Timer exception */
+#define SPR_DSR_AE 0x00000020 /* Alignment exception */
+#define SPR_DSR_IIE 0x00000040 /* Illegal Instruction exception */
+#define SPR_DSR_IE 0x00000080 /* Interrupt exception */
+#define SPR_DSR_DME 0x00000100 /* DTLB miss exception */
+#define SPR_DSR_IME 0x00000200 /* ITLB miss exception */
+#define SPR_DSR_RE 0x00000400 /* Range exception */
+#define SPR_DSR_SCE 0x00000800 /* System call exception */
+#define SPR_DSR_SSE 0x00001000 /* Single Step Exception */
+#define SPR_DSR_TE 0x00002000 /* Trap exception */
+
+/*
+ * Bit definitions for Debug reason register
+ *
+ */
+#define SPR_DRR_RSTE 0x00000001 /* Reset exception */
+#define SPR_DRR_BUSEE 0x00000002 /* Bus error exception */
+#define SPR_DRR_DPFE 0x00000004 /* Data Page Fault exception */
+#define SPR_DRR_IPFE 0x00000008 /* Insn Page Fault exception */
+#define SPR_DRR_TTE 0x00000010 /* Tick Timer exception */
+#define SPR_DRR_AE 0x00000020 /* Alignment exception */
+#define SPR_DRR_IIE 0x00000040 /* Illegal Instruction exception */
+#define SPR_DRR_IE 0x00000080 /* Interrupt exception */
+#define SPR_DRR_DME 0x00000100 /* DTLB miss exception */
+#define SPR_DRR_IME 0x00000200 /* ITLB miss exception */
+#define SPR_DRR_RE 0x00000400 /* Range exception */
+#define SPR_DRR_SCE 0x00000800 /* System call exception */
+#define SPR_DRR_TE 0x00001000 /* Trap exception */
+
+/*
+ * Bit definitions for Performance counters mode registers
+ *
+ */
+#define SPR_PCMR_CP 0x00000001 /* Counter present */
+#define SPR_PCMR_UMRA 0x00000002 /* User mode read access */
+#define SPR_PCMR_CISM 0x00000004 /* Count in supervisor mode */
+#define SPR_PCMR_CIUM 0x00000008 /* Count in user mode */
+#define SPR_PCMR_LA 0x00000010 /* Load access event */
+#define SPR_PCMR_SA 0x00000020 /* Store access event */
+#define SPR_PCMR_IF 0x00000040 /* Instruction fetch event*/
+#define SPR_PCMR_DCM 0x00000080 /* Data cache miss event */
+#define SPR_PCMR_ICM 0x00000100 /* Insn cache miss event */
+#define SPR_PCMR_IFS 0x00000200 /* Insn fetch stall event */
+#define SPR_PCMR_LSUS 0x00000400 /* LSU stall event */
+#define SPR_PCMR_BS 0x00000800 /* Branch stall event */
+#define SPR_PCMR_DTLBM 0x00001000 /* DTLB miss event */
+#define SPR_PCMR_ITLBM 0x00002000 /* ITLB miss event */
+#define SPR_PCMR_DDS 0x00004000 /* Data dependency stall event */
+#define SPR_PCMR_WPE 0x03ff8000 /* Watchpoint events */
+
+/*
+ * Bit definitions for the Power management register
+ *
+ */
+#define SPR_PMR_SDF 0x0000000f /* Slow down factor */
+#define SPR_PMR_DME 0x00000010 /* Doze mode enable */
+#define SPR_PMR_SME 0x00000020 /* Sleep mode enable */
+#define SPR_PMR_DCGE 0x00000040 /* Dynamic clock gating enable */
+#define SPR_PMR_SUME 0x00000080 /* Suspend mode enable */
+
+/*
+ * Bit definitions for PICMR
+ *
+ */
+#define SPR_PICMR_IUM 0xfffffffc /* Interrupt unmask */
+
+/*
+ * Bit definitions for PICPR
+ *
+ */
+#define SPR_PICPR_IPRIO 0xfffffffc /* Interrupt priority */
+
+/*
+ * Bit definitions for PICSR
+ *
+ */
+#define SPR_PICSR_IS 0xffffffff /* Interrupt status */
+
+/*
+ * Bit definitions for Tick Timer Control Register
+ *
+ */
+#define SPR_TTCR_PERIOD 0x0fffffff /* Time Period */
+#define SPR_TTMR_PERIOD SPR_TTCR_PERIOD
+#define SPR_TTMR_IP 0x10000000 /* Interrupt Pending */
+#define SPR_TTMR_IE 0x20000000 /* Interrupt Enable */
+#define SPR_TTMR_RT 0x40000000 /* Restart tick */
+#define SPR_TTMR_SR 0x80000000 /* Single run */
+#define SPR_TTMR_CR 0xc0000000 /* Continuous run */
+#define SPR_TTMR_M 0xc0000000 /* Tick mode */
+
+/*
+ * l.nop constants
+ *
+ */
+#define NOP_NOP 0x0000 /* Normal nop instruction */
+#define NOP_EXIT 0x0001 /* End of simulation */
+#define NOP_REPORT 0x0002 /* Simple report */
+#define NOP_PRINTF 0x0003 /* Simprintf instruction */
+#define NOP_REPORT_FIRST 0x0400 /* Report with number */
+#define NOP_REPORT_LAST 0x03ff /* Report with number */
diff --git a/libc/sysdeps/linux/sh64/sys/procfs.h b/libc/sysdeps/linux/or1k/sys/procfs.h
index aad21e5f8..9d4c68fec 100644
--- a/libc/sysdeps/linux/sh64/sys/procfs.h
+++ b/libc/sysdeps/linux/or1k/sys/procfs.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 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
@@ -28,19 +28,10 @@
#include <sys/time.h>
#include <sys/types.h>
#include <sys/ucontext.h>
-#include <sys/user.h>
-__BEGIN_DECLS
-
-/*
- * ELF register definitions...
- */
-typedef unsigned long elf_greg_t;
-
-#define ELF_NGREG (sizeof (struct pt_regs) / sizeof(elf_greg_t))
-typedef elf_greg_t elf_gregset_t[ELF_NGREG];
+#include <asm/elf.h>
-typedef struct user_fpu_struct elf_fpregset_t;
+__BEGIN_DECLS
struct elf_siginfo
{
@@ -97,15 +88,14 @@ struct elf_prpsinfo
char pr_zomb; /* Zombie. */
char pr_nice; /* Nice val. */
unsigned long int pr_flag; /* Flags. */
- long pr_uid;
- long pr_gid;
- int pr_pid, pr_ppid, pr_pgrp, pr_sid;
+ __uid_t pr_uid;
+ __gid_t pr_gid;
+ __pid_t 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. */
};
-
/* Addresses. */
typedef void *psaddr_t;
diff --git a/libc/sysdeps/linux/e1/sys/reg.h b/libc/sysdeps/linux/or1k/sys/ucontext.h
index a8a7ec1b7..0d82cdb1c 100644
--- a/libc/sysdeps/linux/e1/sys/reg.h
+++ b/libc/sysdeps/linux/or1k/sys/ucontext.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1998, 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
@@ -16,10 +16,11 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#ifndef _SYS_REG_H
-#define _SYS_REG_H 1
+#ifndef _SYS_UCONTEXT_H
+#define _SYS_UCONTEXT_H 1
-/* Index into an array of 4 byte integers returned from ptrace for
- location of the users' stored general purpose registers. */
+#include <features.h>
+#include <signal.h>
+#include <asm/ucontext.h>
-#endif /* _SYS_REG_H */
+#endif /* sys/ucontext.h */
diff --git a/libc/sysdeps/linux/powerpc/Makefile.arch b/libc/sysdeps/linux/powerpc/Makefile.arch
index 85c2cd3c6..7c09c879e 100644
--- a/libc/sysdeps/linux/powerpc/Makefile.arch
+++ b/libc/sysdeps/linux/powerpc/Makefile.arch
@@ -5,14 +5,14 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-CSRC := __syscall_error.c pread_write.c ioctl.c
+CSRC-y := __syscall_error.c ioctl.c copysignl.c
-SSRC := \
+SSRC-y := \
__longjmp.S setjmp.S bsd-setjmp.S bsd-_setjmp.S brk.S \
- clone.S __uClibc_syscall.S syscall.S vfork.S
+ __uClibc_syscall.S syscall.S
+
+SSRC-$(if $(UCLIBC_HAS_THREADS_NATIVE),,y) += clone.S vfork.S
ifeq ($(CONFIG_E500),y)
ARCH_HEADERS := fenv.h
endif
-
-include $(top_srcdir)libc/sysdeps/linux/Makefile.commonarch
diff --git a/libc/sysdeps/linux/powerpc/__longjmp.S b/libc/sysdeps/linux/powerpc/__longjmp.S
index 765a87315..ad99ac9e2 100644
--- a/libc/sysdeps/linux/powerpc/__longjmp.S
+++ b/libc/sysdeps/linux/powerpc/__longjmp.S
@@ -15,15 +15,12 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <features.h>
#include "ppc_asm.h"
-#define _ASM
-#define _SETJMP_H
-#include <bits/setjmp.h>
+#include <jmpbuf-offsets.h>
#if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__
diff --git a/libc/sysdeps/linux/powerpc/bits/atomic.h b/libc/sysdeps/linux/powerpc/bits/atomic.h
index d8a4ed33e..a401206d5 100644
--- a/libc/sysdeps/linux/powerpc/bits/atomic.h
+++ b/libc/sysdeps/linux/powerpc/bits/atomic.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <bits/wordsize.h>
@@ -37,9 +36,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* The 32-bit exchange_bool is different on powerpc64 because the subf
does signed 64-bit arthmatic while the lwarx is 32-bit unsigned
@@ -260,9 +258,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/*
* The 32-bit exchange_bool is different on powerpc64 because the subf
@@ -335,12 +332,28 @@
# define __arch_atomic_decrement_if_positive_64(mem) \
({ abort (); (*mem)--; })
+#ifdef _ARCH_PWR4
+/*
+ * Newer powerpc64 processors support the new "light weight" sync (lwsync)
+ * So if the build is using -mcpu=[power4,power5,power5+,970] we can
+ * safely use lwsync.
+ */
+# define atomic_read_barrier() __asm__ ("lwsync" ::: "memory")
+/*
+ * "light weight" sync can also be used for the release barrier.
+ */
+# ifndef UP
+# define __ARCH_REL_INSTR "lwsync"
+# endif
+#else
+
/*
* Older powerpc32 processors don't support the new "light weight"
* sync (lwsync). So the only safe option is to use normal sync
* for all powerpc32 applications.
*/
# define atomic_read_barrier() __asm__ ("sync" ::: "memory")
+#endif
#endif
@@ -387,6 +400,13 @@ typedef uintmax_t uatomic_max_t;
# endif
#endif
+#ifndef MUTEX_HINT_ACQ
+# define MUTEX_HINT_ACQ
+#endif
+#ifndef MUTEX_HINT_REL
+# define MUTEX_HINT_REL
+#endif
+
#define atomic_full_barrier() __asm__ ("sync" ::: "memory")
#define atomic_write_barrier() __asm__ ("eieio" ::: "memory")
@@ -512,7 +532,7 @@ typedef uintmax_t uatomic_max_t;
__result = __arch_compare_and_exchange_val_32_acq(mem, newval, oldval); \
else if (sizeof (*mem) == 8) \
__result = __arch_compare_and_exchange_val_64_acq(mem, newval, oldval); \
- else \
+ else \
abort (); \
__result; \
})
@@ -524,7 +544,7 @@ typedef uintmax_t uatomic_max_t;
__result = __arch_compare_and_exchange_val_32_rel(mem, newval, oldval); \
else if (sizeof (*mem) == 8) \
__result = __arch_compare_and_exchange_val_64_rel(mem, newval, oldval); \
- else \
+ else \
abort (); \
__result; \
})
@@ -536,7 +556,7 @@ typedef uintmax_t uatomic_max_t;
__result = __arch_atomic_exchange_32_acq (mem, value); \
else if (sizeof (*mem) == 8) \
__result = __arch_atomic_exchange_64_acq (mem, value); \
- else \
+ else \
abort (); \
__result; \
})
@@ -548,7 +568,7 @@ typedef uintmax_t uatomic_max_t;
__result = __arch_atomic_exchange_32_rel (mem, value); \
else if (sizeof (*mem) == 8) \
__result = __arch_atomic_exchange_64_rel (mem, value); \
- else \
+ else \
abort (); \
__result; \
})
@@ -560,7 +580,7 @@ typedef uintmax_t uatomic_max_t;
__result = __arch_atomic_exchange_and_add_32 (mem, value); \
else if (sizeof (*mem) == 8) \
__result = __arch_atomic_exchange_and_add_64 (mem, value); \
- else \
+ else \
abort (); \
__result; \
})
@@ -572,7 +592,7 @@ typedef uintmax_t uatomic_max_t;
__result = __arch_atomic_increment_val_32 (mem); \
else if (sizeof (*(mem)) == 8) \
__result = __arch_atomic_increment_val_64 (mem); \
- else \
+ else \
abort (); \
__result; \
})
@@ -586,7 +606,7 @@ typedef uintmax_t uatomic_max_t;
__result = __arch_atomic_decrement_val_32 (mem); \
else if (sizeof (*(mem)) == 8) \
__result = __arch_atomic_decrement_val_64 (mem); \
- else \
+ else \
abort (); \
__result; \
})
diff --git a/libc/sysdeps/linux/powerpc/bits/endian.h b/libc/sysdeps/linux/powerpc/bits/endian.h
index 2a079347d..7668dd82d 100644
--- a/libc/sysdeps/linux/powerpc/bits/endian.h
+++ b/libc/sysdeps/linux/powerpc/bits/endian.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* PowerPC can be little or big endian. Hopefully gcc will know... */
diff --git a/libc/sysdeps/linux/powerpc/bits/fcntl.h b/libc/sysdeps/linux/powerpc/bits/fcntl.h
index f26a25e76..e13ca19b8 100644
--- a/libc/sysdeps/linux/powerpc/bits/fcntl.h
+++ b/libc/sysdeps/linux/powerpc/bits/fcntl.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FCNTL_H
# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
@@ -49,10 +48,9 @@
# define O_DIRECT 0400000 /* Direct disk access. */
# define O_DIRECTORY 040000 /* Must be a directory. */
# define O_NOFOLLOW 0100000 /* Do not follow links. */
-# define O_NOATIME 01000000 /* Do not set atime. */
-# if 0
-# define O_CLOEXEC 02000000 /* Set close_on_exec. */
-# endif
+# define O_NOATIME 01000000 /* Do not set atime. */
+# define O_CLOEXEC 02000000 /* Set close_on_exec. */
+# define O_PATH 010000000 /* Resolve pathname but do not open file. */
#endif
#ifdef __USE_LARGEFILE64
@@ -102,6 +100,8 @@
# define F_NOTIFY 1026 /* Request notfications on a directory. */
# define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with
close-on-exit set on new fd. */
+# define F_SETPIPE_SZ 1031 /* Set pipe page size array. */
+# define F_GETPIPE_SZ 1032 /* Get pipe page size array. */
#endif
/* For F_[GET|SET]FD. */
@@ -189,7 +189,7 @@ struct flock64
#endif
-#ifdef __USE_GNU
+#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
@@ -212,7 +212,7 @@ struct flock64
__BEGIN_DECLS
-#ifdef __USE_GNU
+#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)
diff --git a/libc/sysdeps/linux/powerpc/bits/fenv.h b/libc/sysdeps/linux/powerpc/bits/fenv.h
index b674965fa..01c68d72f 100644
--- a/libc/sysdeps/linux/powerpc/bits/fenv.h
+++ b/libc/sysdeps/linux/powerpc/bits/fenv.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FENV_H
# error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
diff --git a/libc/sysdeps/linux/powerpc/bits/fenvinline.h b/libc/sysdeps/linux/powerpc/bits/fenvinline.h
index 8146479d8..2dc67ef1c 100644
--- a/libc/sysdeps/linux/powerpc/bits/fenvinline.h
+++ b/libc/sysdeps/linux/powerpc/bits/fenvinline.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <features.h>
diff --git a/libc/sysdeps/linux/powerpc/bits/ipc.h b/libc/sysdeps/linux/powerpc/bits/ipc.h
index 4f45aca36..e21debf5d 100644
--- a/libc/sysdeps/linux/powerpc/bits/ipc.h
+++ b/libc/sysdeps/linux/powerpc/bits/ipc.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_IPC_H
# error "Never use <bits/ipc.h> directly; include <sys/ipc.h> instead."
diff --git a/libc/sysdeps/linux/powerpc/bits/kernel_stat.h b/libc/sysdeps/linux/powerpc/bits/kernel_stat.h
index bfa67229d..579b5b4e2 100644
--- a/libc/sysdeps/linux/powerpc/bits/kernel_stat.h
+++ b/libc/sysdeps/linux/powerpc/bits/kernel_stat.h
@@ -1,13 +1,10 @@
#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... */
+
#if __WORDSIZE == 64
#define kernel_stat kernel_stat64
#else
@@ -22,12 +19,9 @@ struct kernel_stat {
__kernel_off_t st_size;
unsigned long st_blksize;
unsigned long st_blocks;
- unsigned long st_atime;
- unsigned long __unused1;
- unsigned long st_mtime;
- unsigned long __unused2;
- unsigned long st_ctime;
- unsigned long __unused3;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
unsigned long __unused4;
unsigned long __unused5;
};
@@ -45,12 +39,9 @@ struct kernel_stat64 {
long long st_size; /* Size of file, in bytes. */
long st_blksize; /* Optimal block size for I/O. */
long long st_blocks; /* Number 512-byte blocks allocated. */
- long st_atime; /* Time of last access. */
- unsigned long int __unused1;
- long st_mtime; /* Time of last modification. */
- unsigned long int __unused2;
- long st_ctime; /* Time of last status change. */
- unsigned long int __unused3;
+ struct timespec st_atim; /* Time of last access. */
+ struct timespec st_mtim; /* Time of last modification. */
+ struct timespec st_ctim; /* Time of last status change. */
unsigned long int __unused4;
unsigned long int __unused5;
};
diff --git a/libc/sysdeps/linux/powerpc/bits/kernel_types.h b/libc/sysdeps/linux/powerpc/bits/kernel_types.h
index 3f3b93377..1167de263 100644
--- a/libc/sysdeps/linux/powerpc/bits/kernel_types.h
+++ b/libc/sysdeps/linux/powerpc/bits/kernel_types.h
@@ -36,6 +36,8 @@ typedef unsigned int __kernel_gid32_t;
typedef unsigned int __kernel_old_uid_t;
typedef unsigned int __kernel_old_gid_t;
typedef __kernel_dev_t __kernel_old_dev_t;
+typedef long __kernel_long_t;
+typedef unsigned long __kernel_ulong_t;
#else
typedef unsigned int __kernel_dev_t;
typedef unsigned int __kernel_ino_t;
@@ -61,6 +63,8 @@ typedef unsigned int __kernel_gid32_t;
typedef unsigned int __kernel_old_uid_t;
typedef unsigned int __kernel_old_gid_t;
typedef __kernel_dev_t __kernel_old_dev_t;
+typedef long __kernel_long_t;
+typedef unsigned long __kernel_ulong_t;
typedef long long __kernel_loff_t;
#endif
diff --git a/libc/sysdeps/linux/powerpc/bits/local_lim.h b/libc/sysdeps/linux/powerpc/bits/local_lim.h
new file mode 100644
index 000000000..0e50affac
--- /dev/null
+++ b/libc/sysdeps/linux/powerpc/bits/local_lim.h
@@ -0,0 +1,101 @@
+/* Minimum guaranteed maximum values for system limits. Linux/PPC version.
+ Copyright (C) 1993-1998,2000,2002-2004,2006,2008
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ 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, see <http://www.gnu.org/licenses/>. */
+
+/* The kernel header pollutes the namespace with the NR_OPEN symbol
+ and defines LINK_MAX although filesystems have different maxima. A
+ similar thing is true for OPEN_MAX: the limit can be changed at
+ runtime and therefore the macro must not be defined. Remove this
+ after including the header if necessary. */
+#ifndef NR_OPEN
+# define __undef_NR_OPEN
+#endif
+#ifndef LINK_MAX
+# define __undef_LINK_MAX
+#endif
+#ifndef OPEN_MAX
+# define __undef_OPEN_MAX
+#endif
+#ifndef ARG_MAX
+# define __undef_ARG_MAX
+#endif
+
+/* The kernel sources contain a file with all the needed information. */
+#include <linux/limits.h>
+
+/* Have to remove NR_OPEN? */
+#ifdef __undef_NR_OPEN
+# undef NR_OPEN
+# undef __undef_NR_OPEN
+#endif
+/* Have to remove LINK_MAX? */
+#ifdef __undef_LINK_MAX
+# undef LINK_MAX
+# undef __undef_LINK_MAX
+#endif
+/* Have to remove OPEN_MAX? */
+#ifdef __undef_OPEN_MAX
+# undef OPEN_MAX
+# undef __undef_OPEN_MAX
+#endif
+/* Have to remove ARG_MAX? */
+#ifdef __undef_ARG_MAX
+# undef ARG_MAX
+# undef __undef_ARG_MAX
+#endif
+
+/* The number of data keys per process. */
+#define _POSIX_THREAD_KEYS_MAX 128
+/* This is the value this implementation supports. */
+#define PTHREAD_KEYS_MAX 1024
+
+/* Controlling the iterations of destructors for thread-specific data. */
+#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
+/* Number of iterations this implementation does. */
+#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
+
+/* The number of threads per process. */
+#define _POSIX_THREAD_THREADS_MAX 64
+/* We have no predefined limit on the number of threads. */
+#undef PTHREAD_THREADS_MAX
+
+/* Maximum amount by which a process can descrease its asynchronous I/O
+ priority level. */
+#define AIO_PRIO_DELTA_MAX 20
+
+/* Minimum size for a thread. At least two pages for systems with 64k
+ pages. */
+#define PTHREAD_STACK_MIN 131072
+
+/* Maximum number of timer expiration overruns. */
+#define DELAYTIMER_MAX 2147483647
+
+/* Maximum tty name length. */
+#define TTY_NAME_MAX 32
+
+/* Maximum login name length. This is arbitrary. */
+#define LOGIN_NAME_MAX 256
+
+/* Maximum host name length. */
+#define HOST_NAME_MAX 64
+
+/* Maximum message queue priority level. */
+#define MQ_PRIO_MAX 32768
+
+/* Maximum value the semaphore can have. */
+#define SEM_VALUE_MAX (2147483647)
diff --git a/libc/sysdeps/linux/powerpc/bits/mathdef.h b/libc/sysdeps/linux/powerpc/bits/mathdef.h
index f28bacece..2c0cad116 100644
--- a/libc/sysdeps/linux/powerpc/bits/mathdef.h
+++ b/libc/sysdeps/linux/powerpc/bits/mathdef.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <features.h>
@@ -33,32 +32,12 @@
#if defined __USE_ISOC99 && defined _MATH_H && !defined _MATH_H_MATHDEF
# define _MATH_H_MATHDEF 1
-# ifdef __GNUC__
-# if __STDC__ == 1
-
-/* In GNU or ANSI mode, gcc leaves `float' expressions as-is. */
+/* PowerPC has both `float' and `double' arithmetic. */
typedef float float_t; /* `float' expressions are evaluated as
`float'. */
typedef double double_t; /* `double' expressions are evaluated as
`double'. */
-# else
-
-/* For `gcc -traditional', `float' expressions are evaluated as `double'. */
-typedef double float_t; /* `float' expressions are evaluated as
- `double'. */
-typedef double double_t; /* `double' expressions are evaluated as
- `double'. */
-
-# endif
-# else
-
-/* Wild guess at types for float_t and double_t. */
-typedef double float_t;
-typedef double double_t;
-
-# endif
-
/* The values returned by `ilogb' for 0 and NaN respectively. */
# define FP_ILOGB0 (-2147483647)
# define FP_ILOGBNAN (2147483647)
@@ -66,12 +45,9 @@ typedef double double_t;
#endif /* ISO C99 */
#ifndef __NO_LONG_DOUBLE_MATH
-#include <bits/wordsize.h>
/* Signal that we do not really have a `long double'. The disables the
declaration of all the `long double' function variants. */
-# if __WORDSIZE == 32
-# define __NO_LONG_DOUBLE_MATH 1
-# elif !defined __UCLIBC_HAS_LONG_DOUBLE_MATH__
+# if !defined __UCLIBC_HAS_LONG_DOUBLE_MATH__
# define __NO_LONG_DOUBLE_MATH 1
-# endif /* __WORDSIZE == 32 */
+# endif
#endif /* __NO_LONG_DOUBLE_MATH */
diff --git a/libc/sysdeps/linux/powerpc/bits/mathinline.h b/libc/sysdeps/linux/powerpc/bits/mathinline.h
index d1b05f388..206ca977e 100644
--- a/libc/sysdeps/linux/powerpc/bits/mathinline.h
+++ b/libc/sysdeps/linux/powerpc/bits/mathinline.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <features.h>
@@ -27,7 +26,7 @@
#ifdef __cplusplus
# define __MATH_INLINE __inline
#else
-# define __MATH_INLINE extern __inline
+# define __MATH_INLINE __extern_inline
#endif /* __cplusplus */
#if defined __GNUC__ && !defined _SOFT_FLOAT
diff --git a/libc/sysdeps/linux/powerpc/bits/mman.h b/libc/sysdeps/linux/powerpc/bits/mman.h
index e03ab7ff8..c39e7929d 100644
--- a/libc/sysdeps/linux/powerpc/bits/mman.h
+++ b/libc/sysdeps/linux/powerpc/bits/mman.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_MMAN_H
# error "Never use <bits/mman.h> directly; iclude <sys/mman.h> instead."
@@ -63,6 +62,8 @@
# define MAP_NORESERVE 0x00040 /* Don't check for reservations. */
# define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */
# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */
+# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could
+ be uninitialized. */
#endif
/* Flags to `msync'. */
diff --git a/libc/sysdeps/linux/powerpc/bits/msq.h b/libc/sysdeps/linux/powerpc/bits/msq.h
index f19884437..70d4f06e3 100644
--- a/libc/sysdeps/linux/powerpc/bits/msq.h
+++ b/libc/sysdeps/linux/powerpc/bits/msq.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_MSG_H
# error "Never use <bits/msq.h> directly; include <sys/msg.h> instead."
diff --git a/libc/sysdeps/linux/powerpc/bits/sem.h b/libc/sysdeps/linux/powerpc/bits/sem.h
index 92a7a9043..271a607ca 100644
--- a/libc/sysdeps/linux/powerpc/bits/sem.h
+++ b/libc/sysdeps/linux/powerpc/bits/sem.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_SEM_H
# error "Never include <bits/sem.h> directly; use <sys/sem.h> instead."
diff --git a/libc/sysdeps/linux/powerpc/bits/setjmp.h b/libc/sysdeps/linux/powerpc/bits/setjmp.h
index dad90c74c..46e8bf7d1 100644
--- a/libc/sysdeps/linux/powerpc/bits/setjmp.h
+++ b/libc/sysdeps/linux/powerpc/bits/setjmp.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997, 1998, 2000, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 1997,1998,2000,2003,2004,2005,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
@@ -12,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* Define the machine-dependent type `jmp_buf'. PowerPC version. */
#ifndef _BITS_SETJMP_H
@@ -31,30 +31,6 @@
#include <bits/wordsize.h>
-#if defined __USE_MISC || defined _ASM
-# define JB_GPR1 0 /* Also known as the stack pointer */
-# define JB_GPR2 1
-# define JB_LR 2 /* The address we will return to */
-# if __WORDSIZE == 64
-# define JB_GPRS 3 /* GPRs 14 through 31 are saved, 18*2 words total. */
-# define JB_CR 21 /* Condition code registers with the VRSAVE at */
- /* offset 172 (low half of the double word. */
-# define JB_FPRS 22 /* FPRs 14 through 31 are saved, 18*2 words total. */
-# define JB_SIZE (64 * 8) /* As per PPC64-VMX ABI. */
-# define JB_VRSAVE 21 /* VRSAVE shares a double word with the CR at offset */
- /* 168 (high half of the double word). */
-# define JB_VRS 40 /* VRs 20 through 31 are saved, 12*4 words total. */
-# else
-# define JB_GPRS 3 /* GPRs 14 through 31 are saved, 18 in total. */
-# define JB_CR 21 /* Condition code registers. */
-# define JB_FPRS 22 /* FPRs 14 through 31 are saved, 18*2 words total. */
-# define JB_SIZE ((64 + (12 * 4)) * 4)
-# define JB_VRSAVE 62
-# define JB_VRS 64
-# endif
-#endif
-
-
/* The current powerpc 32-bit Altivec ABI specifies for SVR4 ABI and EABI
the vrsave must be at byte 248 & v20 at byte 256. So we must pad this
correctly on 32 bit. It also insists that vecregs are only gauranteed
@@ -62,19 +38,12 @@
We have to version the code because members like int __mask_was_saved
in the jmp_buf will move as jmp_buf is now larger than 248 bytes. We
cannot keep the altivec jmp_buf backward compatible with the jmp_buf. */
-#ifndef _ASM
-# if __WORDSIZE == 64
+#if __WORDSIZE == 64
typedef long int __jmp_buf[64] __attribute__ ((__aligned__ (16)));
-# else
+#else
/* The alignment is not essential, i.e.the buffer can be copied to a 4 byte
aligned buffer as per the ABI it is just added for performance reasons. */
typedef long int __jmp_buf[64 + (12 * 4)] __attribute__ ((__aligned__ (16)));
-# endif
#endif
-/* Test if longjmp to JMPBUF would unwind the frame
- containing a local variable at ADDRESS. */
-#define _JMPBUF_UNWINDS(jmpbuf, address) \
- ((void *) (address) < (void *) (jmpbuf)[JB_GPR1])
-
-#endif /* bits/setjmp.h */
+#endif /* bits/setjmp.h */
diff --git a/libc/sysdeps/linux/powerpc/bits/shm.h b/libc/sysdeps/linux/powerpc/bits/shm.h
index 62560c0ca..63e7f6ed1 100644
--- a/libc/sysdeps/linux/powerpc/bits/shm.h
+++ b/libc/sysdeps/linux/powerpc/bits/shm.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_SHM_H
# error "Never include <bits/shm.h> directly; use <sys/shm.h> instead."
diff --git a/libc/sysdeps/linux/powerpc/bits/sigcontextinfo.h b/libc/sysdeps/linux/powerpc/bits/sigcontextinfo.h
index 138a15cfa..8f95d3137 100644
--- a/libc/sysdeps/linux/powerpc/bits/sigcontextinfo.h
+++ b/libc/sysdeps/linux/powerpc/bits/sigcontextinfo.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <signal.h>
diff --git a/libc/sysdeps/linux/powerpc/bits/stackinfo.h b/libc/sysdeps/linux/powerpc/bits/stackinfo.h
index 839758a4e..08b0a69bb 100644
--- a/libc/sysdeps/linux/powerpc/bits/stackinfo.h
+++ b/libc/sysdeps/linux/powerpc/bits/stackinfo.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* This file contains a bit of information about the stack allocation
of the processor. */
diff --git a/libc/sysdeps/linux/powerpc/bits/stat.h b/libc/sysdeps/linux/powerpc/bits/stat.h
index f4a8de14b..10fa2cbf7 100644
--- a/libc/sysdeps/linux/powerpc/bits/stat.h
+++ b/libc/sysdeps/linux/powerpc/bits/stat.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
+/* Copyright (C) 1992, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2009
Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_STAT_H
# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
@@ -69,7 +68,7 @@ struct stat
# else
__blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
# endif
-#if 0 /*def __USE_MISC*/
+#ifdef __USE_MISC
/* Nanosecond resolution timestamps are stored in a format
equivalent to 'struct timespec'. This is the type used
whenever possible but the Unix namespace rules do not allow the
@@ -109,7 +108,7 @@ struct stat64
__off64_t st_size; /* Size of file, in bytes. */
__blksize_t st_blksize; /* Optimal block size for I/O. */
__blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
-#if 0 /*def __USE_MISC*/
+#ifdef __USE_MISC
/* Nanosecond resolution timestamps are stored in a format
equivalent to 'struct timespec'. This is the type used
whenever possible but the Unix namespace rules do not allow the
@@ -163,7 +162,7 @@ struct stat
# else
__blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
# endif
-#if 0 /*def __USE_MISC*/
+#ifdef __USE_MISC
/* Nanosecond resolution timestamps are stored in a format
equivalent to 'struct timespec'. This is the type used
whenever possible but the Unix namespace rules do not allow the
@@ -203,7 +202,7 @@ struct stat64
__off64_t st_size; /* Size of file, in bytes. */
__blksize_t st_blksize; /* Optimal block size for I/O. */
__blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
-#if 0 /*def __USE_MISC*/
+#ifdef __USE_MISC
/* Nanosecond resolution timestamps are stored in a format
equivalent to 'struct timespec'. This is the type used
whenever possible but the Unix namespace rules do not allow the
@@ -265,3 +264,8 @@ struct stat64
#define __S_IREAD 0400 /* Read by owner. */
#define __S_IWRITE 0200 /* Write by owner. */
#define __S_IEXEC 0100 /* Execute by owner. */
+
+#ifdef __USE_ATFILE
+# define UTIME_NOW ((1l << 30) - 1l)
+# define UTIME_OMIT ((1l << 30) - 2l)
+#endif
diff --git a/libc/sysdeps/linux/powerpc/bits/syscalls.h b/libc/sysdeps/linux/powerpc/bits/syscalls.h
index d233cc7d6..c52d5dd5b 100644
--- a/libc/sysdeps/linux/powerpc/bits/syscalls.h
+++ b/libc/sysdeps/linux/powerpc/bits/syscalls.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _BITS_SYSCALLS_H
#define _BITS_SYSCALLS_H
@@ -22,12 +21,6 @@
#ifndef _SYSCALL_H
# error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
#endif
-/* For Linux we can use the system call table in the header file
- /usr/include/asm/unistd.h
- of the kernel. But these symbols do not follow the SYS_* syntax
- so we have to redefine the `SYS_ify' macro here. */
-#undef SYS_ify
-#define SYS_ify(syscall_name) __NR_##syscall_name
#ifndef __ASSEMBLER__
@@ -122,7 +115,7 @@
register long int r10 __asm__ ("r10"); \
register long int r11 __asm__ ("r11"); \
register long int r12 __asm__ ("r12"); \
- LOADARGS_##nr (funcptr, args); \
+ LOAD_ARGS_##nr (funcptr, args); \
__asm__ __volatile__ \
("mtctr %0\n\t" \
"bctrl\n\t" \
@@ -136,19 +129,6 @@
(int) r3; \
})
-# undef INLINE_SYSCALL
-# define INLINE_SYSCALL(name, nr, args...) \
- ({ \
- INTERNAL_SYSCALL_DECL (sc_err); \
- long int sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, args); \
- if (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \
- { \
- __set_errno (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err)); \
- sc_ret = -1L; \
- } \
- sc_ret; \
- })
-
/* Define a macro which expands inline into the wrapper code for a system
call. This use is for internal calls that do not need to handle errors
normally. It will never touch errno.
@@ -157,11 +137,10 @@
"sc; bnslr+" sequence) and CR (where only CR0.SO is clobbered to signal
an error return status). */
-# undef INTERNAL_SYSCALL_DECL
# define INTERNAL_SYSCALL_DECL(err) long int err
-# undef INTERNAL_SYSCALL
# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+(__extension__ \
({ \
register long int r0 __asm__ ("r0"); \
register long int r3 __asm__ ("r3"); \
@@ -174,7 +153,7 @@
register long int r10 __asm__ ("r10"); \
register long int r11 __asm__ ("r11"); \
register long int r12 __asm__ ("r12"); \
- LOADARGS_##nr(name, args); \
+ LOAD_ARGS_##nr(name, args); \
__asm__ __volatile__ \
("sc \n\t" \
"mfcr %0" \
@@ -185,58 +164,55 @@
: "cr0", "ctr", "memory"); \
err = r0; \
(int) r3; \
- })
-# define INTERNAL_SYSCALL(name, err, nr, args...) \
- INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
-
-# undef INTERNAL_SYSCALL_ERROR_P
+ }) \
+)
# define INTERNAL_SYSCALL_ERROR_P(val, err) \
- ((void) (val), __builtin_expect ((err) & (1 << 28), 0))
+ ((void) (val), unlikely ((err) & (1 << 28)))
-# undef INTERNAL_SYSCALL_ERRNO
# define INTERNAL_SYSCALL_ERRNO(val, err) (val)
-# define LOADARGS_0(name, dummy) \
+extern void __illegally_sized_syscall_arg1(void);
+extern void __illegally_sized_syscall_arg2(void);
+extern void __illegally_sized_syscall_arg3(void);
+extern void __illegally_sized_syscall_arg4(void);
+extern void __illegally_sized_syscall_arg5(void);
+extern void __illegally_sized_syscall_arg6(void);
+
+# define LOAD_ARGS_0(name, dummy) \
r0 = name
-# define LOADARGS_1(name, __arg1) \
- long int arg1 = (long int) (__arg1); \
- LOADARGS_0(name, 0); \
- extern void __illegally_sized_syscall_arg1 (void); \
+# define LOAD_ARGS_1(name, __arg1) \
+ long int arg1 = (long int) (__arg1); \
+ LOAD_ARGS_0(name, 0); \
if (__builtin_classify_type (__arg1) != 5 && sizeof (__arg1) > 4) \
__illegally_sized_syscall_arg1 (); \
r3 = arg1
-# define LOADARGS_2(name, __arg1, __arg2) \
+# define LOAD_ARGS_2(name, __arg1, __arg2) \
long int arg2 = (long int) (__arg2); \
- LOADARGS_1(name, __arg1); \
- extern void __illegally_sized_syscall_arg2 (void); \
+ LOAD_ARGS_1(name, __arg1); \
if (__builtin_classify_type (__arg2) != 5 && sizeof (__arg2) > 4) \
__illegally_sized_syscall_arg2 (); \
r4 = arg2
-# define LOADARGS_3(name, __arg1, __arg2, __arg3) \
+# define LOAD_ARGS_3(name, __arg1, __arg2, __arg3) \
long int arg3 = (long int) (__arg3); \
- LOADARGS_2(name, __arg1, __arg2); \
- extern void __illegally_sized_syscall_arg3 (void); \
+ LOAD_ARGS_2(name, __arg1, __arg2); \
if (__builtin_classify_type (__arg3) != 5 && sizeof (__arg3) > 4) \
__illegally_sized_syscall_arg3 (); \
r5 = arg3
-# define LOADARGS_4(name, __arg1, __arg2, __arg3, __arg4) \
+# define LOAD_ARGS_4(name, __arg1, __arg2, __arg3, __arg4) \
long int arg4 = (long int) (__arg4); \
- LOADARGS_3(name, __arg1, __arg2, __arg3); \
- extern void __illegally_sized_syscall_arg4 (void); \
+ LOAD_ARGS_3(name, __arg1, __arg2, __arg3); \
if (__builtin_classify_type (__arg4) != 5 && sizeof (__arg4) > 4) \
__illegally_sized_syscall_arg4 (); \
r6 = arg4
-# define LOADARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5) \
+# define LOAD_ARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5) \
long int arg5 = (long int) (__arg5); \
- LOADARGS_4(name, __arg1, __arg2, __arg3, __arg4); \
- extern void __illegally_sized_syscall_arg5 (void); \
+ LOAD_ARGS_4(name, __arg1, __arg2, __arg3, __arg4); \
if (__builtin_classify_type (__arg5) != 5 && sizeof (__arg5) > 4) \
__illegally_sized_syscall_arg5 (); \
r7 = arg5
-# define LOADARGS_6(name, __arg1, __arg2, __arg3, __arg4, __arg5, __arg6) \
+# define LOAD_ARGS_6(name, __arg1, __arg2, __arg3, __arg4, __arg5, __arg6) \
long int arg6 = (long int) (__arg6); \
- LOADARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5); \
- extern void __illegally_sized_syscall_arg6 (void); \
+ LOAD_ARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5); \
if (__builtin_classify_type (__arg6) != 5 && sizeof (__arg6) > 4) \
__illegally_sized_syscall_arg6 (); \
r8 = arg6
@@ -249,49 +225,6 @@
# define ASM_INPUT_5 ASM_INPUT_4, "5" (r7)
# define ASM_INPUT_6 ASM_INPUT_5, "6" (r8)
-
-#undef _syscall0
-#define _syscall0(type,name) \
-type name(void){ \
- return (type) INLINE_SYSCALL(name, 0); \
-}
-
-#undef _syscall1
-#define _syscall1(type,name,type1,arg1) \
-type name(type1 arg1){ \
- return (type) INLINE_SYSCALL(name, 1, arg1); \
-}
-
-#undef _syscall2
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name(type1 arg1, type2 arg2){ \
- return (type) INLINE_SYSCALL(name, 2, arg1, arg2); \
-}
-
-#undef _syscall3
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name(type1 arg1, type2 arg2, type3 arg3){ \
- return (type) INLINE_SYSCALL(name, 3, arg1, arg2, arg3); \
-}
-
-#undef _syscall4
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4){ \
- return (type) INLINE_SYSCALL(name, 4, arg1, arg2, arg3, arg4); \
-}
-
-#undef _syscall5
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5){ \
- return (type) INLINE_SYSCALL(name, 5, arg1, arg2, arg3, arg4, arg5); \
-}
-
-#undef _syscall6
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6){ \
- return (type) INLINE_SYSCALL(name, 6, arg1, arg2, arg3, arg4, arg5, arg6); \
-}
-
#endif /* __ASSEMBLER__ */
diff --git a/libc/sysdeps/linux/powerpc/bits/sysdep.h b/libc/sysdeps/linux/powerpc/bits/sysdep.h
deleted file mode 100644
index c42efbabd..000000000
--- a/libc/sysdeps/linux/powerpc/bits/sysdep.h
+++ /dev/null
@@ -1,301 +0,0 @@
-/* Copyright (C) 1992,1997-2003,2004,2005,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 _LINUX_POWERPC_SYSDEP_H
-#define _LINUX_POWERPC_SYSDEP_H 1
-
-#include <sysdeps/unix/powerpc/sysdep.h>
-#include <tls.h>
-
-/* Some systen calls got renamed over time, but retained the same semantics.
- Handle them here so they can be catched by both C and assembler stubs in
- glibc. */
-
-#ifdef __NR_pread64
-# ifdef __NR_pread
-# error "__NR_pread and __NR_pread64 both defined???"
-# endif
-# define __NR_pread __NR_pread64
-#endif
-
-#ifdef __NR_pwrite64
-# ifdef __NR_pwrite
-# error "__NR_pwrite and __NR_pwrite64 both defined???"
-# endif
-# define __NR_pwrite __NR_pwrite64
-#endif
-
-/* For Linux we can use the system call table in the header file
- /usr/include/asm/unistd.h
- of the kernel. But these symbols do not follow the SYS_* syntax
- so we have to redefine the `SYS_ify' macro here. */
-#undef SYS_ify
-#ifdef __STDC__
-# define SYS_ify(syscall_name) __NR_##syscall_name
-#else
-# define SYS_ify(syscall_name) __NR_/**/syscall_name
-#endif
-
-#ifndef __ASSEMBLER__
-
-# include <errno.h>
-
-# ifdef SHARED
-# define INLINE_VSYSCALL(name, nr, args...) \
- ({ \
- __label__ out; \
- __label__ iserr; \
- INTERNAL_SYSCALL_DECL (sc_err); \
- long int sc_ret; \
- \
- if (__vdso_##name != NULL) \
- { \
- sc_ret = INTERNAL_VSYSCALL_NCS (__vdso_##name, sc_err, nr, ##args); \
- if (!INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \
- goto out; \
- if (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err) != ENOSYS) \
- goto iserr; \
- } \
- \
- sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, ##args); \
- if (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \
- { \
- iserr: \
- __set_errno (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err)); \
- sc_ret = -1L; \
- } \
- out: \
- sc_ret; \
- })
-# else
-# define INLINE_VSYSCALL(name, nr, args...) \
- INLINE_SYSCALL (name, nr, ##args)
-# endif
-
-# ifdef SHARED
-# define INTERNAL_VSYSCALL(name, err, nr, args...) \
- ({ \
- __label__ out; \
- long int v_ret; \
- \
- if (__vdso_##name != NULL) \
- { \
- v_ret = INTERNAL_VSYSCALL_NCS (__vdso_##name, err, nr, ##args); \
- if (!INTERNAL_SYSCALL_ERROR_P (v_ret, err) \
- || INTERNAL_SYSCALL_ERRNO (v_ret, err) != ENOSYS) \
- goto out; \
- } \
- v_ret = INTERNAL_SYSCALL (name, err, nr, ##args); \
- out: \
- v_ret; \
- })
-# else
-# define INTERNAL_VSYSCALL(name, err, nr, args...) \
- INTERNAL_SYSCALL (name, err, nr, ##args)
-# endif
-
-# define INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK(name, err, nr, args...) \
- ({ \
- long int sc_ret = ENOSYS; \
- \
- if (__vdso_##name != NULL) \
- sc_ret = INTERNAL_VSYSCALL_NCS (__vdso_##name, err, nr, ##args); \
- else \
- err = 1 << 28; \
- sc_ret; \
- })
-
-/* List of system calls which are supported as vsyscalls. */
-# define HAVE_CLOCK_GETRES_VSYSCALL 1
-# define HAVE_CLOCK_GETTIME_VSYSCALL 1
-
-/* Define a macro which expands inline into the wrapper code for a VDSO
- call. This use is for internal calls that do not need to handle errors
- normally. It will never touch errno.
- On powerpc a system call basically clobbers the same registers like a
- function call, with the exception of LR (which is needed for the
- "sc; bnslr+" sequence) and CR (where only CR0.SO is clobbered to signal
- an error return status). */
-# define INTERNAL_VSYSCALL_NCS(funcptr, err, nr, args...) \
- ({ \
- register void *r0 __asm__ ("r0"); \
- register long int r3 __asm__ ("r3"); \
- register long int r4 __asm__ ("r4"); \
- register long int r5 __asm__ ("r5"); \
- register long int r6 __asm__ ("r6"); \
- register long int r7 __asm__ ("r7"); \
- register long int r8 __asm__ ("r8"); \
- register long int r9 __asm__ ("r9"); \
- register long int r10 __asm__ ("r10"); \
- register long int r11 __asm__ ("r11"); \
- register long int r12 __asm__ ("r12"); \
- LOADARGS_##nr (funcptr, args); \
- __asm__ __volatile__ \
- ("mtctr %0\n\t" \
- "bctrl\n\t" \
- "mfcr %0" \
- : "=&r" (r0), \
- "=&r" (r3), "=&r" (r4), "=&r" (r5), "=&r" (r6), "=&r" (r7), \
- "=&r" (r8), "=&r" (r9), "=&r" (r10), "=&r" (r11), "=&r" (r12) \
- : ASM_INPUT_##nr \
- : "cr0", "ctr", "lr", "memory"); \
- err = (long int) r0; \
- (int) r3; \
- })
-
-# undef INLINE_SYSCALL
-# define INLINE_SYSCALL(name, nr, args...) \
- ({ \
- INTERNAL_SYSCALL_DECL (sc_err); \
- long int sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, args); \
- if (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \
- { \
- __set_errno (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err)); \
- sc_ret = -1L; \
- } \
- sc_ret; \
- })
-
-/* Define a macro which expands inline into the wrapper code for a system
- call. This use is for internal calls that do not need to handle errors
- normally. It will never touch errno.
- On powerpc a system call basically clobbers the same registers like a
- function call, with the exception of LR (which is needed for the
- "sc; bnslr+" sequence) and CR (where only CR0.SO is clobbered to signal
- an error return status). */
-
-# undef INTERNAL_SYSCALL_DECL
-# define INTERNAL_SYSCALL_DECL(err) long int err
-
-# undef INTERNAL_SYSCALL
-# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
- ({ \
- register long int r0 __asm__ ("r0"); \
- register long int r3 __asm__ ("r3"); \
- register long int r4 __asm__ ("r4"); \
- register long int r5 __asm__ ("r5"); \
- register long int r6 __asm__ ("r6"); \
- register long int r7 __asm__ ("r7"); \
- register long int r8 __asm__ ("r8"); \
- register long int r9 __asm__ ("r9"); \
- register long int r10 __asm__ ("r10"); \
- register long int r11 __asm__ ("r11"); \
- register long int r12 __asm__ ("r12"); \
- LOADARGS_##nr(name, args); \
- __asm__ __volatile__ \
- ("sc \n\t" \
- "mfcr %0" \
- : "=&r" (r0), \
- "=&r" (r3), "=&r" (r4), "=&r" (r5), "=&r" (r6), "=&r" (r7), \
- "=&r" (r8), "=&r" (r9), "=&r" (r10), "=&r" (r11), "=&r" (r12) \
- : ASM_INPUT_##nr \
- : "cr0", "ctr", "memory"); \
- err = r0; \
- (int) r3; \
- })
-# define INTERNAL_SYSCALL(name, err, nr, args...) \
- INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
-
-# undef INTERNAL_SYSCALL_ERROR_P
-# define INTERNAL_SYSCALL_ERROR_P(val, err) \
- ((void) (val), __builtin_expect ((err) & (1 << 28), 0))
-
-# undef INTERNAL_SYSCALL_ERRNO
-# define INTERNAL_SYSCALL_ERRNO(val, err) (val)
-
-# define LOADARGS_0(name, dummy) \
- r0 = name
-# define LOADARGS_1(name, __arg1) \
- long int arg1 = (long int) (__arg1); \
- LOADARGS_0(name, 0); \
- extern void __illegally_sized_syscall_arg1 (void); \
- if (__builtin_classify_type (__arg1) != 5 && sizeof (__arg1) > 4) \
- __illegally_sized_syscall_arg1 (); \
- r3 = arg1
-# define LOADARGS_2(name, __arg1, __arg2) \
- long int arg2 = (long int) (__arg2); \
- LOADARGS_1(name, __arg1); \
- extern void __illegally_sized_syscall_arg2 (void); \
- if (__builtin_classify_type (__arg2) != 5 && sizeof (__arg2) > 4) \
- __illegally_sized_syscall_arg2 (); \
- r4 = arg2
-# define LOADARGS_3(name, __arg1, __arg2, __arg3) \
- long int arg3 = (long int) (__arg3); \
- LOADARGS_2(name, __arg1, __arg2); \
- extern void __illegally_sized_syscall_arg3 (void); \
- if (__builtin_classify_type (__arg3) != 5 && sizeof (__arg3) > 4) \
- __illegally_sized_syscall_arg3 (); \
- r5 = arg3
-# define LOADARGS_4(name, __arg1, __arg2, __arg3, __arg4) \
- long int arg4 = (long int) (__arg4); \
- LOADARGS_3(name, __arg1, __arg2, __arg3); \
- extern void __illegally_sized_syscall_arg4 (void); \
- if (__builtin_classify_type (__arg4) != 5 && sizeof (__arg4) > 4) \
- __illegally_sized_syscall_arg4 (); \
- r6 = arg4
-# define LOADARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5) \
- long int arg5 = (long int) (__arg5); \
- LOADARGS_4(name, __arg1, __arg2, __arg3, __arg4); \
- extern void __illegally_sized_syscall_arg5 (void); \
- if (__builtin_classify_type (__arg5) != 5 && sizeof (__arg5) > 4) \
- __illegally_sized_syscall_arg5 (); \
- r7 = arg5
-# define LOADARGS_6(name, __arg1, __arg2, __arg3, __arg4, __arg5, __arg6) \
- long int arg6 = (long int) (__arg6); \
- LOADARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5); \
- extern void __illegally_sized_syscall_arg6 (void); \
- if (__builtin_classify_type (__arg6) != 5 && sizeof (__arg6) > 4) \
- __illegally_sized_syscall_arg6 (); \
- r8 = arg6
-
-# define ASM_INPUT_0 "0" (r0)
-# define ASM_INPUT_1 ASM_INPUT_0, "1" (r3)
-# define ASM_INPUT_2 ASM_INPUT_1, "2" (r4)
-# define ASM_INPUT_3 ASM_INPUT_2, "3" (r5)
-# define ASM_INPUT_4 ASM_INPUT_3, "4" (r6)
-# define ASM_INPUT_5 ASM_INPUT_4, "5" (r7)
-# define ASM_INPUT_6 ASM_INPUT_5, "6" (r8)
-
-#endif /* __ASSEMBLER__ */
-
-
-/* Pointer mangling support. */
-#if defined NOT_IN_libc && defined IS_IN_rtld
-/* We cannot use the thread descriptor because in ld.so we use setjmp
- earlier than the descriptor is initialized. */
-#else
-# ifdef __ASSEMBLER__
-# define PTR_MANGLE(reg, tmpreg) \
- lwz tmpreg,POINTER_GUARD(r2); \
- xor reg,tmpreg,reg
-# define PTR_MANGLE2(reg, tmpreg) \
- xor reg,tmpreg,reg
-# define PTR_MANGLE3(destreg, reg, tmpreg) \
- lwz tmpreg,POINTER_GUARD(r2); \
- xor destreg,tmpreg,reg
-# define PTR_DEMANGLE(reg, tmpreg) PTR_MANGLE (reg, tmpreg)
-# define PTR_DEMANGLE2(reg, tmpreg) PTR_MANGLE2 (reg, tmpreg)
-# define PTR_DEMANGLE3(destreg, reg, tmpreg) PTR_MANGLE3 (destreg, reg, tmpreg)
-# else
-# define PTR_MANGLE(var) \
- (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
-# define PTR_DEMANGLE(var) PTR_MANGLE (var)
-# endif
-#endif
-
-#endif /* linux/powerpc/powerpc32/sysdep.h */
diff --git a/libc/sysdeps/linux/powerpc/bits/termios.h b/libc/sysdeps/linux/powerpc/bits/termios.h
index 7aac02dc5..ffd99a5e2 100644
--- a/libc/sysdeps/linux/powerpc/bits/termios.h
+++ b/libc/sysdeps/linux/powerpc/bits/termios.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _TERMIOS_H
# error "Never include <bits/termios.h> directly; use <termios.h> instead."
@@ -220,6 +219,7 @@ struct termios {
#define TCSADRAIN 1
#define TCSAFLUSH 2
+#ifndef __UCLIBC_STRICT_HEADERS__
struct sgttyb {
char sg_ispeed;
char sg_ospeed;
@@ -227,6 +227,7 @@ struct sgttyb {
char sg_kill;
short sg_flags;
};
+#endif
struct tchars {
char t_intrc;
diff --git a/libc/sysdeps/linux/powerpc/bits/uClibc_arch_features.h b/libc/sysdeps/linux/powerpc/bits/uClibc_arch_features.h
index a3f11df31..661069384 100644
--- a/libc/sysdeps/linux/powerpc/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/powerpc/bits/uClibc_arch_features.h
@@ -11,32 +11,31 @@
/* can your target use syscall6() for mmap ? */
#define __UCLIBC_MMAP_HAS_6_ARGS__
-/* does your target use syscall4() for truncate64 ? (32bit arches only) */
-#define __UCLIBC_TRUNCATE64_HAS_4_ARGS__
+/* does your target align 64bit values in register pairs ? (32bit arches only) */
+#define __UCLIBC_SYSCALL_ALIGN_64BIT__
/* does your target have a broken create_module() ? */
#undef __UCLIBC_BROKEN_CREATE_MODULE__
/* does your target have to worry about older [gs]etrlimit() ? */
-/* this is only an issue on i386 where linux < 2.3.35, so we just assume it works ... */
#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 */
+#undef __UCLIBC_ASM_LINE_SEP__
+
#endif /* _BITS_UCLIBC_ARCH_FEATURES_H */
diff --git a/libc/sysdeps/linux/powerpc/bits/wordsize.h b/libc/sysdeps/linux/powerpc/bits/wordsize.h
index cf934234f..3e8a1e0a1 100644
--- a/libc/sysdeps/linux/powerpc/bits/wordsize.h
+++ b/libc/sysdeps/linux/powerpc/bits/wordsize.h
@@ -2,7 +2,7 @@
#if defined __powerpc64__
# define __WORDSIZE 64
-# define __WORDSIZE_COMPAT32 1
+# define __WORDSIZE_TIME64_COMPAT32 1
#else
# define __WORDSIZE 32
#endif
diff --git a/libc/sysdeps/linux/powerpc/brk.S b/libc/sysdeps/linux/powerpc/brk.S
index 5fe8d4086..83a8c7955 100644
--- a/libc/sysdeps/linux/powerpc/brk.S
+++ b/libc/sysdeps/linux/powerpc/brk.S
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <features.h>
#include "ppc_asm.h"
diff --git a/libc/sysdeps/linux/powerpc/bsd-_setjmp.S b/libc/sysdeps/linux/powerpc/bsd-_setjmp.S
index 585878acf..f07bd9160 100644
--- a/libc/sysdeps/linux/powerpc/bsd-_setjmp.S
+++ b/libc/sysdeps/linux/powerpc/bsd-_setjmp.S
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* This just does a tail-call to `__sigsetjmp (ARG, 0)'.
We cannot do it in C because it must be a tail-call, so frame-unwinding
diff --git a/libc/sysdeps/linux/powerpc/bsd-setjmp.S b/libc/sysdeps/linux/powerpc/bsd-setjmp.S
index f95d08217..0b4e757d2 100644
--- a/libc/sysdeps/linux/powerpc/bsd-setjmp.S
+++ b/libc/sysdeps/linux/powerpc/bsd-setjmp.S
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* This just does a tail-call to `__sigsetjmp (ARG, 1)'.
We cannot do it in C because it must be a tail-call, so frame-unwinding
diff --git a/libc/sysdeps/linux/powerpc/clone.S b/libc/sysdeps/linux/powerpc/clone.S
index 15d03f679..8efbbda1a 100644
--- a/libc/sysdeps/linux/powerpc/clone.S
+++ b/libc/sysdeps/linux/powerpc/clone.S
@@ -13,29 +13,31 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <features.h>
-#include "ppc_asm.h"
#define _ERRNO_H 1
#include <bits/errno.h>
-#include <sys/syscall.h>
+#include <sysdep.h>
+
+#define CLONE_VM 0x00000100
+#define CLONE_THREAD 0x00010000
/* This is the only really unusual system call in PPC linux, but not
because of any weirdness in the system call itself; because of
all the freaky stuff we have to do to make the call useful. */
/* int [r3] clone(int (*fn)(void *arg) [r3], void *child_stack [r4],
- int flags [r5], void *arg [r6]); */
+ int flags [r5], void *arg [r6], void *parent_tid [r7],
+ void *tls [r8], void *child_tid [r9]); */
#ifdef __NR_clone
- .globl clone
- .type clone,@function
+ .globl __clone
+ .type __clone,@function
.align 2
-clone:
+__clone:
/* Check for child_stack == NULL || fn == NULL. */
cmpwi cr0,r4,0
cmpwi cr1,r3,0
@@ -44,22 +46,44 @@ clone:
/* Set up stack frame for parent. */
stwu r1,-32(r1)
+ cfi_adjust_cfa_offset (32)
+#ifdef RESET_PID
+ stmw r28,16(r1)
+#else
+# ifndef __ASSUME_FIXED_CLONE_SYSCALL
stmw r29,16(r1)
-
+# else
+ stmw r30,16(r1)
+# endif
+#endif
+
/* Set up stack frame for child. */
clrrwi r4,r4,4
li r0,0
stwu r0,-16(r4)
/* Save fn, args, stack across syscall. */
- mr r29,r3 /* Function in r29. */
- mr r30,r4 /* Stack pointer in r30. */
+ mr r30,r3 /* Function in r30. */
+#ifndef __ASSUME_FIXED_CLONE_SYSCALL
+ mr r29,r4 /* Stack pointer in r29. */
+#endif
+#ifdef RESET_PID
+ mr r28,r5
+#endif
mr r31,r6 /* Argument in r31. */
/* 'flags' argument is first parameter to clone syscall. (The other
argument is the stack pointer, already in r4.) */
mr r3,r5
+ /* Move the parent_tid, child_tid and tls arguments. */
+ mr r5,r7
+ mr r6,r8
+ mr r7,r9
+
+ /* End FDE now, because in the child the unwind info will be wrong. */
+ cfi_endproc
+
/* Do the call. */
li 0, __NR_clone
sc
@@ -69,13 +93,27 @@ clone:
crandc cr1*4+eq,cr1*4+eq,cr0*4+so
bne- cr1,.Lparent /* The '-' is to minimise the race. */
+#ifndef __ASSUME_FIXED_CLONE_SYSCALL
/* On at least mklinux DR3a5, clone() doesn't actually change
the stack pointer. I'm pretty sure this is a bug, because
it adds a race condition if a signal is sent to a thread
just after it is created (in the previous three instructions). */
- mr r1,r30
+ mr r1,r29
+#endif
+
+#ifdef RESET_PID
+ andis. r0,r28,CLONE_THREAD>>16
+ bne+ r0,.Loldpid
+ andi. r0,r28,CLONE_VM
+ li r3,-1
+ bne- r0,.Lnomoregetpid
+.Lnomoregetpid:
+ stw r3,TID(r2)
+ stw r3,PID(r2)
+.Loldpid:
+#endif
/* Call procedure. */
- mtctr r29
+ mtctr r30
mr r3,r31
bctrl
/* Call _exit with result from procedure. */
@@ -83,16 +121,24 @@ clone:
.Lparent:
/* Parent. Restore registers & return. */
+#ifdef RESET_PID
+ lmw r28,16(r1)
+#else
+# ifndef __ASSUME_FIXED_CLONE_SYSCALL
lmw r29,16(r1)
+# else
+ lmw r30,16(r1)
+# endif
+#endif
addi r1,r1,32
bnslr+
-
b __syscall_error
.Lbadargs:
li r3,EINVAL
-
b __syscall_error
- .size clone,.-clone
+ cfi_startproc
+ .size __clone,.-__clone
+weak_alias(__clone, clone)
#endif
diff --git a/libc/sysdeps/linux/powerpc/copysignl.c b/libc/sysdeps/linux/powerpc/copysignl.c
new file mode 100644
index 000000000..000f653be
--- /dev/null
+++ b/libc/sysdeps/linux/powerpc/copysignl.c
@@ -0,0 +1,89 @@
+/* s_copysignl.c -- long double version of s_copysign.c.
+ * Conversion to long double by Ulrich Drepper,
+ * Cygnus Support, drepper@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/*
+ * copysignl(long double x, long double y)
+ * copysignl(x,y) returns a value with the magnitude of x and
+ * with the sign bit of y.
+ */
+
+#include <endian.h>
+#include <stdint.h>
+
+#if __FLOAT_WORD_ORDER == BIG_ENDIAN
+
+typedef union
+{
+ long double value;
+ struct
+ {
+ int sign_exponent:16;
+ unsigned int empty:16;
+ uint32_t msw;
+ uint32_t lsw;
+ } parts;
+} ieee_long_double_shape_type;
+
+#endif
+
+#if __FLOAT_WORD_ORDER == LITTLE_ENDIAN
+
+typedef union
+{
+ long double value;
+ struct
+ {
+ uint32_t lsw;
+ uint32_t msw;
+ int sign_exponent:16;
+ unsigned int empty:16;
+ } parts;
+} ieee_long_double_shape_type;
+
+#endif
+
+/* Get int from the exponent of a long double. */
+
+#define GET_LDOUBLE_EXP(exp,d) \
+do { \
+ ieee_long_double_shape_type ge_u; \
+ ge_u.value = (d); \
+ (exp) = ge_u.parts.sign_exponent; \
+} while (0)
+
+/* Set exponent of a long double from an int. */
+
+#define SET_LDOUBLE_EXP(d,exp) \
+do { \
+ ieee_long_double_shape_type se_u; \
+ se_u.value = (d); \
+ se_u.parts.sign_exponent = (exp); \
+ (d) = se_u.value; \
+} while (0)
+
+long double copysignl(long double x, long double y);
+libc_hidden_proto(copysignl);
+
+long double copysignl(long double x, long double y)
+{
+ uint32_t es1,es2;
+ GET_LDOUBLE_EXP(es1,x);
+ GET_LDOUBLE_EXP(es2,y);
+ SET_LDOUBLE_EXP(x,(es1&0x7fff)|(es2&0x8000));
+ return x;
+}
+
+libc_hidden_def(copysignl);
diff --git a/libc/sysdeps/linux/powerpc/crt1.S b/libc/sysdeps/linux/powerpc/crt1.S
index 4f1494a8f..27bfc5a5a 100644
--- a/libc/sysdeps/linux/powerpc/crt1.S
+++ b/libc/sysdeps/linux/powerpc/crt1.S
@@ -12,8 +12,8 @@
* 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
+ * along with this program; see the file COPYING.LIB. If not, see
+ * <http://www.gnu.org/licenses/>.
*/
#include <features.h>
diff --git a/libc/sysdeps/linux/powerpc/crtn.S b/libc/sysdeps/linux/powerpc/crtn.S
index ba6d0e0c8..938367caa 100644
--- a/libc/sysdeps/linux/powerpc/crtn.S
+++ b/libc/sysdeps/linux/powerpc/crtn.S
@@ -9,7 +9,6 @@
addi 1,1,32
mtlr 0
blr
- .size _init, .-_init
.section .fini
.align 2
@@ -20,4 +19,3 @@
addi 1,1,32
mtlr 0
blr
- .size _fini, .-_fini
diff --git a/libc/sysdeps/linux/powerpc/fenv.h b/libc/sysdeps/linux/powerpc/fenv.h
index 8a06f024e..9ba384756 100644
--- a/libc/sysdeps/linux/powerpc/fenv.h
+++ b/libc/sysdeps/linux/powerpc/fenv.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/*
* ISO C99 7.6: Floating-point environment <fenv.h>
@@ -73,7 +72,7 @@ extern int feraiseexcept (int __excepts) __THROW;
/* Set complete status for exceptions indicated by EXCEPTS according to
the representation in the object pointed to by FLAGP. */
-extern int fesetexceptflag (__const fexcept_t *__flagp, int __excepts) __THROW;
+extern int fesetexceptflag (const fexcept_t *__flagp, int __excepts) __THROW;
/* Determine which of subset of the exceptions specified by EXCEPTS are
currently set. */
@@ -102,12 +101,12 @@ extern int feholdexcept (fenv_t *__envp) __THROW;
/* Establish the floating-point environment represented by the object
pointed to by ENVP. */
-extern int fesetenv (__const fenv_t *__envp) __THROW;
+extern int fesetenv (const fenv_t *__envp) __THROW;
/* Save current exceptions in temporary storage, install environment
represented by object pointed to by ENVP and raise exceptions
according to saved exceptions. */
-extern int feupdateenv (__const fenv_t *__envp) __THROW;
+extern int feupdateenv (const fenv_t *__envp) __THROW;
/* Include optimization. */
diff --git a/libc/sysdeps/linux/powerpc/fpu_control.h b/libc/sysdeps/linux/powerpc/fpu_control.h
index 442da4721..74e7a1b49 100644
--- a/libc/sysdeps/linux/powerpc/fpu_control.h
+++ b/libc/sysdeps/linux/powerpc/fpu_control.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FPU_CONTROL_H
#define _FPU_CONTROL_H
diff --git a/libc/sysdeps/linux/powerpc/ioctl.c b/libc/sysdeps/linux/powerpc/ioctl.c
index 7f92be410..4c4c12341 100644
--- a/libc/sysdeps/linux/powerpc/ioctl.c
+++ b/libc/sysdeps/linux/powerpc/ioctl.c
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <stdarg.h>
#include <termios.h>
@@ -22,17 +21,14 @@
#include <sys/ioctl.h>
#include <sys/syscall.h>
-libc_hidden_proto(ioctl)
-libc_hidden_proto(tcsetattr)
-libc_hidden_proto(tcgetattr)
/* The user-visible size of struct termios has changed. Catch ioctl calls
using the new-style struct termios, and translate them to old-style. */
#define __NR___syscall_ioctl __NR_ioctl
-static inline
-_syscall3(int, __syscall_ioctl, int, fd, unsigned long int, request, void *, arg);
+static __always_inline
+_syscall3(int, __syscall_ioctl, int, fd, unsigned long int, request, void *, arg)
int ioctl (int fd, unsigned long int request, ...)
diff --git a/libc/sysdeps/linux/powerpc/jmpbuf-offsets.h b/libc/sysdeps/linux/powerpc/jmpbuf-offsets.h
new file mode 100644
index 000000000..eb7d7fd17
--- /dev/null
+++ b/libc/sysdeps/linux/powerpc/jmpbuf-offsets.h
@@ -0,0 +1,40 @@
+/* Private macros for accessing __jmp_buf contents. PowerPC version.
+ Copyright (C) 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <bits/wordsize.h>
+
+#define JB_GPR1 0 /* Also known as the stack pointer */
+#define JB_GPR2 1
+#define JB_LR 2 /* The address we will return to */
+#if __WORDSIZE == 64
+# define JB_GPRS 3 /* GPRs 14 through 31 are saved, 18*2 words total. */
+# define JB_CR 21 /* Condition code registers with the VRSAVE at */
+ /* offset 172 (low half of the double word. */
+# define JB_FPRS 22 /* FPRs 14 through 31 are saved, 18*2 words total. */
+# define JB_SIZE (64 * 8) /* As per PPC64-VMX ABI. */
+# define JB_VRSAVE 21 /* VRSAVE shares a double word with the CR at offset */
+ /* 168 (high half of the double word). */
+# define JB_VRS 40 /* VRs 20 through 31 are saved, 12*4 words total. */
+#else
+# define JB_GPRS 3 /* GPRs 14 through 31 are saved, 18 in total. */
+# define JB_CR 21 /* Condition code registers. */
+# define JB_FPRS 22 /* FPRs 14 through 31 are saved, 18*2 words total. */
+# define JB_SIZE ((64 + (12 * 4)) * 4)
+# define JB_VRSAVE 62
+# define JB_VRS 64
+#endif
diff --git a/libc/sysdeps/linux/powerpc/jmpbuf-unwind.h b/libc/sysdeps/linux/powerpc/jmpbuf-unwind.h
new file mode 100644
index 000000000..54322b805
--- /dev/null
+++ b/libc/sysdeps/linux/powerpc/jmpbuf-unwind.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+#include <setjmp.h>
+#include <jmpbuf-offsets.h>
+
+/* Test if longjmp to JMPBUF would unwind the frame
+ containing a local variable at ADDRESS. */
+#define _JMPBUF_UNWINDS(jmpbuf, address) \
+ ((void *) (address) < (void *) (jmpbuf)[JB_GPR1])
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <stdint.h>
+#include <unwind.h>
+
+#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
+ _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
+
+#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
+ ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[JB_GPR1] - (_adj))
+#endif
diff --git a/libc/sysdeps/linux/powerpc/powerpc32/sysdep.h b/libc/sysdeps/linux/powerpc/powerpc32/sysdep.h
new file mode 100644
index 000000000..9459e7919
--- /dev/null
+++ b/libc/sysdeps/linux/powerpc/powerpc32/sysdep.h
@@ -0,0 +1,151 @@
+/* Assembly macros for 32-bit PowerPC.
+ Copyright (C) 1999, 2001, 2002, 2003, 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifdef __ASSEMBLER__
+
+#ifdef __ELF__
+
+/* If compiled for profiling, call `_mcount' at the start of each
+ function. */
+#ifdef PROF
+/* The mcount code relies on a the return address being on the stack
+ to locate our caller and so it can restore it; so store one just
+ for its benefit. */
+# define CALL_MCOUNT \
+ mflr r0; \
+ stw r0,4(r1); \
+ cfi_offset (lr, 4); \
+ bl JUMPTARGET(_mcount);
+#else /* PROF */
+# define CALL_MCOUNT /* Do nothing. */
+#endif /* PROF */
+
+#define ENTRY(name) \
+ .globl C_SYMBOL_NAME(name); \
+ ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
+ .align ALIGNARG(2); \
+ C_LABEL(name) \
+ cfi_startproc; \
+ CALL_MCOUNT
+
+#define EALIGN_W_0 /* No words to insert. */
+#define EALIGN_W_1 nop
+#define EALIGN_W_2 nop;nop
+#define EALIGN_W_3 nop;nop;nop
+#define EALIGN_W_4 EALIGN_W_3;nop
+#define EALIGN_W_5 EALIGN_W_4;nop
+#define EALIGN_W_6 EALIGN_W_5;nop
+#define EALIGN_W_7 EALIGN_W_6;nop
+
+/* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes
+ past a 2^align boundary. */
+#ifdef PROF
+# define EALIGN(name, alignt, words) \
+ .globl C_SYMBOL_NAME(name); \
+ ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
+ .align ALIGNARG(2); \
+ C_LABEL(name) \
+ cfi_startproc; \
+ CALL_MCOUNT \
+ b 0f; \
+ .align ALIGNARG(alignt); \
+ EALIGN_W_##words; \
+ 0:
+#else /* PROF */
+# define EALIGN(name, alignt, words) \
+ .globl C_SYMBOL_NAME(name); \
+ ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
+ .align ALIGNARG(alignt); \
+ EALIGN_W_##words; \
+ C_LABEL(name) \
+ cfi_startproc;
+#endif
+
+#undef END
+#define END(name) \
+ cfi_endproc; \
+ ASM_SIZE_DIRECTIVE(name)
+
+#define DO_CALL(syscall) \
+ li 0,syscall; \
+ sc
+
+#undef JUMPTARGET
+#ifdef PIC
+# define JUMPTARGET(name) name##@plt
+#else
+# define JUMPTARGET(name) name
+#endif
+
+#if defined SHARED && defined DO_VERSIONING && defined PIC \
+ && !defined NO_HIDDEN
+# undef HIDDEN_JUMPTARGET
+# define HIDDEN_JUMPTARGET(name) __GI_##name##@local
+#endif
+
+#define PSEUDO(name, syscall_name, args) \
+ .section ".text"; \
+ ENTRY (name) \
+ DO_CALL (SYS_ify (syscall_name));
+
+#define PSEUDO_RET \
+ bnslr+; \
+ b __syscall_error@local
+#define ret PSEUDO_RET
+
+#undef PSEUDO_END
+#define PSEUDO_END(name) \
+ END (name)
+
+#define PSEUDO_NOERRNO(name, syscall_name, args) \
+ .section ".text"; \
+ ENTRY (name) \
+ DO_CALL (SYS_ify (syscall_name));
+
+#define PSEUDO_RET_NOERRNO \
+ blr
+#define ret_NOERRNO PSEUDO_RET_NOERRNO
+
+#undef PSEUDO_END_NOERRNO
+#define PSEUDO_END_NOERRNO(name) \
+ END (name)
+
+#define PSEUDO_ERRVAL(name, syscall_name, args) \
+ .section ".text"; \
+ ENTRY (name) \
+ DO_CALL (SYS_ify (syscall_name));
+
+#define PSEUDO_RET_ERRVAL \
+ blr
+#undef ret_ERRVAL
+#define ret_ERRVAL PSEUDO_RET_ERRVAL
+
+#undef PSEUDO_END_ERRVAL
+#define PSEUDO_END_ERRVAL(name) \
+ END (name)
+
+/* Local labels stripped out by the linker. */
+#undef L
+#define L(x) .L##x
+
+/* Label in text section. */
+#define C_TEXT(name) name
+
+#endif /* __ELF__ */
+
+#endif /* __ASSEMBLER__ */
diff --git a/libc/sysdeps/linux/powerpc/powerpc64/sysdep.h b/libc/sysdeps/linux/powerpc/powerpc64/sysdep.h
new file mode 100644
index 000000000..5a194af58
--- /dev/null
+++ b/libc/sysdeps/linux/powerpc/powerpc64/sysdep.h
@@ -0,0 +1,243 @@
+/* Assembly macros for 64-bit PowerPC.
+ Copyright (C) 2002, 2003, 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifdef __ELF__
+
+#ifdef __ASSEMBLER__
+
+/* Support macros for CALL_MCOUNT. */
+ .macro SAVE_ARG NARG
+ .if \NARG
+ SAVE_ARG \NARG-1
+ std 2+\NARG,-72+8*(\NARG)(1)
+ .endif
+ .endm
+
+ .macro REST_ARG NARG
+ .if \NARG
+ REST_ARG \NARG-1
+ ld 2+\NARG,40+8*(\NARG)(1)
+ .endif
+ .endm
+
+/* If compiled for profiling, call `_mcount' at the start of each function.
+ see ppc-mcount.S for more details. */
+ .macro CALL_MCOUNT NARG
+#ifdef PROF
+ mflr r0
+ SAVE_ARG \NARG
+ std r0,16(r1)
+ stdu r1,-112(r1)
+ bl JUMPTARGET (_mcount)
+ ld r0,128(r1)
+ REST_ARG \NARG
+ addi r1,r1,112
+ mtlr r0
+#endif
+ .endm
+
+#ifdef USE_PPC64_OVERLAPPING_OPD
+# define OPD_ENT(name) .quad BODY_LABEL (name), .TOC.@tocbase
+#else
+# define OPD_ENT(name) .quad BODY_LABEL (name), .TOC.@tocbase, 0
+#endif
+
+#define ENTRY_1(name) \
+ .section ".text"; \
+ .type BODY_LABEL(name),@function; \
+ .globl name; \
+ .section ".opd","aw"; \
+ .align 3; \
+name##: OPD_ENT (name); \
+ .previous;
+
+# define DOT_LABEL(X) X
+# define BODY_LABEL(X) .LY##X
+# define ENTRY_2(name) \
+ .type name,@function; \
+ ENTRY_1(name)
+# define END_2(name) \
+ .size name,.-BODY_LABEL(name); \
+ .size BODY_LABEL(name),.-BODY_LABEL(name);
+
+#define ENTRY(name) \
+ ENTRY_2(name) \
+ .align ALIGNARG(2); \
+BODY_LABEL(name): \
+ cfi_startproc;
+
+#define EALIGN_W_0 /* No words to insert. */
+#define EALIGN_W_1 nop
+#define EALIGN_W_2 nop;nop
+#define EALIGN_W_3 nop;nop;nop
+#define EALIGN_W_4 EALIGN_W_3;nop
+#define EALIGN_W_5 EALIGN_W_4;nop
+#define EALIGN_W_6 EALIGN_W_5;nop
+#define EALIGN_W_7 EALIGN_W_6;nop
+
+/* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes
+ past a 2^alignt boundary. */
+#define EALIGN(name, alignt, words) \
+ ENTRY_2(name) \
+ .align ALIGNARG(alignt); \
+ EALIGN_W_##words; \
+BODY_LABEL(name): \
+ cfi_startproc;
+
+/* Local labels stripped out by the linker. */
+#undef L
+#define L(x) .L##x
+
+#define tostring(s) #s
+#define stringify(s) tostring(s)
+#define XGLUE(a,b) a##b
+#define GLUE(a,b) XGLUE(a,b)
+#define LT_LABEL(name) GLUE(.LT,name)
+#define LT_LABELSUFFIX(name,suffix) GLUE(GLUE(.LT,name),suffix)
+
+/* Support Traceback tables */
+#define TB_ASM 0x000c000000000000
+#define TB_GLOBALLINK 0x0000800000000000
+#define TB_IS_EPROL 0x0000400000000000
+#define TB_HAS_TBOFF 0x0000200000000000
+#define TB_INT_PROC 0x0000100000000000
+#define TB_HAS_CTL 0x0000080000000000
+#define TB_TOCLESS 0x0000040000000000
+#define TB_FP_PRESENT 0x0000020000000000
+#define TB_LOG_ABORT 0x0000010000000000
+#define TB_INT_HANDL 0x0000008000000000
+#define TB_NAME_PRESENT 0x0000004000000000
+#define TB_USES_ALLOCA 0x0000002000000000
+#define TB_SAVES_CR 0x0000000200000000
+#define TB_SAVES_LR 0x0000000100000000
+#define TB_STORES_BC 0x0000000080000000
+#define TB_FIXUP 0x0000000040000000
+#define TB_FP_SAVED(fprs) (((fprs) & 0x3f) << 24)
+#define TB_GPR_SAVED(gprs) (((fprs) & 0x3f) << 16)
+#define TB_FIXEDPARMS(parms) (((parms) & 0xff) << 8)
+#define TB_FLOATPARMS(parms) (((parms) & 0x7f) << 1)
+#define TB_PARMSONSTK 0x0000000000000001
+
+#define PPC_HIGHER(v) (((v) >> 32) & 0xffff)
+#define TB_DEFAULT TB_ASM | TB_HAS_TBOFF | TB_NAME_PRESENT
+
+#define TRACEBACK(name) \
+LT_LABEL(name): ; \
+ .long 0 ; \
+ .quad TB_DEFAULT ; \
+ .long LT_LABEL(name)-BODY_LABEL(name) ; \
+ .short LT_LABELSUFFIX(name,_name_end)-LT_LABELSUFFIX(name,_name_start) ; \
+LT_LABELSUFFIX(name,_name_start): ;\
+ .ascii stringify(name) ; \
+LT_LABELSUFFIX(name,_name_end): ; \
+ .align 2 ;
+
+#define TRACEBACK_MASK(name,mask) \
+LT_LABEL(name): ; \
+ .long 0 ; \
+ .quad TB_DEFAULT | mask ; \
+ .long LT_LABEL(name)-BODY_LABEL(name) ; \
+ .short LT_LABELSUFFIX(name,_name_end)-LT_LABELSUFFIX(name,_name_start) ; \
+LT_LABELSUFFIX(name,_name_start): ;\
+ .ascii stringify(name) ; \
+LT_LABELSUFFIX(name,_name_end): ; \
+ .align 2 ;
+
+/* END generates Traceback tables */
+#undef END
+#define END(name) \
+ cfi_endproc; \
+ TRACEBACK(name) \
+ END_2(name)
+
+/* This form supports more informative traceback tables */
+#define END_GEN_TB(name,mask) \
+ cfi_endproc; \
+ TRACEBACK_MASK(name,mask) \
+ END_2(name)
+
+#define DO_CALL(syscall) \
+ li 0,syscall; \
+ sc
+
+/* ppc64 is always PIC */
+#undef JUMPTARGET
+#define JUMPTARGET(name) DOT_LABEL(name)
+
+#define PSEUDO(name, syscall_name, args) \
+ .section ".text"; \
+ ENTRY (name) \
+ DO_CALL (SYS_ify (syscall_name));
+
+#define PSEUDO_RET \
+ bnslr+; \
+ b JUMPTARGET(__syscall_error)
+
+#define ret PSEUDO_RET
+
+#undef PSEUDO_END
+#define PSEUDO_END(name) \
+ END (name)
+
+#define PSEUDO_NOERRNO(name, syscall_name, args) \
+ .section ".text"; \
+ ENTRY (name) \
+ DO_CALL (SYS_ify (syscall_name));
+
+#define PSEUDO_RET_NOERRNO \
+ blr
+
+#define ret_NOERRNO PSEUDO_RET_NOERRNO
+
+#undef PSEUDO_END_NOERRNO
+#define PSEUDO_END_NOERRNO(name) \
+ END (name)
+
+#define PSEUDO_ERRVAL(name, syscall_name, args) \
+ .section ".text"; \
+ ENTRY (name) \
+ DO_CALL (SYS_ify (syscall_name));
+
+#define PSEUDO_RET_ERRVAL \
+ blr
+
+#undef ret_ERRVAL
+#define ret_ERRVAL PSEUDO_RET_ERRVAL
+
+#undef PSEUDO_END_ERRVAL
+#define PSEUDO_END_ERRVAL(name) \
+ END (name)
+
+#else /* !__ASSEMBLER__ */
+
+#ifdef USE_PPC64_OVERLAPPING_OPD
+# define OPD_ENT(name) ".quad " BODY_PREFIX #name ", .TOC.@tocbase;"
+#else
+# define OPD_ENT(name) ".quad " BODY_PREFIX #name ", .TOC.@tocbase, 0;"
+#endif
+
+# define DOT_PREFIX ""
+# define BODY_PREFIX ".LY"
+# define ENTRY_2(name) ".type " #name ",@function;"
+# define END_2(name) \
+ ".size " #name ",.-" BODY_PREFIX #name ";\n" \
+ ".size " BODY_PREFIX #name ",.-" BODY_PREFIX #name ";"
+
+#endif /* __ASSEMBLER__ */
+
+#endif /* __ELF__ */
diff --git a/libc/sysdeps/linux/powerpc/ppc_asm.h b/libc/sysdeps/linux/powerpc/ppc_asm.h
index e51d88f73..2a6fbbc0f 100644
--- a/libc/sysdeps/linux/powerpc/ppc_asm.h
+++ b/libc/sysdeps/linux/powerpc/ppc_asm.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifdef __ASSEMBLER__
diff --git a/libc/sysdeps/linux/powerpc/pread_write.c b/libc/sysdeps/linux/powerpc/pread_write.c
deleted file mode 100644
index aef040c90..000000000
--- a/libc/sysdeps/linux/powerpc/pread_write.c
+++ /dev/null
@@ -1,183 +0,0 @@
-/* vi: set sw=4 ts=4:
- *
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-/* 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...
- */
-
-#include <sys/syscall.h>
-#include <unistd.h>
-#include <endian.h>
-
-#ifndef __UCLIBC_HAS_LFS__
-# define off64_t off_t
-#endif
-
-#ifdef __NR_pread
-extern __typeof(pread) __libc_pread;
-# define __NR___syscall_pread __NR_pread
-static __inline__ _syscall6(ssize_t, __syscall_pread, int, fd,
- void *, buf, size_t, count, int, dummy, 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, 0, __LONG_LONG_PAIR(offset >> 31, offset)));
-}
-weak_alias(__libc_pread,pread)
-
-# ifdef __UCLIBC_HAS_LFS__
-extern __typeof(pread64) __libc_pread64;
-ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset)
-{
- return(__syscall_pread(fd, buf, count, 0, __LONG_LONG_PAIR(offset >> 32, offset)));
-}
-weak_alias(__libc_pread64,pread64)
-# endif /* __UCLIBC_HAS_LFS__ */
-#endif /* __NR_pread */
-
-
-#ifdef __NR_pwrite
-extern __typeof(pwrite) __libc_pwrite;
-# define __NR___syscall_pwrite __NR_pwrite
-static __inline__ _syscall6(ssize_t, __syscall_pwrite, int, fd,
- const void *, buf, size_t, count, int, dummy, 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, 0, __LONG_LONG_PAIR(offset >> 31, offset)));
-}
-weak_alias(__libc_pwrite,pwrite)
-
-# ifdef __UCLIBC_HAS_LFS__
-extern __typeof(pwrite64) __libc_pwrite64;
-ssize_t __libc_pwrite64(int fd, const void *buf, size_t count, off64_t offset)
-{
- return(__syscall_pwrite(fd, buf, count, 0, __LONG_LONG_PAIR(offset >> 32, offset)));
-}
-weak_alias(__libc_pwrite64,pwrite64)
-# endif /* __UCLIBC_HAS_LFS__ */
-#endif /* __NR_pwrite */
-
-
-
-#if ! defined __NR_pread || ! defined __NR_pwrite
-libc_hidden_proto(read)
-libc_hidden_proto(write)
-libc_hidden_proto(lseek)
-
-static ssize_t __fake_pread_write(int fd, void *buf,
- size_t count, off_t offset, int do_pwrite)
-{
- int save_errno;
- ssize_t result;
- off_t old_offset;
-
- /* Since we must not change the file pointer preserve the
- * value so that we can restore it later. */
- if ((old_offset=lseek(fd, 0, SEEK_CUR)) == (off_t) -1)
- return -1;
-
- /* Set to wanted position. */
- if (lseek (fd, offset, SEEK_SET) == (off_t) -1)
- return -1;
-
- if (do_pwrite == 1) {
- /* Write the data. */
- result = write(fd, buf, count);
- } else {
- /* Read the data. */
- result = read(fd, buf, count);
- }
-
- /* Now we have to restore the position. If this fails we
- * have to return this as an error. */
- save_errno = errno;
- if (lseek(fd, old_offset, SEEK_SET) == (off_t) -1)
- {
- if (result == -1)
- __set_errno(save_errno);
- return -1;
- }
- __set_errno(save_errno);
- return(result);
-}
-
-# ifdef __UCLIBC_HAS_LFS__
-libc_hidden_proto(lseek64)
-
-static ssize_t __fake_pread_write64(int fd, void *buf,
- size_t count, off64_t offset, int do_pwrite)
-{
- int save_errno;
- ssize_t result;
- off64_t old_offset;
-
- /* Since we must not change the file pointer preserve the
- * value so that we can restore it later. */
- if ((old_offset=lseek64(fd, 0, SEEK_CUR)) == (off64_t) -1)
- return -1;
-
- /* Set to wanted position. */
- if (lseek64(fd, offset, SEEK_SET) == (off64_t) -1)
- return -1;
-
- if (do_pwrite == 1) {
- /* Write the data. */
- result = write(fd, buf, count);
- } else {
- /* Read the data. */
- result = read(fd, buf, count);
- }
-
- /* Now we have to restore the position. */
- save_errno = errno;
- if (lseek64 (fd, old_offset, SEEK_SET) == (off64_t) -1) {
- if (result == -1)
- __set_errno (save_errno);
- return -1;
- }
- __set_errno (save_errno);
- return result;
-}
-# endif /* __UCLIBC_HAS_LFS__ */
-#endif /* ! defined __NR_pread || ! defined __NR_pwrite */
-
-#ifndef __NR_pread
-ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset)
-{
- return(__fake_pread_write(fd, buf, count, offset, 0));
-}
-weak_alias(__libc_pread,pread)
-
-# ifdef __UCLIBC_HAS_LFS__
-ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset)
-{
- return(__fake_pread_write64(fd, buf, count, offset, 0));
-}
-weak_alias(__libc_pread64,pread64)
-# endif /* __UCLIBC_HAS_LFS__ */
-#endif /* ! __NR_pread */
-
-
-#ifndef __NR_pwrite
-ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset)
-{
- return(__fake_pread_write(fd, (void*)buf, count, offset, 1));
-}
-weak_alias(__libc_pwrite,pwrite)
-
-# ifdef __UCLIBC_HAS_LFS__
-ssize_t __libc_pwrite64(int fd, const void *buf, size_t count, off64_t offset)
-{
- return(__fake_pread_write64(fd, (void*)buf, count, offset, 1));
-}
-weak_alias(__libc_pwrite64,pwrite64)
-# endif /* __UCLIBC_HAS_LFS__ */
-#endif /* ! __NR_pwrite */
diff --git a/libc/sysdeps/linux/powerpc/setjmp.S b/libc/sysdeps/linux/powerpc/setjmp.S
index 04b06d689..5abe9f9d4 100644
--- a/libc/sysdeps/linux/powerpc/setjmp.S
+++ b/libc/sysdeps/linux/powerpc/setjmp.S
@@ -15,15 +15,12 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <features.h>
#include "ppc_asm.h"
-#define _ASM
-#define _SETJMP_H
-#include <bits/setjmp.h>
+#include <jmpbuf-offsets.h>
#if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__
#define FP(x...) x
diff --git a/libc/sysdeps/linux/powerpc/sys/procfs.h b/libc/sysdeps/linux/powerpc/sys/procfs.h
index 118463649..7ae12e3cc 100644
--- a/libc/sysdeps/linux/powerpc/sys/procfs.h
+++ b/libc/sysdeps/linux/powerpc/sys/procfs.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_PROCFS_H
#define _SYS_PROCFS_H 1
diff --git a/libc/sysdeps/linux/powerpc/sys/ptrace.h b/libc/sysdeps/linux/powerpc/sys/ptrace.h
index 91a87307f..dd81efc28 100644
--- a/libc/sysdeps/linux/powerpc/sys/ptrace.h
+++ b/libc/sysdeps/linux/powerpc/sys/ptrace.h
@@ -1,5 +1,5 @@
/* `ptrace' debugger support interface. Linux version.
- Copyright (C) 2001 Free Software Foundation, Inc.
+ Copyright (C) 2001-2014 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
@@ -13,14 +13,14 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_PTRACE_H
#define _SYS_PTRACE_H 1
#include <features.h>
+#include <bits/types.h>
__BEGIN_DECLS
@@ -79,8 +79,96 @@ enum __ptrace_request
#define PT_DETACH PTRACE_DETACH
/* Continue and stop at the next (return from) syscall. */
- PTRACE_SYSCALL = 24
+ PTRACE_SYSCALL = 24,
#define PT_SYSCALL PTRACE_SYSCALL
+
+ /* 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
+
+ /* Get register content. */
+ PTRACE_GETREGSET = 0x4204,
+#define PTRACE_GETREGSET PTRACE_GETREGSET
+
+ /* Set register content. */
+ PTRACE_SETREGSET = 0x4205,
+#define PTRACE_SETREGSET PTRACE_SETREGSET
+
+ /* Like PTRACE_ATTACH, but do not force tracee to trap and do not affect
+ signal or group stop state. */
+ PTRACE_SEIZE = 0x4206,
+#define PTRACE_SEIZE PTRACE_SEIZE
+
+ /* Trap seized tracee. */
+ PTRACE_INTERRUPT = 0x4207,
+#define PTRACE_INTERRUPT PTRACE_INTERRUPT
+
+ /* Wait for next group event. */
+ PTRACE_LISTEN = 0x4208,
+#define PTRACE_LISTEN PTRACE_LISTEN
+
+ PTRACE_PEEKSIGINFO = 0x4209
+#define PTRACE_PEEKSIGINFO PTRACE_PEEKSIGINFO
+};
+
+
+/* Flag for PTRACE_LISTEN. */
+enum __ptrace_flags
+{
+ PTRACE_SEIZE_DEVEL = 0x80000000
+};
+
+/* 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_TRACESECCOMP = 0x00000080,
+ PTRACE_O_EXITKILL = 0x00100000,
+ PTRACE_O_MASK = 0x001000ff
+};
+
+/* 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,
+ PTRACE_EVENT_SECCOMP = 7
+};
+
+/* Arguments for PTRACE_PEEKSIGINFO. */
+struct __ptrace_peeksiginfo_args
+{
+ __uint64_t off; /* From which siginfo to start. */
+ __uint32_t flags; /* Flags for peeksiginfo. */
+ __int32_t nr; /* How many siginfos to take. */
+};
+
+enum __ptrace_peeksiginfo_flags
+{
+ /* Read signals from a shared (process wide) queue. */
+ PTRACE_PEEKSIGINFO_SHARED = (1 << 0)
};
/* Perform process tracing functions. REQUEST is one of the values
diff --git a/libc/sysdeps/linux/powerpc/sys/ucontext.h b/libc/sysdeps/linux/powerpc/sys/ucontext.h
index 737512afc..72fbae4f2 100644
--- a/libc/sysdeps/linux/powerpc/sys/ucontext.h
+++ b/libc/sysdeps/linux/powerpc/sys/ucontext.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_UCONTEXT_H
#define _SYS_UCONTEXT_H 1
diff --git a/libc/sysdeps/linux/powerpc/sys/user.h b/libc/sysdeps/linux/powerpc/sys/user.h
index e8a8aaa95..5fa37451c 100644
--- a/libc/sysdeps/linux/powerpc/sys/user.h
+++ b/libc/sysdeps/linux/powerpc/sys/user.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_USER_H
diff --git a/libc/sysdeps/linux/powerpc/syscall.S b/libc/sysdeps/linux/powerpc/syscall.S
index b85398416..248df6973 100644
--- a/libc/sysdeps/linux/powerpc/syscall.S
+++ b/libc/sysdeps/linux/powerpc/syscall.S
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <features.h>
@@ -30,6 +29,7 @@ syscall:
mr 5,6
mr 6,7
mr 7,8
+ mr 8,9
sc
bnslr;
diff --git a/libc/sysdeps/linux/powerpc/sysdep.h b/libc/sysdeps/linux/powerpc/sysdep.h
new file mode 100644
index 000000000..9a57062dc
--- /dev/null
+++ b/libc/sysdeps/linux/powerpc/sysdep.h
@@ -0,0 +1,195 @@
+/* Copyright (C) 1999, 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
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <common/sysdep.h>
+
+/*
+ * Powerpc Feature masks for the Aux Vector Hardware Capabilities (AT_HWCAP).
+ * This entry is copied to _dl_hwcap or rtld_global._dl_hwcap during startup.
+ * The following must match the kernels linux/asm/cputable.h.
+ */
+#define PPC_FEATURE_32 0x80000000 /* 32-bit mode. */
+#define PPC_FEATURE_64 0x40000000 /* 64-bit mode. */
+#define PPC_FEATURE_601_INSTR 0x20000000 /* 601 chip, Old POWER ISA. */
+#define PPC_FEATURE_HAS_ALTIVEC 0x10000000 /* SIMD/Vector Unit. */
+#define PPC_FEATURE_HAS_FPU 0x08000000 /* Floating Point Unit. */
+#define PPC_FEATURE_HAS_MMU 0x04000000 /* Memory Management Unit. */
+#define PPC_FEATURE_HAS_4xxMAC 0x02000000 /* 4xx Multiply Accumulator. */
+#define PPC_FEATURE_UNIFIED_CACHE 0x01000000 /* Unified I/D cache. */
+#define PPC_FEATURE_HAS_SPE 0x00800000 /* Signal Processing ext. */
+#define PPC_FEATURE_HAS_EFP_SINGLE 0x00400000 /* SPE Float. */
+#define PPC_FEATURE_HAS_EFP_DOUBLE 0x00200000 /* SPE Double. */
+#define PPC_FEATURE_NO_TB 0x00100000 /* 601/403gx have no timebase */
+#define PPC_FEATURE_POWER4 0x00080000 /* POWER4 ISA 2.00 */
+#define PPC_FEATURE_POWER5 0x00040000 /* POWER5 ISA 2.02 */
+#define PPC_FEATURE_POWER5_PLUS 0x00020000 /* POWER5+ ISA 2.03 */
+#define PPC_FEATURE_CELL_BE 0x00010000 /* CELL Broadband Engine */
+#define PPC_FEATURE_BOOKE 0x00008000
+#define PPC_FEATURE_SMT 0x00004000 /* Simultaneous Multi-Threading */
+#define PPC_FEATURE_ICACHE_SNOOP 0x00002000
+#define PPC_FEATURE_ARCH_2_05 0x00001000 /* ISA 2.05 */
+#define PPC_FEATURE_PA6T 0x00000800 /* PA Semi 6T Core */
+#define PPC_FEATURE_HAS_DFP 0x00000400 /* Decimal FP Unit */
+#define PPC_FEATURE_POWER6_EXT 0x00000200 /* P6 + mffgpr/mftgpr */
+#define PPC_FEATURE_ARCH_2_06 0x00000100 /* ISA 2.06 */
+#define PPC_FEATURE_HAS_VSX 0x00000080 /* P7 Vector Extension. */
+#define PPC_FEATURE_970 (PPC_FEATURE_POWER4 + PPC_FEATURE_HAS_ALTIVEC)
+
+#ifdef __ASSEMBLER__
+
+/* Symbolic names for the registers. The only portable way to write asm
+ code is to use number but this produces really unreadable code.
+ Therefore these symbolic names. */
+
+/* Integer registers. */
+#define r0 0
+#define r1 1
+#define r2 2
+#define r3 3
+#define r4 4
+#define r5 5
+#define r6 6
+#define r7 7
+#define r8 8
+#define r9 9
+#define r10 10
+#define r11 11
+#define r12 12
+#define r13 13
+#define r14 14
+#define r15 15
+#define r16 16
+#define r17 17
+#define r18 18
+#define r19 19
+#define r20 20
+#define r21 21
+#define r22 22
+#define r23 23
+#define r24 24
+#define r25 25
+#define r26 26
+#define r27 27
+#define r28 28
+#define r29 29
+#define r30 30
+#define r31 31
+
+/* Floating-point registers. */
+#define fp0 0
+#define fp1 1
+#define fp2 2
+#define fp3 3
+#define fp4 4
+#define fp5 5
+#define fp6 6
+#define fp7 7
+#define fp8 8
+#define fp9 9
+#define fp10 10
+#define fp11 11
+#define fp12 12
+#define fp13 13
+#define fp14 14
+#define fp15 15
+#define fp16 16
+#define fp17 17
+#define fp18 18
+#define fp19 19
+#define fp20 20
+#define fp21 21
+#define fp22 22
+#define fp23 23
+#define fp24 24
+#define fp25 25
+#define fp26 26
+#define fp27 27
+#define fp28 28
+#define fp29 29
+#define fp30 30
+#define fp31 31
+
+/* Condition code registers. */
+#define cr0 0
+#define cr1 1
+#define cr2 2
+#define cr3 3
+#define cr4 4
+#define cr5 5
+#define cr6 6
+#define cr7 7
+
+/* Vector registers. */
+#define v0 0
+#define v1 1
+#define v2 2
+#define v3 3
+#define v4 4
+#define v5 5
+#define v6 6
+#define v7 7
+#define v8 8
+#define v9 9
+#define v10 10
+#define v11 11
+#define v12 12
+#define v13 13
+#define v14 14
+#define v15 15
+#define v16 16
+#define v17 17
+#define v18 18
+#define v19 19
+#define v20 20
+#define v21 21
+#define v22 22
+#define v23 23
+#define v24 24
+#define v25 25
+#define v26 26
+#define v27 27
+#define v28 28
+#define v29 29
+#define v30 30
+#define v31 31
+
+#define VRSAVE 256
+
+
+#ifdef __ELF__
+
+/* This seems to always be the case on PPC. */
+#define ALIGNARG(log2) log2
+/* For ELF we need the `.type' directive to make shared libs work right. */
+#define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg;
+#define ASM_SIZE_DIRECTIVE(name) .size name,.-name
+
+/* In ELF C symbols are asm symbols. */
+#undef NO_UNDERSCORES
+#define NO_UNDERSCORES
+
+#endif /* __ELF__ */
+
+# include <sys/syscall.h>
+# if defined(__powerpc64__)
+# include "powerpc64/sysdep.h"
+# else
+# include "powerpc32/sysdep.h"
+# endif
+
+#endif /* __ASSEMBLER__ */
+
diff --git a/libc/sysdeps/linux/powerpc/vfork.S b/libc/sysdeps/linux/powerpc/vfork.S
index 600c980a8..0f31edafc 100644
--- a/libc/sysdeps/linux/powerpc/vfork.S
+++ b/libc/sysdeps/linux/powerpc/vfork.S
@@ -1,3 +1,4 @@
+/* vi: set sw=4 ts=4: */
/*
* Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
*
@@ -26,4 +27,4 @@ __vfork:
.size __vfork,.-__vfork
weak_alias(__vfork,vfork)
-libc_hidden_weak(vfork)
+libc_hidden_def(vfork)
diff --git a/libc/sysdeps/linux/sh/Makefile.arch b/libc/sysdeps/linux/sh/Makefile.arch
index 77ad570d6..99a77213b 100644
--- a/libc/sysdeps/linux/sh/Makefile.arch
+++ b/libc/sysdeps/linux/sh/Makefile.arch
@@ -6,9 +6,10 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-CSRC := \
- mmap.c pipe.c __init_brk.c brk.c sbrk.c syscall.c pread_write.c
+CSRC-y := \
+ pipe.c __init_brk.c brk.c sbrk.c pread_write.c
-SSRC := setjmp.S __longjmp.S vfork.S clone.S ___fpscr_values.S
+SSRC-y := setjmp.S __longjmp.S ___fpscr_values.S
-include $(top_srcdir)libc/sysdeps/linux/Makefile.commonarch
+CSRC-$(UCLIBC_LINUX_SPECIFIC) += cacheflush.c
+SSRC-$(if $(UCLIBC_HAS_THREADS_NATIVE),,y) += clone.S vfork.S
diff --git a/libc/sysdeps/linux/sh/___fpscr_values.S b/libc/sysdeps/linux/sh/___fpscr_values.S
index de8f0b42d..aac7a8e4f 100644
--- a/libc/sysdeps/linux/sh/___fpscr_values.S
+++ b/libc/sysdeps/linux/sh/___fpscr_values.S
@@ -14,14 +14,13 @@
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
+ along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include <features.h>
.data
-#if defined(__CONFIG_SH4__)
+#ifdef __SH4__
.global ___fpscr_values
.type ___fpscr_values,@object
.size ___fpscr_values,8
diff --git a/libc/sysdeps/linux/sh/__init_brk.c b/libc/sysdeps/linux/sh/__init_brk.c
index bb0692448..8a41eb3c4 100644
--- a/libc/sysdeps/linux/sh/__init_brk.c
+++ b/libc/sysdeps/linux/sh/__init_brk.c
@@ -7,7 +7,7 @@
void * __curbrk attribute_hidden = 0;
#define __NR__brk __NR_brk
-attribute_hidden _syscall1(void *, _brk, void *, ptr);
+attribute_hidden _syscall1(void *, _brk, void *, ptr)
extern int __init_brk (void) attribute_hidden;
int
diff --git a/libc/sysdeps/linux/sh/__longjmp.S b/libc/sysdeps/linux/sh/__longjmp.S
index eb569917b..5abf22912 100644
--- a/libc/sysdeps/linux/sh/__longjmp.S
+++ b/libc/sysdeps/linux/sh/__longjmp.S
@@ -14,12 +14,8 @@
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. */
+ see <http://www.gnu.org/licenses/>. */
-#define _SETJMP_H
-#define _ASM
-#include <bits/setjmp.h>
#include <features.h>
/* __longjmp(jmpbuf, val) */
diff --git a/libc/sysdeps/linux/sh/bits/atomic.h b/libc/sysdeps/linux/sh/bits/atomic.h
index 6bb7255c5..18ae9ea77 100644
--- a/libc/sysdeps/linux/sh/bits/atomic.h
+++ b/libc/sysdeps/linux/sh/bits/atomic.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <stdint.h>
@@ -54,6 +53,10 @@ typedef uintmax_t uatomic_max_t;
Japan. http://lc.linux.or.jp/lc2002/papers/niibe0919h.pdf (in
Japanese).
+ Niibe Yutaka, "gUSA: User Space Atomicity with Little Kernel
+ Modification", LinuxTag 2003, Rome.
+ http://www.semmel.ch/Linuxtag-DVD/talks/170/paper.html (in English).
+
B.N. Bershad, D. Redell, and J. Ellis, "Fast Mutual Exclusion for
Uniprocessors", Proceedings of the Fifth Architectural Support for
Programming Languages and Operating Systems (ASPLOS), pp. 223-233,
@@ -65,355 +68,231 @@ typedef uintmax_t uatomic_max_t;
r1: saved stack pointer
*/
-#define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
- ({ __typeof (*(mem)) __result; \
+#if __GNUC_PREREQ (4, 7)
+# define rNOSP "u"
+#else
+# define rNOSP "r"
+#endif
+
+/* Avoid having lots of different versions of compare and exchange,
+ by having this one complicated version. Parameters:
+ bwl: b, w or l for 8, 16 and 32 bit versions.
+ version: val or bool, depending on whether the result is the
+ previous value or a bool indicating whether the transfer
+ did happen (note this needs inverting before being
+ returned in atomic_compare_and_exchange_bool).
+*/
+
+#define __arch_compare_and_exchange_n(mem, newval, oldval, bwl, version) \
+ ({ signed long __arch_result; \
__asm__ __volatile__ ("\
.align 2\n\
mova 1f,r0\n\
nop\n\
mov r15,r1\n\
mov #-8,r15\n\
- 0: mov.b @%1,%0\n\
+ 0: mov." #bwl " @%1,%0\n\
cmp/eq %0,%3\n\
bf 1f\n\
- mov.b %2,@%1\n\
- 1: mov r1,r15"\
- : "=&r" (__result) : "r" (mem), "r" (newval), "r" (oldval) \
- : "r0", "r1", "t", "memory"); \
- __result; })
+ mov." #bwl " %2,@%1\n\
+ 1: mov r1,r15\n\
+ .ifeqs \"bool\",\"" #version "\"\n\
+ movt %0\n\
+ .endif\n" \
+ : "=&r" (__arch_result) \
+ : rNOSP (mem), rNOSP (newval), rNOSP (oldval) \
+ : "r0", "r1", "t", "memory"); \
+ __arch_result; })
+
+#define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
+ __arch_compare_and_exchange_n(mem, newval, (int8_t)(oldval), b, val)
#define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \
- ({ __typeof (*(mem)) __result; \
- __asm__ __volatile__ ("\
+ __arch_compare_and_exchange_n(mem, newval, (int16_t)(oldval), w, val)
+
+#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
+ __arch_compare_and_exchange_n(mem, newval, (int32_t)(oldval), l, val)
+
+/* XXX We do not really need 64-bit compare-and-exchange. At least
+ not in the moment. Using it would mean causing portability
+ problems since not many other 32-bit architectures have support for
+ such an operation. So don't define any code for now. */
+
+# define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
+ (abort (), 0)
+
+/* For "bool" routines, return if the exchange did NOT occur */
+
+#define __arch_compare_and_exchange_bool_8_acq(mem, newval, oldval) \
+ (! __arch_compare_and_exchange_n(mem, newval, (int8_t)(oldval), b, bool))
+
+#define __arch_compare_and_exchange_bool_16_acq(mem, newval, oldval) \
+ (! __arch_compare_and_exchange_n(mem, newval, (int16_t)(oldval), w, bool))
+
+#define __arch_compare_and_exchange_bool_32_acq(mem, newval, oldval) \
+ (! __arch_compare_and_exchange_n(mem, newval, (int32_t)(oldval), l, bool))
+
+# define __arch_compare_and_exchange_bool_64_acq(mem, newval, oldval) \
+ (abort (), 0)
+
+/* Similar to the above, have one template which can be used in a
+ number of places. This version returns both the old and the new
+ values of the location. Parameters:
+ bwl: b, w or l for 8, 16 and 32 bit versions.
+ oper: The instruction to perform on the old value.
+ Note old is not sign extended, so should be an unsigned long.
+*/
+
+#define __arch_operate_old_new_n(mem, value, old, new, bwl, oper) \
+ (void) ({ __asm__ __volatile__ ("\
.align 2\n\
mova 1f,r0\n\
- nop\n\
mov r15,r1\n\
+ nop\n\
mov #-8,r15\n\
- 0: mov.w @%1,%0\n\
- cmp/eq %0,%3\n\
- bf 1f\n\
- mov.w %2,@%1\n\
- 1: mov r1,r15"\
- : "=&r" (__result) : "r" (mem), "r" (newval), "r" (oldval) \
- : "r0", "r1", "t", "memory"); \
- __result; })
+ 0: mov." #bwl " @%2,%0\n\
+ mov %0,%1\n\
+ " #oper " %3,%1\n\
+ mov." #bwl " %1,@%2\n\
+ 1: mov r1,r15" \
+ : "=&r" (old), "=&r"(new) \
+ : rNOSP (mem), rNOSP (value) \
+ : "r0", "r1", "memory"); \
+ })
-#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
- ({ __typeof (*(mem)) __result; \
+#define __arch_exchange_and_add_8_int(mem, value) \
+ ({ int32_t __value = (value), __new, __old; \
+ __arch_operate_old_new_n((mem), __value, __old, __new, b, add); \
+ __old; })
+
+#define __arch_exchange_and_add_16_int(mem, value) \
+ ({ int32_t __value = (value), __new, __old; \
+ __arch_operate_old_new_n((mem), __value, __old, __new, w, add); \
+ __old; })
+
+#define __arch_exchange_and_add_32_int(mem, value) \
+ ({ int32_t __value = (value), __new, __old; \
+ __arch_operate_old_new_n((mem), __value, __old, __new, l, add); \
+ __old; })
+
+#define __arch_exchange_and_add_64_int(mem, value) \
+ (abort (), 0)
+
+#define atomic_exchange_and_add(mem, value) \
+ __atomic_val_bysize (__arch_exchange_and_add, int, mem, value)
+
+
+/* Again, another template. We get a slight optimisation when the old value
+ does not need to be returned. Parameters:
+ bwl: b, w or l for 8, 16 and 32 bit versions.
+ oper: The instruction to perform on the old value.
+*/
+
+#define __arch_operate_new_n(mem, value, bwl, oper) \
+ ({ int32_t __value = (value), __new; \
__asm__ __volatile__ ("\
.align 2\n\
mova 1f,r0\n\
- nop\n\
mov r15,r1\n\
- mov #-8,r15\n\
- 0: mov.l @%1,%0\n\
- cmp/eq %0,%3\n\
- bf 1f\n\
- mov.l %2,@%1\n\
- 1: mov r1,r15"\
- : "=&r" (__result) : "r" (mem), "r" (newval), "r" (oldval) \
- : "r0", "r1", "t", "memory"); \
- __result; })
+ mov #-6,r15\n\
+ 0: mov." #bwl " @%1,%0\n\
+ " #oper " %2,%0\n\
+ mov." #bwl " %0,@%1\n\
+ 1: mov r1,r15" \
+ : "=&r" (__new) \
+ : rNOSP (mem), rNOSP (__value) \
+ : "r0", "r1", "memory"); \
+ __new; \
+ })
-/* XXX We do not really need 64-bit compare-and-exchange. At least
- not in the moment. Using it would mean causing portability
- problems since not many other 32-bit architectures have support for
- such an operation. So don't define any code for now. */
+#define __arch_add_8_int(mem, value) \
+ __arch_operate_new_n(mem, value, b, add)
-# define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
- (abort (), (__typeof (*mem)) 0)
+#define __arch_add_16_int(mem, value) \
+ __arch_operate_new_n(mem, value, w, add)
-#define atomic_exchange_and_add(mem, value) \
- ({ __typeof (*(mem)) __result, __tmp, __value = (value); \
- if (sizeof (*(mem)) == 1) \
- __asm__ __volatile__ ("\
- .align 2\n\
- mova 1f,r0\n\
- mov r15,r1\n\
- mov #-6,r15\n\
- 0: mov.b @%2,%0\n\
- add %0,%1\n\
- mov.b %1,@%2\n\
- 1: mov r1,r15"\
- : "=&r" (__result), "=&r" (__tmp) : "r" (mem), "1" (__value) \
- : "r0", "r1", "memory"); \
- else if (sizeof (*(mem)) == 2) \
- __asm__ __volatile__ ("\
- .align 2\n\
- mova 1f,r0\n\
- mov r15,r1\n\
- mov #-6,r15\n\
- 0: mov.w @%2,%0\n\
- add %0,%1\n\
- mov.w %1,@%2\n\
- 1: mov r1,r15"\
- : "=&r" (__result), "=&r" (__tmp) : "r" (mem), "1" (__value) \
- : "r0", "r1", "memory"); \
- else if (sizeof (*(mem)) == 4) \
- __asm__ __volatile__ ("\
- .align 2\n\
- mova 1f,r0\n\
- mov r15,r1\n\
- mov #-6,r15\n\
- 0: mov.l @%2,%0\n\
- add %0,%1\n\
- mov.l %1,@%2\n\
- 1: mov r1,r15"\
- : "=&r" (__result), "=&r" (__tmp) : "r" (mem), "1" (__value) \
- : "r0", "r1", "memory"); \
- else \
- { \
- __typeof (mem) memp = (mem); \
- do \
- __result = *memp; \
- while (__arch_compare_and_exchange_val_64_acq \
- (memp, __result + __value, __result) == __result); \
- (void) __value; \
- } \
- __result; })
+#define __arch_add_32_int(mem, value) \
+ __arch_operate_new_n(mem, value, l, add)
+
+#define __arch_add_64_int(mem, value) \
+ (abort (), 0)
#define atomic_add(mem, value) \
- (void) ({ __typeof (*(mem)) __tmp, __value = (value); \
- if (sizeof (*(mem)) == 1) \
- __asm__ __volatile__ ("\
- .align 2\n\
- mova 1f,r0\n\
- mov r15,r1\n\
- mov #-6,r15\n\
- 0: mov.b @%1,r2\n\
- add r2,%0\n\
- mov.b %0,@%1\n\
- 1: mov r1,r15"\
- : "=&r" (__tmp) : "r" (mem), "0" (__value) \
- : "r0", "r1", "r2", "memory"); \
- else if (sizeof (*(mem)) == 2) \
- __asm__ __volatile__ ("\
- .align 2\n\
- mova 1f,r0\n\
- mov r15,r1\n\
- mov #-6,r15\n\
- 0: mov.w @%1,r2\n\
- add r2,%0\n\
- mov.w %0,@%1\n\
- 1: mov r1,r15"\
- : "=&r" (__tmp) : "r" (mem), "0" (__value) \
- : "r0", "r1", "r2", "memory"); \
- else if (sizeof (*(mem)) == 4) \
- __asm__ __volatile__ ("\
- .align 2\n\
- mova 1f,r0\n\
- mov r15,r1\n\
- mov #-6,r15\n\
- 0: mov.l @%1,r2\n\
- add r2,%0\n\
- mov.l %0,@%1\n\
- 1: mov r1,r15"\
- : "=&r" (__tmp) : "r" (mem), "0" (__value) \
- : "r0", "r1", "r2", "memory"); \
- else \
- { \
- __typeof (*(mem)) oldval; \
- __typeof (mem) memp = (mem); \
- do \
- oldval = *memp; \
- while (__arch_compare_and_exchange_val_64_acq \
- (memp, oldval + __value, oldval) == oldval); \
- (void) __value; \
- } \
- })
+ ((void) __atomic_val_bysize (__arch_add, int, mem, value))
+
+
+#define __arch_add_negative_8_int(mem, value) \
+ (__arch_operate_new_n(mem, value, b, add) < 0)
+
+#define __arch_add_negative_16_int(mem, value) \
+ (__arch_operate_new_n(mem, value, w, add) < 0)
+
+#define __arch_add_negative_32_int(mem, value) \
+ (__arch_operate_new_n(mem, value, l, add) < 0)
+
+#define __arch_add_negative_64_int(mem, value) \
+ (abort (), 0)
#define atomic_add_negative(mem, value) \
- ({ unsigned char __result; \
- __typeof (*(mem)) __tmp, __value = (value); \
- if (sizeof (*(mem)) == 1) \
- __asm__ __volatile__ ("\
- .align 2\n\
- mova 1f,r0\n\
- mov r15,r1\n\
- mov #-6,r15\n\
- 0: mov.b @%2,r2\n\
- add r2,%1\n\
- mov.b %1,@%2\n\
- 1: mov r1,r15\n\
- shal %1\n\
- movt %0"\
- : "=r" (__result), "=&r" (__tmp) : "r" (mem), "1" (__value) \
- : "r0", "r1", "r2", "t", "memory"); \
- else if (sizeof (*(mem)) == 2) \
- __asm__ __volatile__ ("\
- .align 2\n\
- mova 1f,r0\n\
- mov r15,r1\n\
- mov #-6,r15\n\
- 0: mov.w @%2,r2\n\
- add r2,%1\n\
- mov.w %1,@%2\n\
- 1: mov r1,r15\n\
- shal %1\n\
- movt %0"\
- : "=r" (__result), "=&r" (__tmp) : "r" (mem), "1" (__value) \
- : "r0", "r1", "r2", "t", "memory"); \
- else if (sizeof (*(mem)) == 4) \
- __asm__ __volatile__ ("\
- .align 2\n\
- mova 1f,r0\n\
- mov r15,r1\n\
- mov #-6,r15\n\
- 0: mov.l @%2,r2\n\
- add r2,%1\n\
- mov.l %1,@%2\n\
- 1: mov r1,r15\n\
- shal %1\n\
- movt %0"\
- : "=r" (__result), "=&r" (__tmp) : "r" (mem), "1" (__value) \
- : "r0", "r1", "r2", "t", "memory"); \
- else \
- abort (); \
- __result; })
+ __atomic_bool_bysize (__arch_add_negative, int, mem, value)
+
+
+#define __arch_add_zero_8_int(mem, value) \
+ (__arch_operate_new_n(mem, value, b, add) == 0)
+
+#define __arch_add_zero_16_int(mem, value) \
+ (__arch_operate_new_n(mem, value, w, add) == 0)
+
+#define __arch_add_zero_32_int(mem, value) \
+ (__arch_operate_new_n(mem, value, l, add) == 0)
+
+#define __arch_add_zero_64_int(mem, value) \
+ (abort (), 0)
#define atomic_add_zero(mem, value) \
- ({ unsigned char __result; \
- __typeof (*(mem)) __tmp, __value = (value); \
- if (sizeof (*(mem)) == 1) \
- __asm__ __volatile__ ("\
- .align 2\n\
- mova 1f,r0\n\
- mov r15,r1\n\
- mov #-6,r15\n\
- 0: mov.b @%2,r2\n\
- add r2,%1\n\
- mov.b %1,@%2\n\
- 1: mov r1,r15\n\
- tst %1,%1\n\
- movt %0"\
- : "=r" (__result), "=&r" (__tmp) : "r" (mem), "1" (__value) \
- : "r0", "r1", "r2", "t", "memory"); \
- else if (sizeof (*(mem)) == 2) \
- __asm__ __volatile__ ("\
- .align 2\n\
- mova 1f,r0\n\
- mov r15,r1\n\
- mov #-6,r15\n\
- 0: mov.w @%2,r2\n\
- add r2,%1\n\
- mov.w %1,@%2\n\
- 1: mov r1,r15\n\
- tst %1,%1\n\
- movt %0"\
- : "=r" (__result), "=&r" (__tmp) : "r" (mem), "1" (__value) \
- : "r0", "r1", "r2", "t", "memory"); \
- else if (sizeof (*(mem)) == 4) \
- __asm__ __volatile__ ("\
- .align 2\n\
- mova 1f,r0\n\
- mov r15,r1\n\
- mov #-6,r15\n\
- 0: mov.l @%2,r2\n\
- add r2,%1\n\
- mov.l %1,@%2\n\
- 1: mov r1,r15\n\
- tst %1,%1\n\
- movt %0"\
- : "=r" (__result), "=&r" (__tmp) : "r" (mem), "1" (__value) \
- : "r0", "r1", "r2", "t", "memory"); \
- else \
- abort (); \
- __result; })
+ __atomic_bool_bysize (__arch_add_zero, int, mem, value)
+
#define atomic_increment_and_test(mem) atomic_add_zero((mem), 1)
#define atomic_decrement_and_test(mem) atomic_add_zero((mem), -1)
-#define atomic_bit_set(mem, bit) \
- (void) ({ unsigned int __mask = 1 << (bit); \
- if (sizeof (*(mem)) == 1) \
- __asm__ __volatile__ ("\
- .align 2\n\
- mova 1f,r0\n\
- mov r15,r1\n\
- mov #-6,r15\n\
- 0: mov.b @%0,r2\n\
- or %1,r2\n\
- mov.b r2,@%0\n\
- 1: mov r1,r15"\
- : : "r" (mem), "r" (__mask) \
- : "r0", "r1", "r2", "memory"); \
- else if (sizeof (*(mem)) == 2) \
- __asm__ __volatile__ ("\
- .align 2\n\
- mova 1f,r0\n\
- mov r15,r1\n\
- mov #-6,r15\n\
- 0: mov.w @%0,r2\n\
- or %1,r2\n\
- mov.w r2,@%0\n\
- 1: mov r1,r15"\
- : : "r" (mem), "r" (__mask) \
- : "r0", "r1", "r2", "memory"); \
- else if (sizeof (*(mem)) == 4) \
- __asm__ __volatile__ ("\
- .align 2\n\
- mova 1f,r0\n\
- mov r15,r1\n\
- mov #-6,r15\n\
- 0: mov.l @%0,r2\n\
- or %1,r2\n\
- mov.l r2,@%0\n\
- 1: mov r1,r15"\
- : : "r" (mem), "r" (__mask) \
- : "r0", "r1", "r2", "memory"); \
- else \
- abort (); \
- })
-
-#define atomic_bit_test_set(mem, bit) \
- ({ unsigned int __mask = 1 << (bit); \
- unsigned int __result = __mask; \
- if (sizeof (*(mem)) == 1) \
- __asm__ __volatile__ ("\
- .align 2\n\
- mova 1f,r0\n\
- nop\n\
- mov r15,r1\n\
- mov #-8,r15\n\
- 0: mov.b @%2,r2\n\
- or r2,%1\n\
- and r2,%0\n\
- mov.b %1,@%2\n\
- 1: mov r1,r15"\
- : "=&r" (__result), "=&r" (__mask) \
- : "r" (mem), "0" (__result), "1" (__mask) \
- : "r0", "r1", "r2", "memory"); \
- else if (sizeof (*(mem)) == 2) \
- __asm__ __volatile__ ("\
- .align 2\n\
- mova 1f,r0\n\
- nop\n\
- mov r15,r1\n\
- mov #-8,r15\n\
- 0: mov.w @%2,r2\n\
- or r2,%1\n\
- and r2,%0\n\
- mov.w %1,@%2\n\
- 1: mov r1,r15"\
- : "=&r" (__result), "=&r" (__mask) \
- : "r" (mem), "0" (__result), "1" (__mask) \
- : "r0", "r1", "r2", "memory"); \
- else if (sizeof (*(mem)) == 4) \
- __asm__ __volatile__ ("\
- .align 2\n\
- mova 1f,r0\n\
- nop\n\
- mov r15,r1\n\
- mov #-8,r15\n\
- 0: mov.l @%2,r2\n\
- or r2,%1\n\
- and r2,%0\n\
- mov.l %1,@%2\n\
- 1: mov r1,r15"\
- : "=&r" (__result), "=&r" (__mask) \
- : "r" (mem), "0" (__result), "1" (__mask) \
- : "r0", "r1", "r2", "memory"); \
- else \
- abort (); \
- __result; })
+
+#define __arch_bit_set_8_int(mem, value) \
+ __arch_operate_new_n(mem, 1<<(value), b, or)
+
+#define __arch_bit_set_16_int(mem, value) \
+ __arch_operate_new_n(mem, 1<<(value), w, or)
+
+#define __arch_bit_set_32_int(mem, value) \
+ __arch_operate_new_n(mem, 1<<(value), l, or)
+
+#define __arch_bit_set_64_int(mem, value) \
+ (abort (), 0)
+
+#define __arch_add_64_int(mem, value) \
+ (abort (), 0)
+
+#define atomic_bit_set(mem, value) \
+ ((void) __atomic_val_bysize (__arch_bit_set, int, mem, value))
+
+
+#define __arch_bit_test_set_8_int(mem, value) \
+ ({ int32_t __value = 1<<(value), __new, __old; \
+ __arch_operate_old_new_n((mem), __value, __old, __new, b, or); \
+ __old & __value; })
+
+#define __arch_bit_test_set_16_int(mem, value) \
+ ({ int32_t __value = 1<<(value), __new, __old; \
+ __arch_operate_old_new_n((mem), __value, __old, __new, w, or); \
+ __old & __value; })
+
+#define __arch_bit_test_set_32_int(mem, value) \
+ ({ int32_t __value = 1<<(value), __new, __old; \
+ __arch_operate_old_new_n((mem), __value, __old, __new, l, or); \
+ __old & __value; })
+
+#define __arch_bit_test_set_64_int(mem, value) \
+ (abort (), 0)
+
+#define atomic_bit_test_set(mem, value) \
+ __atomic_val_bysize (__arch_bit_test_set, int, mem, value)
diff --git a/libc/sysdeps/linux/sh/bits/fcntl.h b/libc/sysdeps/linux/sh/bits/fcntl.h
index 93c41d225..84720dcc1 100644
--- a/libc/sysdeps/linux/sh/bits/fcntl.h
+++ b/libc/sysdeps/linux/sh/bits/fcntl.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FCNTL_H
# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
@@ -50,9 +49,8 @@
# define O_DIRECTORY 0200000 /* Must be a directory. */
# define O_NOFOLLOW 0400000 /* Do not follow links. */
# define O_NOATIME 01000000 /* Do not set atime. */
-# if 0
# define O_CLOEXEC 02000000 /* Set close_on_exec. */
-# endif
+# define O_PATH 010000000 /* Resolve pathname but do not open file. */
#endif
/* For now Linux has synchronisity options for data and read operations.
@@ -102,6 +100,8 @@
# define F_NOTIFY 1026 /* Request notfications on a directory. */
# define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with
close-on-exit set on new fd. */
+# define F_SETPIPE_SZ 1031 /* Set pipe page size array. */
+# define F_GETPIPE_SZ 1032 /* Get pipe page size array. */
#endif
/* For F_[GET|SET]FD. */
@@ -189,7 +189,7 @@ struct flock64
#endif
-#ifdef __USE_GNU
+#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
@@ -212,7 +212,7 @@ struct flock64
__BEGIN_DECLS
-#ifdef __USE_GNU
+#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)
diff --git a/libc/sysdeps/linux/sh/bits/fenv.h b/libc/sysdeps/linux/sh/bits/fenv.h
index cbbad92e1..38c303ff2 100644
--- a/libc/sysdeps/linux/sh/bits/fenv.h
+++ b/libc/sysdeps/linux/sh/bits/fenv.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FENV_H
# error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
diff --git a/libc/sysdeps/linux/sh/bits/huge_val.h b/libc/sysdeps/linux/sh/bits/huge_val.h
index 732b06503..984faab91 100644
--- a/libc/sysdeps/linux/sh/bits/huge_val.h
+++ b/libc/sysdeps/linux/sh/bits/huge_val.h
@@ -16,9 +16,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _MATH_H
# error "Never use <bits/huge_val.h> directly; include <math.h> instead."
diff --git a/libc/sysdeps/linux/sh/bits/kernel_stat.h b/libc/sysdeps/linux/sh/bits/kernel_stat.h
index 2e88dad82..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... */
@@ -23,12 +19,9 @@ struct kernel_stat {
unsigned long st_size;
unsigned long st_blksize;
unsigned long st_blocks;
- unsigned long st_atime;
- unsigned long __unused1;
- unsigned long st_mtime;
- unsigned long __unused2;
- unsigned long st_ctime;
- unsigned long __unused3;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
unsigned long __unused4;
unsigned long __unused5;
};
@@ -72,14 +65,9 @@ struct kernel_stat64 {
unsigned long __pad4; /* Future possible st_blocks hi bits */
#endif
- unsigned long st_atime;
- unsigned long __pad5;
-
- unsigned long st_mtime;
- unsigned long __pad6;
-
- unsigned long st_ctime;
- unsigned long __pad7; /* will be high 32 bits of ctime someday */
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
unsigned long __unused1;
unsigned long __unused2;
diff --git a/libc/sysdeps/linux/sh/bits/kernel_types.h b/libc/sysdeps/linux/sh/bits/kernel_types.h
index 7d55cf510..ac97261e6 100644
--- a/libc/sysdeps/linux/sh/bits/kernel_types.h
+++ b/libc/sysdeps/linux/sh/bits/kernel_types.h
@@ -4,8 +4,9 @@
* our private content, and not the kernel header, will win.
* -Erik
*/
-#ifndef __ASM_SH_POSIX_TYPES_H
+#if !defined __ASM_SH_POSIX_TYPES_H && !defined __ASM_SH_POSIX_TYPES_32_H
#define __ASM_SH_POSIX_TYPES_H
+#define __ASM_SH_POSIX_TYPES_32_H
typedef unsigned short __kernel_dev_t;
typedef unsigned long __kernel_ino_t;
@@ -31,6 +32,8 @@ typedef unsigned int __kernel_gid32_t;
typedef unsigned short __kernel_old_uid_t;
typedef unsigned short __kernel_old_gid_t;
typedef __kernel_dev_t __kernel_old_dev_t;
+typedef long __kernel_long_t;
+typedef unsigned long __kernel_ulong_t;
typedef long long __kernel_loff_t;
typedef struct {
diff --git a/libc/sysdeps/linux/sh/bits/mathdef.h b/libc/sysdeps/linux/sh/bits/mathdef.h
index 2b8caf194..9c7e0566e 100644
--- a/libc/sysdeps/linux/sh/bits/mathdef.h
+++ b/libc/sysdeps/linux/sh/bits/mathdef.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#if !defined _MATH_H && !defined _COMPLEX_H
# error "Never use <bits/mathdef.h> directly; include <math.h> instead"
@@ -30,32 +29,12 @@
#if defined __USE_ISOC99 && defined _MATH_H && !defined _MATH_H_MATHDEF
# define _MATH_H_MATHDEF 1
-# ifdef __GNUC__
-# if __STDC__ == 1
-
-/* In GNU or ANSI mode, gcc leaves `float' expressions as-is. */
+/* SH has both `float' and `double' arithmetic. */
typedef float float_t; /* `float' expressions are evaluated as
`float'. */
typedef double double_t; /* `double' expressions are evaluated as
`double'. */
-# else
-
-/* For `gcc -traditional', `float' expressions are evaluated as `double'. */
-typedef double float_t; /* `float' expressions are evaluated as
- `double'. */
-typedef double double_t; /* `double' expressions are evaluated as
- `double'. */
-
-# endif
-# else
-
-/* Wild guess at types for float_t and double_t. */
-typedef double float_t;
-typedef double double_t;
-
-# endif
-
/* The values returned by `ilogb' for 0 and NaN respectively. */
# define FP_ILOGB0 0x80000001
# define FP_ILOGBNAN 0x7fffffff
diff --git a/libc/sysdeps/linux/sh/bits/mman.h b/libc/sysdeps/linux/sh/bits/mman.h
deleted file mode 100644
index 7a6b572a4..000000000
--- a/libc/sysdeps/linux/sh/bits/mman.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/* Definitions for POSIX memory map interface. Linux/SH version.
- Copyright (C) 1997,1999,2000,2003,2005,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 _SYS_MMAN_H
-# error "Never include this file directly. Use <sys/mman.h> instead"
-#endif
-
-/* The following definitions basically come from the kernel headers.
- But the kernel header is not namespace clean. */
-
-
-/* Protections are chosen from these bits, OR'd together. The
- implementation does not necessarily support PROT_EXEC or PROT_WRITE
- without PROT_READ. The only guarantees are that no writing will be
- allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
-
-#define PROT_READ 0x1 /* Page can be read. */
-#define PROT_WRITE 0x2 /* Page can be written. */
-#define PROT_EXEC 0x4 /* Page can be executed. */
-#define PROT_NONE 0x0 /* Page can not be accessed. */
-#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of
- growsdown vma (mprotect only). */
-#define PROT_GROWSUP 0x02000000 /* Extend change to start of
- growsup vma (mprotect only). */
-
-/* Sharing types (must choose one and only one of these). */
-#define MAP_SHARED 0x01 /* Share changes. */
-#define MAP_PRIVATE 0x02 /* Changes are private. */
-#ifdef __USE_MISC
-# define MAP_TYPE 0x0f /* Mask for type of mapping. */
-#endif
-
-/* Other flags. */
-#define MAP_FIXED 0x10 /* Interpret addr exactly. */
-#ifdef __USE_MISC
-# define MAP_FILE 0
-# define MAP_ANONYMOUS 0x20 /* Don't use a file. */
-# define MAP_ANON MAP_ANONYMOUS
-#endif
-
-/* These are Linux-specific. */
-#ifdef __USE_MISC
-# define MAP_GROWSDOWN 0x0100 /* Stack-like segment. */
-# define MAP_DENYWRITE 0x0800 /* ETXTBSY */
-# define MAP_EXECUTABLE 0x1000 /* Mark it as an executable. */
-# define MAP_LOCKED 0x2000 /* Lock the mapping. */
-# define MAP_NORESERVE 0x4000 /* Don't check for reservations. */
-# define MAP_POPULATE 0x8000 /* Populate (prefault) pagetables. */
-# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */
-#endif
-
-/* Flags to `msync'. */
-#define MS_ASYNC 1 /* Sync memory asynchronously. */
-#define MS_SYNC 4 /* Synchronous memory sync. */
-#define MS_INVALIDATE 2 /* Invalidate the caches. */
-
-/* Flags for `mlockall'. */
-#define MCL_CURRENT 1 /* Lock all currently mapped pages. */
-#define MCL_FUTURE 2 /* Lock all additions to address
- space. */
-
-/* Flags for `mremap'. */
-#ifdef __USE_GNU
-# define MREMAP_MAYMOVE 1
-# define MREMAP_FIXED 2
-#endif
-
-/* Advice to `madvise'. */
-#ifdef __USE_BSD
-# define MADV_NORMAL 0 /* No further special treatment. */
-# define MADV_RANDOM 1 /* Expect random page references. */
-# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
-# define MADV_WILLNEED 3 /* Will need these pages. */
-# define MADV_DONTNEED 4 /* Don't need these pages. */
-# define MADV_REMOVE 9 /* Remove these pages and resources. */
-# define MADV_DONTFORK 10 /* Do not inherit across fork. */
-# define MADV_DOFORK 11 /* Do inherit across fork. */
-#endif
-
-/* The POSIX people had to invent similar names for the same things. */
-#ifdef __USE_XOPEN2K
-# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
-# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
-# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
-# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
-# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
-#endif
diff --git a/libc/sysdeps/linux/sh/bits/setjmp.h b/libc/sysdeps/linux/sh/bits/setjmp.h
index 6458dfefd..85476a4d8 100644
--- a/libc/sysdeps/linux/sh/bits/setjmp.h
+++ b/libc/sysdeps/linux/sh/bits/setjmp.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999, 2000, 2003, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 1999,2000,2003,2005,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
@@ -12,19 +12,17 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* Define the machine-dependent type `jmp_buf'. SH version. */
#ifndef _BITS_SETJMP_H
-#define _BITS_SETJMP_H 1
+#define _BITS_SETJMP_H 1
#if !defined _SETJMP_H && !defined _PTHREAD_H
# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
#endif
-#ifndef _ASM
typedef struct
{
/* Callee-saved registers r8 through r15. */
@@ -42,15 +40,5 @@ typedef struct
/* Callee-saved floating point registers fr12 through fr15. */
int __fpregs[4];
} __jmp_buf[1];
-#endif
-
-#if defined __USE_MISC || defined _ASM
-# define JB_SIZE (4 * 15)
-#endif
-
-/* Test if longjmp to JMPBUF would unwind the frame
- containing a local variable at ADDRESS. */
-#define _JMPBUF_UNWINDS(jmpbuf, address) \
- ((void *) (address) < (void *) (jmpbuf)[0].__regs[7])
-#endif /* bits/setjmp.h */
+#endif /* bits/setjmp.h */
diff --git a/libc/sysdeps/linux/sh/bits/shm.h b/libc/sysdeps/linux/sh/bits/shm.h
index ccf4b8943..646e5badc 100644
--- a/libc/sysdeps/linux/sh/bits/shm.h
+++ b/libc/sysdeps/linux/sh/bits/shm.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_SHM_H
# error "Never include <bits/shm.h> directly; use <sys/shm.h> instead."
diff --git a/libc/sysdeps/linux/sh/bits/sigcontextinfo.h b/libc/sysdeps/linux/sh/bits/sigcontextinfo.h
index 3e1f3e949..13b36acf7 100644
--- a/libc/sysdeps/linux/sh/bits/sigcontextinfo.h
+++ b/libc/sysdeps/linux/sh/bits/sigcontextinfo.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#define SIGCONTEXT int _a2, int _a3, int _a4, struct sigcontext
diff --git a/libc/sysdeps/linux/sh/bits/stackinfo.h b/libc/sysdeps/linux/sh/bits/stackinfo.h
index e65338f25..c52e7d7b7 100644
--- a/libc/sysdeps/linux/sh/bits/stackinfo.h
+++ b/libc/sysdeps/linux/sh/bits/stackinfo.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* This file contains a bit of information about the stack allocation
of the processor. */
diff --git a/libc/sysdeps/linux/sh/bits/syscalls.h b/libc/sysdeps/linux/sh/bits/syscalls.h
index e0ab65b82..efd423ed3 100644
--- a/libc/sysdeps/linux/sh/bits/syscalls.h
+++ b/libc/sysdeps/linux/sh/bits/syscalls.h
@@ -5,7 +5,7 @@
#endif
/* The Linux kernel uses different trap numbers on sh-2. */
-#ifdef __CONFIG_SH2__
+#if defined __sh2__ || defined __SH2A__
# define __SH_SYSCALL_TRAP_BASE 0x20
#else
# define __SH_SYSCALL_TRAP_BASE 0x10
@@ -15,138 +15,14 @@
#include <errno.h>
-#define SYS_ify(syscall_name) (__NR_##syscall_name)
-
-/* user-visible error numbers are in the range -1 - -125: see <asm-sh/errno.h> */
-#define __syscall_return(type, res) \
-do { \
- if ((unsigned long)(res) >= (unsigned long)(-125)) { \
- /* Avoid using "res" which is declared to be in register r0; \
- errno might expand to a function call and clobber it. */ \
- int __err = -(res); \
- __set_errno(__err); \
- res = -1; \
- } \
- return (type) (res); \
-} while (0)
-
-/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
-#define _syscall0(type,name) \
-type name(void) \
-{ \
-register long __sc0 __asm__ ("r3") = __NR_##name; \
-__asm__ __volatile__ ("trapa %1" \
- : "=z" (__sc0) \
- : "i" (__SH_SYSCALL_TRAP_BASE), "0" (__sc0) \
- : "memory" ); \
-__syscall_return(type,__sc0); \
-}
-
-#define _syscall1(type,name,type1,arg1) \
-type name(type1 arg1) \
-{ \
-register long __sc0 __asm__ ("r3") = __NR_##name; \
-register long __sc4 __asm__ ("r4") = (long) arg1; \
-__asm__ __volatile__ ("trapa %1" \
- : "=z" (__sc0) \
- : "i" (__SH_SYSCALL_TRAP_BASE + 1), "0" (__sc0), "r" (__sc4) \
- : "memory"); \
-__syscall_return(type,__sc0); \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name(type1 arg1,type2 arg2) \
-{ \
-register long __sc0 __asm__ ("r3") = __NR_##name; \
-register long __sc4 __asm__ ("r4") = (long) arg1; \
-register long __sc5 __asm__ ("r5") = (long) arg2; \
-__asm__ __volatile__ ("trapa %1" \
- : "=z" (__sc0) \
- : "i" (__SH_SYSCALL_TRAP_BASE + 2), "0" (__sc0), "r" (__sc4), \
- "r" (__sc5) \
- : "memory"); \
-__syscall_return(type,__sc0); \
-}
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name(type1 arg1,type2 arg2,type3 arg3) \
-{ \
-register long __sc0 __asm__ ("r3") = __NR_##name; \
-register long __sc4 __asm__ ("r4") = (long) arg1; \
-register long __sc5 __asm__ ("r5") = (long) arg2; \
-register long __sc6 __asm__ ("r6") = (long) arg3; \
-__asm__ __volatile__ ("trapa %1" \
- : "=z" (__sc0) \
- : "i" (__SH_SYSCALL_TRAP_BASE + 3), "0" (__sc0), "r" (__sc4), \
- "r" (__sc5), "r" (__sc6) \
- : "memory"); \
-__syscall_return(type,__sc0); \
-}
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
-{ \
-register long __sc0 __asm__ ("r3") = __NR_##name; \
-register long __sc4 __asm__ ("r4") = (long) arg1; \
-register long __sc5 __asm__ ("r5") = (long) arg2; \
-register long __sc6 __asm__ ("r6") = (long) arg3; \
-register long __sc7 __asm__ ("r7") = (long) arg4; \
-__asm__ __volatile__ ("trapa %1" \
- : "=z" (__sc0) \
- : "i" (__SH_SYSCALL_TRAP_BASE + 4), "0" (__sc0), "r" (__sc4), \
- "r" (__sc5), "r" (__sc6), \
- "r" (__sc7) \
- : "memory" ); \
-__syscall_return(type,__sc0); \
-}
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
-{ \
-register long __sc3 __asm__ ("r3") = __NR_##name; \
-register long __sc4 __asm__ ("r4") = (long) arg1; \
-register long __sc5 __asm__ ("r5") = (long) arg2; \
-register long __sc6 __asm__ ("r6") = (long) arg3; \
-register long __sc7 __asm__ ("r7") = (long) arg4; \
-register long __sc0 __asm__ ("r0") = (long) arg5; \
-__asm__ __volatile__ ("trapa %1" \
- : "=z" (__sc0) \
- : "i" (__SH_SYSCALL_TRAP_BASE + 5), "0" (__sc0), "r" (__sc4), \
- "r" (__sc5), "r" (__sc6), "r" (__sc7), "r" (__sc3) \
- : "memory" ); \
-__syscall_return(type,__sc0); \
-}
-
-#ifndef __SH_SYSCALL6_TRAPA
-#define __SH_SYSCALL6_TRAPA __SH_SYSCALL_TRAP_BASE + 6
-#endif
-
-/* Add in _syscall6 which is not in the kernel header */
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
-{ \
-register long __sc3 __asm__ ("r3") = __NR_##name; \
-register long __sc4 __asm__ ("r4") = (long) arg1; \
-register long __sc5 __asm__ ("r5") = (long) arg2; \
-register long __sc6 __asm__ ("r6") = (long) arg3; \
-register long __sc7 __asm__ ("r7") = (long) arg4; \
-register long __sc0 __asm__ ("r0") = (long) arg5; \
-register long __sc1 __asm__ ("r1") = (long) arg6; \
-__asm__ __volatile__ ("trapa %1" \
- : "=z" (__sc0) \
- : "i" (__SH_SYSCALL6_TRAPA), "0" (__sc0), "r" (__sc4), \
- "r" (__sc5), "r" (__sc6), "r" (__sc7), "r" (__sc3), "r" (__sc1) \
- : "memory" ); \
-__syscall_return(type,__sc0); \
-}
-
-#define SYSCALL_INST_STR0 "trapa #0x10\n\t"
-#define SYSCALL_INST_STR1 "trapa #0x11\n\t"
-#define SYSCALL_INST_STR2 "trapa #0x12\n\t"
-#define SYSCALL_INST_STR3 "trapa #0x13\n\t"
-#define SYSCALL_INST_STR4 "trapa #0x14\n\t"
-#define SYSCALL_INST_STR5 "trapa #0x15\n\t"
-#define SYSCALL_INST_STR6 "trapa #0x16\n\t"
+#define SYSCALL_INST_STR(x) "trapa #"__stringify(__SH_SYSCALL_TRAP_BASE + x)"\n\t"
+#define SYSCALL_INST_STR0 SYSCALL_INST_STR(0)
+#define SYSCALL_INST_STR1 SYSCALL_INST_STR(1)
+#define SYSCALL_INST_STR2 SYSCALL_INST_STR(2)
+#define SYSCALL_INST_STR3 SYSCALL_INST_STR(3)
+#define SYSCALL_INST_STR4 SYSCALL_INST_STR(4)
+#define SYSCALL_INST_STR5 SYSCALL_INST_STR(5)
+#define SYSCALL_INST_STR6 SYSCALL_INST_STR(6)
# ifdef NEED_SYSCALL_INST_PAD
# define SYSCALL_INST_PAD "\
@@ -236,55 +112,24 @@ __syscall_return(type,__sc0); \
register long int r1 __asm__ ("%r1") = (long int) (_arg6); \
register long int r2 __asm__ ("%r2") = (long int) (_arg7)
-#undef INLINE_SYSCALL
-#define INLINE_SYSCALL(name, nr, args...) \
- ({ \
- unsigned int __resultvar = INTERNAL_SYSCALL (name, , nr, args); \
- if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (__resultvar, ), 0)) \
- { \
- __set_errno (INTERNAL_SYSCALL_ERRNO (__resultvar, )); \
- __resultvar = 0xffffffff; \
- } \
- (int) __resultvar; })
-
-#undef INTERNAL_SYSCALL
-#define INTERNAL_SYSCALL(name, err, nr, args...) \
- ({ \
- unsigned long int resultvar; \
- register long int r3 __asm__ ("%r3") = SYS_ify (name); \
- SUBSTITUTE_ARGS_##nr(args); \
- \
- __asm__ volatile (SYSCALL_INST_STR##nr SYSCALL_INST_PAD \
- : "=z" (resultvar) \
- : "r" (r3) ASMFMT_##nr \
- : "memory"); \
- \
- (int) resultvar; })
-
/* The _NCS variant allows non-constant syscall numbers. */
#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
- ({ \
- unsigned long int resultvar; \
- register long int r3 __asm__ ("%r3") = (name); \
- SUBSTITUTE_ARGS_##nr(args); \
- \
- __asm__ volatile (SYSCALL_INST_STR##nr SYSCALL_INST_PAD \
- : "=z" (resultvar) \
- : "r" (r3) ASMFMT_##nr \
- : "memory"); \
- \
- (int) resultvar; })
-
-#undef INTERNAL_SYSCALL_DECL
-#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
-
-#undef INTERNAL_SYSCALL_ERROR_P
+(__extension__ \
+ ({ \
+ unsigned long int resultvar; \
+ register long int r3 __asm__ ("%r3") = (name); \
+ SUBSTITUTE_ARGS_##nr(args); \
+ __asm__ __volatile__ (SYSCALL_INST_STR##nr SYSCALL_INST_PAD \
+ : "=z" (resultvar) \
+ : "r" (r3) ASMFMT_##nr \
+ : "memory", "t" \
+ ); \
+ (int) resultvar; \
+ }) \
+)
#define INTERNAL_SYSCALL_ERROR_P(val, err) \
((unsigned int) (val) >= 0xfffff001u)
-#undef INTERNAL_SYSCALL_ERRNO
-#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
-
#endif /* __ASSEMBLER__ */
#endif /* _BITS_SYSCALLS_H */
diff --git a/libc/sysdeps/linux/sh/bits/uClibc_arch_features.h b/libc/sysdeps/linux/sh/bits/uClibc_arch_features.h
index 55e34804f..401bd45d6 100644
--- a/libc/sysdeps/linux/sh/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/sh/bits/uClibc_arch_features.h
@@ -6,7 +6,7 @@
#define _BITS_UCLIBC_ARCH_FEATURES_H
/* instruction used when calling abort() to kill yourself */
-#if defined(__CONFIG_SH2__)
+#ifdef __sh2__
# define __UCLIBC_ABORT_INSTRUCTION__ "trapa #32"
#else
# define __UCLIBC_ABORT_INSTRUCTION__ "trapa #0xff"
@@ -15,8 +15,8 @@
/* 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 align 64bit values in register pairs ? (32bit arches only) */
+#undef __UCLIBC_SYSCALL_ALIGN_64BIT__
/* does your target have a broken create_module() ? */
#undef __UCLIBC_BROKEN_CREATE_MODULE__
@@ -27,19 +27,19 @@
/* 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 */
+#define __UCLIBC_HAVE_ASM_CFI_DIRECTIVES__
/* define if target supports IEEE signed zero floats */
#define __UCLIBC_HAVE_SIGNED_ZERO__
+/* only weird assemblers generally need this */
+#undef __UCLIBC_ASM_LINE_SEP__
+
#endif /* _BITS_UCLIBC_ARCH_FEATURES_H */
diff --git a/libc/sysdeps/linux/sh/bits/wordsize.h b/libc/sysdeps/linux/sh/bits/wordsize.h
index ba643b60a..ca82fd7d4 100644
--- a/libc/sysdeps/linux/sh/bits/wordsize.h
+++ b/libc/sysdeps/linux/sh/bits/wordsize.h
@@ -12,8 +12,7 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#define __WORDSIZE 32
diff --git a/libc/sysdeps/linux/sh/brk.c b/libc/sysdeps/linux/sh/brk.c
index c69c97ad6..a98cd5446 100644
--- a/libc/sysdeps/linux/sh/brk.c
+++ b/libc/sysdeps/linux/sh/brk.c
@@ -13,7 +13,6 @@ extern void * __curbrk attribute_hidden;
extern int __init_brk (void) attribute_hidden;
extern void *_brk(void *ptr) attribute_hidden;
-libc_hidden_proto(brk)
int brk(void * end_data_seg)
{
if (__init_brk () == 0)
diff --git a/libc/sysdeps/linux/sh/cacheflush.c b/libc/sysdeps/linux/sh/cacheflush.c
new file mode 100644
index 000000000..619b96b5a
--- /dev/null
+++ b/libc/sysdeps/linux/sh/cacheflush.c
@@ -0,0 +1,14 @@
+/*
+ * cacheflush syscall for SUPERH
+ *
+ * Copyright (C) 2009 STMicroelectronics Ltd
+ * Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+#include <sys/syscall.h>
+
+#ifdef __NR_cacheflush
+int cacheflush(void *addr, const int nbytes, int op);
+_syscall3(int, cacheflush, void *, addr, const int, nbytes, const int, op)
+#endif
diff --git a/libc/sysdeps/linux/sh/clone.S b/libc/sysdeps/linux/sh/clone.S
index 386b4ceb1..3ed6b25de 100644
--- a/libc/sysdeps/linux/sh/clone.S
+++ b/libc/sysdeps/linux/sh/clone.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2000, 2003, 2004, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -12,101 +12,117 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* clone() is even more special than fork() as it mucks with stacks
and invokes a function in the right context after its all over. */
#include <features.h>
-#include <sys/syscall.h>
-#define _ERRNO_H
+#include <asm/unistd.h>
+#include <sysdep.h>
+#define _ERRNO_H 1
#include <bits/errno.h>
-#include <bits/sysnum.h>
-
-
-#ifdef __HAVE_SHARED__
-#define PLTJMP(_x) _x@PLT
-#else
-#define PLTJMP(_x) _x
+#ifdef RESET_PID
+#include <tcb-offsets.h>
#endif
+/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg,
+ pid_t *ptid, void *tls, pid_t *ctid); */
-
-/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */
-
- .text
-
-.text
-.align 4
-.type clone,@function
-.globl clone;
-clone:
+ .text
+ENTRY(__clone)
/* sanity check arguments. */
tst r4, r4
- bt 0f
- tst r5, r5
- bf/s 1f
- mov #+__NR_clone, r3
-0:
- bra __syscall_error
- mov #-EINVAL, r4
-
+ bt/s 0f
+ tst r5, r5
+ bf 1f
+0:
+ bra .Lsyscall_error
+ mov #-EINVAL,r0
1:
/* insert the args onto the new stack */
mov.l r7, @-r5
/* save the function pointer as the 0th element */
mov.l r4, @-r5
-
+
/* do the system call */
mov r6, r4
- trapa #(__SH_SYSCALL_TRAP_BASE + 2)
+ mov.l @r15, r6
+ mov.l @(8,r15), r7
+ mov.l @(4,r15), r0
+ mov #+SYS_ify(clone), r3
+ trapa #0x15
mov r0, r1
-#ifdef __CONFIG_SH2__
-// 12 arithmetic shifts for the crappy sh2, because shad doesn't exist!
- shar r1
- shar r1
- shar r1
- shar r1
- shar r1
- shar r1
- shar r1
- shar r1
- shar r1
- shar r1
- shar r1
- shar r1
-#else
+#ifdef __sh2__
+/* 12 arithmetic shifts for the sh2, because shad doesn't exist! */
+ shar r1
+ shar r1
+ shar r1
+ shar r1
+ shar r1
+ shar r1
+ shar r1
+ shar r1
+ shar r1
+ shar r1
+ shar r1
+ shar r1
+#else
mov #-12, r2
shad r2, r1
#endif
not r1, r1 // r1=0 means r0 = -1 to -4095
tst r1, r1 // i.e. error in linux
- bf/s 2f
- tst r0, r0
- bra __syscall_error
- mov r0, r4
-
-2:
- bt 3f
+ bf .Lclone_end
+.Lsyscall_error:
+ SYSCALL_ERROR_HANDLER
+.Lclone_end:
+ tst r0, r0
+ bt 2f
+.Lpseudo_end:
rts
nop
+2:
+ /* terminate the stack frame */
+ mov #0, r14
+#ifdef RESET_PID
+ mov r4, r0
+ shlr16 r0
+ tst #1, r0 // CLONE_THREAD = (1 << 16)
+ bf/s 4f
+ mov r4, r0
+ /* new pid */
+ shlr8 r0
+ tst #1, r0 // CLONE_VM = (1 << 8)
+ bf/s 3f
+ mov #-1, r0
+ mov #+SYS_ify(getpid), r3
+ trapa #0x15
3:
+ stc gbr, r1
+ mov.w .Lpidoff, r2
+ add r1, r2
+ mov.l r0, @r2
+ mov.w .Ltidoff, r2
+ add r1, r2
+ mov.l r0, @r2
+4:
+#endif
/* thread starts */
mov.l @r15, r1
jsr @r1
mov.l @(4,r15), r4
/* we are done, passing the return value through r0 */
- mov.l .L1, r1
-#ifdef __HAVE_SHARED__
+ mov.l .L3, r1
+#ifdef SHARED
mov.l r12, @-r15
sts.l pr, @-r15
mov r0, r4
- mova .LG, r0 /* .LG from syscall_error.S */
+ mova .LG, r0
mov.l .LG, r12
add r0, r12
- mova .L1, r0
+ mova .L3, r0
add r0, r1
jsr @r1
nop
@@ -118,8 +134,16 @@ clone:
mov r0, r4
#endif
.align 2
-.L1:
- .long PLTJMP( HIDDEN_JUMPTARGET(_exit))
-.size clone,.-clone;
+.LG:
+ .long _GLOBAL_OFFSET_TABLE_
+.L3:
+ .long PLTJMP(C_SYMBOL_NAME(_exit))
+#ifdef RESET_PID
+.Lpidoff:
+ .word PID - TLS_PRE_TCB_SIZE
+.Ltidoff:
+ .word TID - TLS_PRE_TCB_SIZE
+#endif
+PSEUDO_END (__clone)
-#include "syscall_error.S"
+weak_alias (__clone, clone)
diff --git a/libc/sysdeps/linux/sh/crt1.S b/libc/sysdeps/linux/sh/crt1.S
index 1c3c54447..2d3e68ed2 100644
--- a/libc/sysdeps/linux/sh/crt1.S
+++ b/libc/sysdeps/linux/sh/crt1.S
@@ -14,8 +14,7 @@
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
+ along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
@@ -56,6 +55,35 @@ _start:
/* Push the stack_end, rtld_fini and fini func onto the stack */
mov.l r6,@-r15
mov.l r4,@-r15
+
+#ifdef __PIC__
+ mova L_got, r0
+ mov.l L_got, r12
+ add r0, r12
+
+ mov.l L_fini,r0
+ add r12, r0
+ mov.l r0,@-r15
+
+ /* Set up the main/init funcs that go in registers */
+ mov.l L_main, r4
+ add r12, r4
+ mov.l L_init, r7
+ add r12, r7
+
+ /* __uClibc_main (main, argc, argv, init, fini, rtld_fini, stack_end) */
+
+ /* Let the libc call main and exit with its return code. */
+ mov.l L_uClibc_main,r0
+ mov.l @(r0,r12),r1
+ jsr @r1
+ nop
+ /* We should not get here. */
+ mov.l L_abort,r0
+ mov.l @(r0,r12),r1
+ jsr @r1
+ nop
+#else
mov.l L_fini,r0
mov.l r0,@-r15
@@ -73,10 +101,25 @@ _start:
mov.l L_abort,r1
jmp @r1
nop
+#endif
.size _start,.-_start
.align 2
+#ifdef __PIC__
+L_got:
+ .long _GLOBAL_OFFSET_TABLE_
+L_main:
+ .long main@GOTOFF
+L_init:
+ .long _init@GOTOFF
+L_fini:
+ .long _fini@GOTOFF
+L_uClibc_main:
+ .long __uClibc_main@GOT
+L_abort:
+ .long abort@GOT
+#else
L_main:
.long main
L_init:
@@ -87,6 +130,7 @@ L_uClibc_main:
.long __uClibc_main
L_abort:
.long abort
+#endif
/* Define a symbol for the first piece of initialized data. */
.data
diff --git a/libc/sysdeps/linux/sh/crtn.S b/libc/sysdeps/linux/sh/crtn.S
index 437f8ebc3..e8be7e51f 100644
--- a/libc/sysdeps/linux/sh/crtn.S
+++ b/libc/sysdeps/linux/sh/crtn.S
@@ -15,7 +15,6 @@
.align 2
.L6:
.L7:
- .size _init, .-_init
.section .fini
.hidden _fini
@@ -31,6 +30,5 @@
.align 2
.L11:
.L12:
- .size _fini, .-_fini
.ident "GCC: (GNU) 3.3.2"
diff --git a/libc/sysdeps/linux/sh/fpu_control.h b/libc/sysdeps/linux/sh/fpu_control.h
index db3cc4557..8143041fe 100644
--- a/libc/sysdeps/linux/sh/fpu_control.h
+++ b/libc/sysdeps/linux/sh/fpu_control.h
@@ -1,5 +1,5 @@
/* FPU control word definitions. SH version.
- Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1999, 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
@@ -13,14 +13,15 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FPU_CONTROL_H
#define _FPU_CONTROL_H
-#warning This file is only correct for sh4
+#ifndef __SH4__
+#error This file is only correct for sh4
+#endif
/* masking of interrupts */
#define _FPU_MASK_VM 0x0800 /* Invalid operation */
@@ -47,6 +48,8 @@ typedef unsigned int fpu_control_t;
#define _FPU_GETCW(cw) __asm__ ("sts fpscr,%0" : "=r" (cw))
#if defined __GNUC__
+/* GCC provides this function */
+extern void __set_fpscr (unsigned long);
#define _FPU_SETCW(cw) __set_fpscr ((cw))
#else
#define _FPU_SETCW(cw) __asm__ ("lds %0,fpscr" : : "r" (cw))
diff --git a/libc/sysdeps/linux/sh/jmpbuf-offsets.h b/libc/sysdeps/linux/sh/jmpbuf-offsets.h
new file mode 100644
index 000000000..0b824b205
--- /dev/null
+++ b/libc/sysdeps/linux/sh/jmpbuf-offsets.h
@@ -0,0 +1,19 @@
+/* Private macros for accessing __jmp_buf contents. SH version.
+ Copyright (C) 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#define JB_SIZE (4 * 15)
diff --git a/libc/sysdeps/linux/sh/jmpbuf-unwind.h b/libc/sysdeps/linux/sh/jmpbuf-unwind.h
new file mode 100644
index 000000000..8875cc1c8
--- /dev/null
+++ b/libc/sysdeps/linux/sh/jmpbuf-unwind.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+#include <setjmp.h>
+
+/* Test if longjmp to JMPBUF would unwind the frame
+ containing a local variable at ADDRESS. */
+#define _JMPBUF_UNWINDS(jmpbuf, address) \
+ ((void *) (address) < (void *) (jmpbuf)[0].__regs[7])
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <stdint.h>
+#include <unwind.h>
+
+#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
+ _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
+
+#define _JMPBUF_UNWINDS_ADJ(jmpbuf, address, adj) \
+ ((uintptr_t) (address) - (adj) < (uintptr_t) (jmpbuf)[0].__regs[7] - (adj))
+#endif
diff --git a/libc/sysdeps/linux/sh/mmap.c b/libc/sysdeps/linux/sh/mmap.c
deleted file mode 100644
index e711b0ff8..000000000
--- a/libc/sysdeps/linux/sh/mmap.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Copyright (C) 2001 Hewlett-Packard
-
- 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
-
- Derived in part from the Linux-8086 C library, the GNU C Library, and several
- other sundry sources. Files within this library are copyright by their
- respective copyright holders.
-*/
-
-#include <unistd.h>
-#include <errno.h>
-#include <sys/mman.h>
-
-libc_hidden_proto(mmap)
-
-#ifdef HIOS
-# define __SH_SYSCALL6_TRAPA 0x2E
-#endif
-
-#include <sys/syscall.h>
-
-_syscall6(__ptr_t, mmap, __ptr_t, addr, size_t, len, int, prot, int, flags, int, fd, __off_t, offset);
-libc_hidden_def(mmap)
diff --git a/libc/sysdeps/linux/sh/pipe.c b/libc/sysdeps/linux/sh/pipe.c
index 432a5bc03..799f51839 100644
--- a/libc/sysdeps/linux/sh/pipe.c
+++ b/libc/sysdeps/linux/sh/pipe.c
@@ -12,7 +12,6 @@
#include <unistd.h>
#include <syscall.h>
-libc_hidden_proto(pipe)
int pipe(int *fd)
{
diff --git a/libc/sysdeps/linux/sh/pread_write.c b/libc/sysdeps/linux/sh/pread_write.c
index 1fef23ae8..5877f686f 100644
--- a/libc/sysdeps/linux/sh/pread_write.c
+++ b/libc/sysdeps/linux/sh/pread_write.c
@@ -4,80 +4,8 @@
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-/*
- * 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...
- */
-
-#include <sys/syscall.h>
-#include <unistd.h>
-#include <stdint.h>
-#include <endian.h>
-
-#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
-
-#ifdef __NR_pread
-extern __typeof(pread) __libc_pread;
-# define __NR___syscall_pread __NR_pread
-static __inline__ _syscall6(ssize_t, __syscall_pread, int, fd, void *, buf,
- size_t, count, int, dummy, 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,0,__LONG_LONG_PAIR(offset >> 31,offset)));
-}
-weak_alias(__libc_pread,pread)
-
-# ifdef __UCLIBC_HAS_LFS__
-extern __typeof(pread64) __libc_pread64;
-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, 0, __LONG_LONG_PAIR (high, low)));
-}
-weak_alias(__libc_pread64,pread64)
-# endif /* __UCLIBC_HAS_LFS__ */
-#endif /* __NR_pread */
-
-/**********************************************************************/
-
-#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
-
-#ifdef __NR_pwrite
-extern __typeof(pwrite) __libc_pwrite;
-# define __NR___syscall_pwrite __NR_pwrite
-static __inline__ _syscall6(ssize_t, __syscall_pwrite, int, fd, const void *, buf,
- size_t, count, int, dummy, 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,0,__LONG_LONG_PAIR(offset >> 31,offset)));
-}
-weak_alias(__libc_pwrite,pwrite)
-# ifdef __UCLIBC_HAS_LFS__
-extern __typeof(pwrite64) __libc_pwrite64;
-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, 0, __LONG_LONG_PAIR (high, low)));
-}
-weak_alias(__libc_pwrite64,pwrite64)
-# endif /* __UCLIBC_HAS_LFS__ */
-#endif /* __NR_pwrite */
+/* SuperH doesn't have this alignment issue. It just decided to copy
+ * the syscall interface from another arch for no good reason. */
+#define __UCLIBC_SYSCALL_ALIGN_64BIT__
+#include "../common/pread_write.c"
diff --git a/libc/sysdeps/linux/sh/sbrk.c b/libc/sysdeps/linux/sh/sbrk.c
index a1ff2a148..2dc719a16 100644
--- a/libc/sysdeps/linux/sh/sbrk.c
+++ b/libc/sysdeps/linux/sh/sbrk.c
@@ -8,7 +8,6 @@ extern void * __curbrk attribute_hidden;
extern int __init_brk (void) attribute_hidden;
extern void *_brk(void *ptr) attribute_hidden;
-libc_hidden_proto(sbrk)
void *
sbrk(intptr_t increment)
{
diff --git a/libc/sysdeps/linux/sh/setjmp.S b/libc/sysdeps/linux/sh/setjmp.S
index 3296c2ba9..d27cf394c 100644
--- a/libc/sysdeps/linux/sh/setjmp.S
+++ b/libc/sysdeps/linux/sh/setjmp.S
@@ -14,13 +14,10 @@
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. */
+ see <http://www.gnu.org/licenses/>. */
#include <features.h>
-#define _SETJMP_H
-#define _ASM
-#include <bits/setjmp.h>
+#include <jmpbuf-offsets.h>
.text
@@ -77,7 +74,7 @@ __sigsetjmp_intern:
mov.l r9, @-r4
mov.l r8, @-r4
-#ifdef __HAVE_SHARED__
+#ifdef __HAVE_SHARED__
mov.l .LG, r2
mova .LG, r0
add r0, r2
diff --git a/libc/sysdeps/linux/sh/sys/io.h b/libc/sysdeps/linux/sh/sys/io.h
index 6fdc44ff8..6f8ef2f19 100644
--- a/libc/sysdeps/linux/sh/sys/io.h
+++ b/libc/sysdeps/linux/sh/sys/io.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_IO_H
@@ -23,6 +22,7 @@
__BEGIN_DECLS
+#if defined __UCLIBC_LINUX_SPECIFIC__
/* If TURN_ON is TRUE, request for permission to do direct i/o on the
port numbers in the range [FROM,FROM+NUM-1]. Otherwise, turn I/O
permission off for that range. This call requires root privileges. */
@@ -33,6 +33,7 @@ extern int ioperm (unsigned long int __from, unsigned long int __num,
permission to access any I/O port is granted. This call requires
root privileges. */
extern int iopl (int __level) __THROW;
+#endif /* __UCLIBC_LINUX_SPECIFIC__ */
/* The functions that actually perform reads and writes. */
extern unsigned char inb (unsigned long int port) __THROW;
diff --git a/libc/sysdeps/linux/sh/sys/procfs.h b/libc/sysdeps/linux/sh/sys/procfs.h
index aad21e5f8..5fc4c579c 100644
--- a/libc/sysdeps/linux/sh/sys/procfs.h
+++ b/libc/sysdeps/linux/sh/sys/procfs.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_PROCFS_H
#define _SYS_PROCFS_H 1
diff --git a/libc/sysdeps/linux/sh/sys/ucontext.h b/libc/sysdeps/linux/sh/sys/ucontext.h
index 0996bf2d5..230b52444 100644
--- a/libc/sysdeps/linux/sh/sys/ucontext.h
+++ b/libc/sysdeps/linux/sh/sys/ucontext.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* Where is System V/SH ABI? */
@@ -32,10 +31,10 @@
typedef int greg_t;
/* Number of general registers. */
-#define NFPREG 16
+#define NGREG 16
/* Container for all general registers. */
-typedef greg_t gregset_t[NFPREG];
+typedef greg_t gregset_t[NGREG];
#ifdef __USE_GNU
/* Number of each register is the `gregset_t' array. */
@@ -98,7 +97,7 @@ typedef struct
unsigned int mach;
unsigned int macl;
-#ifdef __CONFIG_SH4__
+#ifdef __SH4__
/* FPU registers */
fpregset_t fpregs;
fpregset_t xfpregs;
diff --git a/libc/sysdeps/linux/sh/sys/user.h b/libc/sysdeps/linux/sh/sys/user.h
index b1adc13b7..0c6355a51 100644
--- a/libc/sysdeps/linux/sh/sys/user.h
+++ b/libc/sysdeps/linux/sh/sys/user.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_USER_H
#define _SYS_USER_H 1
@@ -22,6 +21,17 @@
#include <unistd.h>
#include <asm/ptrace.h>
+/* asm/ptrace.h polutes the namespace. */
+#undef PTRACE_GETREGS
+#undef PTRACE_SETREGS
+#undef PTRACE_GETFPREGS
+#undef PTRACE_SETFPREGS
+#undef PTRACE_GETFDPIC
+#undef PTRACE_GETFDPIC_EXEC
+#undef PTRACE_GETFDPIC_INTERP
+#undef PTRACE_GETDSPREGS
+#undef PTRACE_SETDSPREGS
+
/*
* Core file format: The core file is written in such a way that gdb
* can understand it and provide useful information to the user (under
diff --git a/libc/sysdeps/linux/sh/syscall.c b/libc/sysdeps/linux/sh/syscall.c
deleted file mode 100644
index ba187c9b7..000000000
--- a/libc/sysdeps/linux/sh/syscall.c
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-#include <features.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/syscall.h>
-
-long syscall(long sysnum,
- long arg1, long arg2, long arg3,
- long arg4, long arg5, long arg6)
-{
-register long __sc3 __asm__ ("r3") = sysnum;
-register long __sc4 __asm__ ("r4") = (long) arg1;
-register long __sc5 __asm__ ("r5") = (long) arg2;
-register long __sc6 __asm__ ("r6") = (long) arg3;
-register long __sc7 __asm__ ("r7") = (long) arg4;
-register long __sc0 __asm__ ("r0") = (long) arg5;
-register long __sc1 __asm__ ("r1") = (long) arg6;
-__asm__ __volatile__ (
- "trapa %1"
- : "=z" (__sc0) \
- : "i" (__SH_SYSCALL_TRAP_BASE + 6),
- "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6), "r" (__sc7), \
- "r" (__sc3), "r" (__sc1) \
- : "memory" );
-__syscall_return(long,__sc0);
-}
diff --git a/libc/sysdeps/linux/sh/syscall_error.S b/libc/sysdeps/linux/sh/syscall_error.S
index 1764ebfc8..737950308 100644
--- a/libc/sysdeps/linux/sh/syscall_error.S
+++ b/libc/sysdeps/linux/sh/syscall_error.S
@@ -3,7 +3,7 @@ __syscall_error:
/* Call errno_location, store '-r4' in errno and return -1 */
mov.l r12, @-r15
sts.l pr, @-r15
-#ifdef __HAVE_SHARED__
+#ifdef SHARED
mova .LG, r0
mov.l .LG, r12
add r0, r12
@@ -27,7 +27,7 @@ __syscall_error:
.align 4
-#ifdef __HAVE_SHARED__
+#ifdef SHARED
1: .long __errno_location@GOT
.LG: .long _GLOBAL_OFFSET_TABLE_
#else
diff --git a/libc/sysdeps/linux/sh/sysdep.h b/libc/sysdeps/linux/sh/sysdep.h
new file mode 100644
index 000000000..b9b0009a5
--- /dev/null
+++ b/libc/sysdeps/linux/sh/sysdep.h
@@ -0,0 +1,293 @@
+/* Assembler macros for SH.
+ Copyright (C) 1999, 2000, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <common/sysdep.h>
+
+#include <features.h>
+
+#ifdef __ASSEMBLER__
+
+/* Syntactic details of assembler. */
+
+#define LOCAL(X) .L_##X
+#define ALIGNARG(log2) log2
+/* For ELF we need the `.type' directive to make shared libs work right. */
+#define ASM_TYPE_DIRECTIVE(name,typearg) .type name,@##typearg;
+#define ASM_SIZE_DIRECTIVE(name) .size name,.-name
+
+#ifdef SHARED
+#define PLTJMP(_x) _x##@PLT
+#else
+#define PLTJMP(_x) _x
+#endif
+
+/* Define an entry point visible from C. */
+#define ENTRY(name) \
+ .globl C_SYMBOL_NAME(name); \
+ ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),function) \
+ .align ALIGNARG(5); \
+ C_LABEL(name) \
+ cfi_startproc; \
+ CALL_MCOUNT
+
+#undef END
+#define END(name) \
+ cfi_endproc; \
+ ASM_SIZE_DIRECTIVE(C_SYMBOL_NAME(name))
+
+/* If compiled for profiling, call `mcount' at the start of each function. */
+#ifdef PROF
+#define CALL_MCOUNT \
+ mov.l 1f,r1; \
+ sts.l pr,@-r15; \
+ cfi_adjust_cfa_offset (4); \
+ cfi_rel_offset (pr, 0); \
+ mova 2f,r0; \
+ jmp @r1; \
+ lds r0,pr; \
+ .align 2; \
+1: .long mcount; \
+2: lds.l @r15+,pr; \
+ cfi_adjust_cfa_offset (-4); \
+ cfi_restore (pr)
+
+#else
+#define CALL_MCOUNT /* Do nothing. */
+#endif
+
+#ifdef __UCLIBC_UNDERSCORES__
+/* Since C identifiers are not normally prefixed with an underscore
+ on this system, the asm identifier `syscall_error' intrudes on the
+ C name space. Make sure we use an innocuous name. */
+#define syscall_error __syscall_error
+#define mcount _mcount
+#endif
+
+/* For Linux we can use the system call table in the header file
+ /usr/include/asm/unistd.h
+ of the kernel. But these symbols do not follow the SYS_* syntax
+ so we have to redefine the `SYS_ify' macro here. */
+#undef SYS_ify
+#define SYS_ify(syscall_name) (__NR_##syscall_name)
+
+#define ret rts ; nop
+/* The sh move insn is s, d. */
+#define MOVE(x,y) mov x , y
+
+/* Linux uses a negative return value to indicate syscall errors,
+ unlike most Unices, which use the condition codes' carry flag.
+
+ Since version 2.1 the return value of a system call might be
+ negative even if the call succeeded. E.g., the `lseek' system call
+ might return a large offset. Therefore we must not anymore test
+ for < 0, but test for a real error by making sure the value in R0
+ is a real error number. Linus said he will make sure the no syscall
+ returns a value in -1 .. -4095 as a valid result so we can savely
+ test with -4095. */
+
+#define _IMM1 #-1
+#define _IMM12 #-12
+#undef PSEUDO
+#define PSEUDO(name, syscall_name, args) \
+ .text; \
+ ENTRY (name); \
+ DO_CALL (syscall_name, args); \
+ mov r0,r1; \
+ mov _IMM12,r2; \
+ shad r2,r1; \
+ not r1,r1; \
+ tst r1,r1; \
+ bf .Lpseudo_end; \
+ SYSCALL_ERROR_HANDLER; \
+ .Lpseudo_end:
+
+#undef PSEUDO_END
+#define PSEUDO_END(name) \
+ END (name)
+
+#undef PSEUDO_NOERRNO
+#define PSEUDO_NOERRNO(name, syscall_name, args) \
+ .text; \
+ ENTRY (name); \
+ DO_CALL (syscall_name, args)
+
+#undef PSEUDO_END_NOERRNO
+#define PSEUDO_END_NOERRNO(name) \
+ END (name)
+
+#define ret_NOERRNO ret
+
+#define PSEUDO_ERRVAL(name, syscall_name, args) \
+ .text; \
+ ENTRY (name); \
+ DO_CALL (syscall_name, args);
+
+#undef PSEUDO_END_ERRVAL
+#define PSEUDO_END_ERRVAL(name) \
+ END (name)
+
+#ifndef __PIC__
+# define SYSCALL_ERROR_HANDLER \
+ mov.l 0f,r1; \
+ jmp @r1; \
+ mov r0,r4; \
+ .align 2; \
+ 0: .long __syscall_error
+
+#include <libc/sysdeps/linux/sh/syscall_error.S>
+#else
+# ifdef RTLD_PRIVATE_ERRNO
+
+# define SYSCALL_ERROR_HANDLER \
+ neg r0,r1; \
+ mov.l 0f,r12; \
+ mova 0f,r0; \
+ add r0,r12; \
+ mov.l 1f,r0; \
+ mov.l r1,@(r0,r12)
+ bra .Lpseudo_end; \
+ mov _IMM1,r0; \
+ .align 2; \
+ 0: .long _GLOBAL_OFFSET_TABLE_; \
+ 1: .long rtld_errno@GOTOFF
+
+# elif defined _LIBC_REENTRANT
+
+# if defined USE___THREAD
+
+# ifndef NOT_IN_libc
+# define SYSCALL_ERROR_ERRNO __libc_errno
+# else
+# define SYSCALL_ERROR_ERRNO errno
+# endif
+# define SYSCALL_ERROR_HANDLER \
+ neg r0,r1; \
+ mov r12,r2; \
+ mov.l 0f,r12; \
+ mova 0f,r0; \
+ add r0,r12; \
+ mov.l 1f,r0; \
+ stc gbr, r4; \
+ mov.l @(r0,r12),r0; \
+ bra .Lskip; \
+ add r4,r0; \
+ .align 2; \
+ 1: .long SYSCALL_ERROR_ERRNO@GOTTPOFF; \
+ .Lskip: \
+ mov r2,r12; \
+ mov.l r1,@r0; \
+ bra .Lpseudo_end; \
+ mov _IMM1,r0; \
+ .align 2; \
+ 0: .long _GLOBAL_OFFSET_TABLE_
+# else
+
+# define SYSCALL_ERROR_HANDLER \
+ neg r0,r1; \
+ mov.l r14,@-r15; \
+ mov.l r12,@-r15; \
+ mov.l r1,@-r15; \
+ mov.l 0f,r12; \
+ mova 0f,r0; \
+ add r0,r12; \
+ sts.l pr,@-r15; \
+ mov r15,r14; \
+ mov.l 1f,r1; \
+ bsrf r1; \
+ nop; \
+ 2: mov r14,r15; \
+ lds.l @r15+,pr; \
+ mov.l @r15+,r1; \
+ mov.l r1,@r0; \
+ mov.l @r15+,r12; \
+ mov.l @r15+,r14; \
+ bra .Lpseudo_end; \
+ mov _IMM1,r0; \
+ .align 2; \
+ 0: .long _GLOBAL_OFFSET_TABLE_; \
+ 1: .long PLTJMP(C_SYMBOL_NAME(__errno_location))-(2b-.)
+/* A quick note: it is assumed that the call to `__errno_location' does
+ not modify the stack! */
+# endif
+# else
+
+/* Store (-r0) into errno through the GOT. */
+# define SYSCALL_ERROR_HANDLER \
+ neg r0,r1; \
+ mov r12,r2; \
+ mov.l 0f,r12; \
+ mova 0f,r0; \
+ add r0,r12; \
+ mov.l 1f,r0; \
+ mov.l @(r0,r12),r0; \
+ mov r2,r12; \
+ mov.l r1,@r0; \
+ bra .Lpseudo_end; \
+ mov _IMM1,r0; \
+ .align 2; \
+ 0: .long _GLOBAL_OFFSET_TABLE_; \
+ 1: .long errno@GOT
+# endif /* _LIBC_REENTRANT */
+#endif /* __PIC__ */
+
+# ifdef __SH4__
+# define SYSCALL_INST_PAD \
+ or r0,r0; or r0,r0; or r0,r0; or r0,r0; or r0,r0
+# else
+# define SYSCALL_INST_PAD
+# endif
+
+#define SYSCALL_INST0 trapa #0x10
+#define SYSCALL_INST1 trapa #0x11
+#define SYSCALL_INST2 trapa #0x12
+#define SYSCALL_INST3 trapa #0x13
+#define SYSCALL_INST4 trapa #0x14
+#define SYSCALL_INST5 mov.l @(0,r15),r0; trapa #0x15
+#define SYSCALL_INST6 mov.l @(0,r15),r0; mov.l @(4,r15),r1; trapa #0x16
+
+#undef DO_CALL
+#define DO_CALL(syscall_name, args) \
+ mov.l 1f,r3; \
+ SYSCALL_INST##args; \
+ SYSCALL_INST_PAD; \
+ bra 2f; \
+ nop; \
+ .align 2; \
+ 1: .long SYS_ify (syscall_name); \
+ 2:
+#endif /* __ASSEMBLER__ */
+
+/* Pointer mangling support. */
+#if defined NOT_IN_libc && defined IS_IN_rtld
+/* We cannot use the thread descriptor because in ld.so we use setjmp
+ earlier than the descriptor is initialized. Using a global variable
+ is too complicated here since we have no PC-relative addressing mode. */
+#else
+# ifdef __ASSEMBLER__
+# define PTR_MANGLE(reg, tmp) \
+ stc gbr,tmp; mov.l @(POINTER_GUARD,tmp),tmp; xor tmp,reg
+# define PTR_MANGLE2(reg, tmp) xor tmp,reg
+# define PTR_DEMANGLE(reg, tmp) PTR_MANGLE (reg, tmp)
+# define PTR_DEMANGLE2(reg, tmp) PTR_MANGLE2 (reg, tmp)
+# else
+# define PTR_MANGLE(var) \
+ (var) = (void *) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
+# define PTR_DEMANGLE(var) PTR_MANGLE (var)
+# endif
+#endif
+
diff --git a/libc/sysdeps/linux/sh/vfork.S b/libc/sysdeps/linux/sh/vfork.S
index a9b440d8f..0a0a0da8d 100644
--- a/libc/sysdeps/linux/sh/vfork.S
+++ b/libc/sysdeps/linux/sh/vfork.S
@@ -12,19 +12,16 @@
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
+ along with this program; if not, see <http://www.gnu.org/licenses/>.
Derived in part from the Linux-8086 C library, the GNU C Library, and several
other sundry sources. Files within this library are copyright by their
respective copyright holders.
*/
-#include <features.h>
#include <sys/syscall.h>
#define _ERRNO_H
#include <bits/errno.h>
-#include <bits/sysnum.h>
/* Clone the calling process, but without copying the whole address space.
The calling process is suspended until the new process exits or is
@@ -41,8 +38,8 @@ __vfork:
mov.w .L2, r3
trapa #__SH_SYSCALL_TRAP_BASE
mov r0, r1
-#ifdef __CONFIG_SH2__
-// 12 arithmetic shifts for the crappy sh2, because shad doesn't exist!
+#ifdef __sh2__
+/* 12 arithmetic shifts for the crappy sh2, because shad doesn't exist! */
shar r1
shar r1
shar r1
@@ -55,13 +52,13 @@ __vfork:
shar r1
shar r1
shar r1
-#else
+#else
mov #-12, r2
shad r2, r1
#endif
- not r1, r1 // r1=0 means r0 = -1 to -4095
- tst r1, r1 // i.e. error in linux
+ not r1, r1 /* r1=0 means r0 = -1 to -4095 */
+ tst r1, r1 /* i.e. error in linux */
bf 2f
mov.w .L1, r1
cmp/eq r1, r0
@@ -72,8 +69,8 @@ __vfork:
mov.w .L3, r3
trapa #__SH_SYSCALL_TRAP_BASE
mov r0, r1
-#ifdef __CONFIG_SH2__
-// 12 arithmetic shifts for the crappy sh2, because shad doesn't exist!
+#ifdef __sh2__
+/* 12 arithmetic shifts for the crappy sh2, because shad doesn't exist! */
shar r1
shar r1
shar r1
@@ -86,13 +83,13 @@ __vfork:
shar r1
shar r1
shar r1
-#else
+#else
mov #-12, r2
shad r2, r1
#endif
- not r1, r1 // r1=0 means r0 = -1 to -4095
- tst r1, r1 // i.e. error in linux
+ not r1, r1 /* r1=0 means r0 = -1 to -4095 */
+ tst r1, r1 /* i.e. error in linux */
bt/s __syscall_error
mov r0, r4
2:
@@ -109,6 +106,6 @@ __vfork:
.size __vfork, .-__vfork
weak_alias(__vfork,vfork)
-libc_hidden_weak(vfork)
+libc_hidden_def(vfork)
#include "syscall_error.S"
diff --git a/libc/sysdeps/linux/sh64/Makefile.arch b/libc/sysdeps/linux/sh64/Makefile.arch
deleted file mode 100644
index d49540ebe..000000000
--- a/libc/sysdeps/linux/sh64/Makefile.arch
+++ /dev/null
@@ -1,12 +0,0 @@
-# Makefile for uClibc
-#
-# Copyright (C) 2008 Paul Mundt <lethal@linux-sh.org>
-#
-# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-#
-
-CSRC := __init_brk.c brk.c sbrk.c syscall.c
-
-SSRC := setjmp.S __longjmp.S
-
-include $(top_srcdir)libc/sysdeps/linux/Makefile.commonarch
diff --git a/libc/sysdeps/linux/sh64/__longjmp.S b/libc/sysdeps/linux/sh64/__longjmp.S
deleted file mode 100644
index ca7925f76..000000000
--- a/libc/sysdeps/linux/sh64/__longjmp.S
+++ /dev/null
@@ -1,141 +0,0 @@
-/* __longjmp for SH-5.
- Copyright (C) 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. */
-
-
-#define _SETJMP_H
-#define _ASM
-#include <bits/setjmp.h>
-
-
-#define INTEGER(reg,offset) ld.q r2, offset*8, reg
-#define DOUBLE(reg,offset) fld.d r2, offset*8, reg
-
-
- .file "__longjmp.S"
-
- .section .text64,"xa"
- .align 2
-
- .global __longjmp
- .type __longjmp,@function
-
-__longjmp:
- /*
- * extern void __longjmp(jmp_buf env, int val);
- *
- * r2 == env
- * r3 == val
- * r4 == temporary
- */
-
- /* callee-save registers R10-R16 */
- INTEGER(r10, __SETJMP_INT(0))
- INTEGER(r11, __SETJMP_INT(1))
- INTEGER(r12, __SETJMP_INT(2))
- INTEGER(r13, __SETJMP_INT(3))
- INTEGER(r14, __SETJMP_INT(4))
- INTEGER(r15, __SETJMP_INT(5))
- INTEGER(r16, __SETJMP_INT(6))
-
- /* callee-save registers R28-R35 */
- INTEGER(r28, __SETJMP_INT(7))
- INTEGER(r29, __SETJMP_INT(8))
- INTEGER(r30, __SETJMP_INT(9))
- INTEGER(r31, __SETJMP_INT(10))
- INTEGER(r32, __SETJMP_INT(11))
- INTEGER(r33, __SETJMP_INT(12))
- INTEGER(r34, __SETJMP_INT(13))
- INTEGER(r35, __SETJMP_INT(14))
-
- /* callee-save registers R44-R59 */
- INTEGER(r44, __SETJMP_INT(15))
- INTEGER(r45, __SETJMP_INT(16))
- INTEGER(r46, __SETJMP_INT(17))
- INTEGER(r47, __SETJMP_INT(18))
- INTEGER(r48, __SETJMP_INT(19))
- INTEGER(r49, __SETJMP_INT(20))
- INTEGER(r50, __SETJMP_INT(21))
- INTEGER(r51, __SETJMP_INT(22))
- INTEGER(r52, __SETJMP_INT(23))
- INTEGER(r53, __SETJMP_INT(24))
- INTEGER(r54, __SETJMP_INT(25))
- INTEGER(r55, __SETJMP_INT(26))
- INTEGER(r56, __SETJMP_INT(27))
- INTEGER(r57, __SETJMP_INT(28))
- INTEGER(r58, __SETJMP_INT(29))
- INTEGER(r59, __SETJMP_INT(30))
-
- #if __SETJMP_NUM_INT != 31
- #error __SETJMP_NUM_INT does agree with expected value
- #endif
-
-#if __SETJMP_NUM_DBL > 0
- /* callee-save registers FR12-FR15 */
- DOUBLE(d12, __SETJMP_DBL(0))
- DOUBLE(d14, __SETJMP_DBL(1))
-
- /* callee-save registers FR36-FR63 */
- DOUBLE(d36, __SETJMP_DBL(2))
- DOUBLE(d38, __SETJMP_DBL(3))
- DOUBLE(d40, __SETJMP_DBL(4))
- DOUBLE(d42, __SETJMP_DBL(5))
- DOUBLE(d44, __SETJMP_DBL(6))
- DOUBLE(d46, __SETJMP_DBL(7))
- DOUBLE(d48, __SETJMP_DBL(8))
- DOUBLE(d50, __SETJMP_DBL(9))
- DOUBLE(d52, __SETJMP_DBL(10))
- DOUBLE(d54, __SETJMP_DBL(11))
- DOUBLE(d56, __SETJMP_DBL(12))
- DOUBLE(d58, __SETJMP_DBL(13))
- DOUBLE(d60, __SETJMP_DBL(14))
- DOUBLE(d62, __SETJMP_DBL(15))
-
- #if __SETJMP_NUM_DBL != 16
- #error __SETJMP_NUM_DBL does agree with expected value
- #endif
-
-#endif /* __SETJMP_NUM_DBL > 0 */
-
- /* callee-save registers TR5-TR7 */
- INTEGER(r4, __SETJMP_TRG(0))
- ptabs r4, tr5
- INTEGER(r4, __SETJMP_TRG(1))
- ptabs r4, tr6
- INTEGER(r4, __SETJMP_TRG(2))
- ptabs r4, tr7
-
- #if __SETJMP_NUM_TRG != 3
- #error __SETJMP_NUM_TRG does agree with expected value
- #endif
-
- /* restore Linkage Register (LR) for __longjmp return */
- INTEGER(r18, __SETJMP_LR)
- ptabs/l r18, tr0
-
- /*
- * must ensure __longjmp() never returns 0.
- * if 'val' == 0, then return 1.
- */
- cmpeq r3, r63, r2 /* r2 = (r3==0) ? 1 : 0; */
- add.l r3, r2, r2 /* return value */
-
- /* return to caller */
- blink tr0, r63
-
-libc_hidden_def(__longjmp)
diff --git a/libc/sysdeps/linux/sh64/bits/endian.h b/libc/sysdeps/linux/sh64/bits/endian.h
deleted file mode 100644
index ae7e3bb2d..000000000
--- a/libc/sysdeps/linux/sh64/bits/endian.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * libc/sysdeps/linux/sh64/bits/endian.h
- *
- * Copyright (C) 2003 Paul Mundt
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- */
-
-#ifndef _ENDIAN_H
-# error "Never use <bits/endian.h> directly; include <endian.h> instead."
-#endif
-
-#ifdef __LITTLE_ENDIAN__
-# define __BYTE_ORDER __LITTLE_ENDIAN
-#else
-# define __BYTE_ORDER __BIG_ENDIAN
-#endif
-
diff --git a/libc/sysdeps/linux/sh64/bits/fcntl.h b/libc/sysdeps/linux/sh64/bits/fcntl.h
deleted file mode 100644
index 49da6279d..000000000
--- a/libc/sysdeps/linux/sh64/bits/fcntl.h
+++ /dev/null
@@ -1,216 +0,0 @@
-/* O_*, F_*, FD_* bit values for Linux.
- Copyright (C) 1995, 1996, 1997, 1998, 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>
-
-/* 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
-
-#ifdef __USE_GNU
-# define O_DIRECT 040000 /* Direct disk access. */
-# define O_DIRECTORY 0200000 /* Must be a directory. */
-# define O_NOFOLLOW 0400000 /* Do not follow links. */
-# define O_STREAMING 04000000/* streaming access */
-#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. */
-# define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with
- close-on-exit set on new fd. */
-#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
-
-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
-
-
-#ifdef __USE_GNU
-/* 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
-
-#ifdef __USE_GNU
-
-/* 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/sh64/bits/kernel_stat.h b/libc/sysdeps/linux/sh64/bits/kernel_stat.h
deleted file mode 100644
index cde7bc880..000000000
--- a/libc/sysdeps/linux/sh64/bits/kernel_stat.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* Stat structure for Linux/sh64 */
-
-#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;
- unsigned long st_ino;
- unsigned short st_mode;
- unsigned short st_nlink;
- unsigned short st_uid;
- unsigned short st_gid;
- unsigned short st_rdev;
- unsigned short __pad2;
- unsigned long st_size;
- unsigned long st_blksize;
- unsigned long st_blocks;
- unsigned long st_atime;
- unsigned long __unused1;
- unsigned long st_mtime;
- unsigned long __unused2;
- unsigned long st_ctime;
- unsigned long __unused3;
- unsigned long __unused4;
- unsigned long __unused5;
-};
-
-struct kernel_stat64 {
- unsigned short st_dev;
- unsigned char __pad0[10];
-
- unsigned long st_ino;
- unsigned int st_mode;
- unsigned int st_nlink;
-
- unsigned long st_uid;
- unsigned long st_gid;
-
- unsigned short st_rdev;
- unsigned char __pad3[10];
-
- long long st_size;
- unsigned long st_blksize;
-
- unsigned long st_blocks; /* Number 512-byte blocks allocated. */
- unsigned long __pad4; /* future possible st_blocks high bits */
-
- unsigned long st_atime;
- unsigned long __pad5;
-
- unsigned long st_mtime;
- unsigned long __pad6;
-
- unsigned long st_ctime;
- unsigned long __pad7; /* will be high 32 bits of ctime someday */
-
- unsigned long __unused1;
- unsigned long __unused2;
-};
-
-#endif /* _BITS_STAT_STRUCT_H */
-
diff --git a/libc/sysdeps/linux/sh64/bits/kernel_types.h b/libc/sysdeps/linux/sh64/bits/kernel_types.h
deleted file mode 100644
index 671cc8345..000000000
--- a/libc/sysdeps/linux/sh64/bits/kernel_types.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * sysdeps/linux/sh64/bits/kernel_types.h
- *
- * Copyright (C) 2000, 2001 Paolo Alberelli
- * Copyright (C) 2003 Paul Mundt
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- */
-
-/*
- * 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_SH64_POSIX_TYPES_H
-#define __ASM_SH64_POSIX_TYPES_H
-
-typedef unsigned short __kernel_dev_t;
-typedef unsigned long __kernel_ino_t;
-typedef unsigned short __kernel_mode_t;
-typedef unsigned short __kernel_nlink_t;
-typedef long __kernel_off_t;
-typedef int __kernel_pid_t;
-typedef unsigned short __kernel_ipc_pid_t;
-typedef unsigned short __kernel_uid_t;
-typedef unsigned short __kernel_gid_t;
-typedef long unsigned int __kernel_size_t;
-typedef int __kernel_ssize_t;
-typedef int __kernel_ptrdiff_t;
-typedef long __kernel_time_t;
-typedef long __kernel_suseconds_t;
-typedef long __kernel_clock_t;
-typedef int __kernel_daddr_t;
-typedef char * __kernel_caddr_t;
-typedef unsigned short __kernel_uid16_t;
-typedef unsigned short __kernel_gid16_t;
-typedef unsigned int __kernel_uid32_t;
-typedef unsigned int __kernel_gid32_t;
-typedef unsigned short __kernel_old_uid_t;
-typedef unsigned short __kernel_old_gid_t;
-typedef __kernel_dev_t __kernel_old_dev_t;
-typedef long long __kernel_loff_t;
-
-typedef struct {
-#ifdef __USE_ALL
- int val[2];
-#else
- int __val[2];
-#endif
-} __kernel_fsid_t;
-
-#endif /* __ASM_SH64_POSIX_TYPES_H */
diff --git a/libc/sysdeps/linux/sh64/bits/mman.h b/libc/sysdeps/linux/sh64/bits/mman.h
deleted file mode 100644
index afa889dbf..000000000
--- a/libc/sysdeps/linux/sh64/bits/mman.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* Cloned for uClibc by Paul Mundt, December 2003 */
-/* Modified by SuperH, Inc. September 2003 */
-
-/* Definitions for POSIX memory map interface. Linux/SH version.
- Copyright (C) 1997, 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. */
-
-#ifndef _SYS_MMAN_H
-# error "Never include this file directly. Use <sys/mman.h> instead"
-#endif
-
-/* The following definitions basically come from the kernel headers.
- But the kernel header is not namespace clean. */
-
-
-/* Protections are chosen from these bits, OR'd together. The
- implementation does not necessarily support PROT_EXEC or PROT_WRITE
- without PROT_READ. The only guarantees are that no writing will be
- allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
-
-#define PROT_READ 0x1 /* Page can be read. */
-#define PROT_WRITE 0x2 /* Page can be written. */
-#define PROT_EXEC 0x4 /* Page can be executed. */
-#define PROT_NONE 0x0 /* Page can not be accessed. */
-
-/* Sharing types (must choose one and only one of these). */
-#define MAP_SHARED 0x01 /* Share changes. */
-#define MAP_PRIVATE 0x02 /* Changes are private. */
-#ifdef __USE_MISC
-# define MAP_TYPE 0x0f /* Mask for type of mapping. */
-#endif
-
-/* Other flags. */
-#define MAP_FIXED 0x10 /* Interpret addr exactly. */
-#ifdef __USE_MISC
-# define MAP_FILE 0
-# define MAP_ANONYMOUS 0x20 /* Don't use a file. */
-# define MAP_ANON MAP_ANONYMOUS
-#endif
-
-/* These are Linux-specific. */
-#ifdef __USE_MISC
-# define MAP_GROWSDOWN 0x0100 /* Stack-like segment. */
-# define MAP_DENYWRITE 0x0800 /* ETXTBSY */
-# define MAP_EXECUTABLE 0x1000 /* Mark it as an executable. */
-# define MAP_LOCKED 0x2000 /* Lock the mapping. */
-# define MAP_NORESERVE 0x4000 /* Don't check for reservations. */
-#endif
-
-/* Flags to `msync'. */
-#define MS_ASYNC 1 /* Sync memory asynchronously. */
-#define MS_SYNC 4 /* Synchronous memory sync. */
-#define MS_INVALIDATE 2 /* Invalidate the caches. */
-
-/* Flags for `mlockall'. */
-#define MCL_CURRENT 1 /* Lock all currently mapped pages. */
-#define MCL_FUTURE 2 /* Lock all additions to address
- space. */
-
-/* Flags for `mremap'. */
-#ifdef __USE_GNU
-# define MREMAP_MAYMOVE 1
-# define MREMAP_FIXED 2
-#endif
-
-/* Advice to `madvise'. */
-#ifdef __USE_BSD
-# define MADV_NORMAL 0 /* No further special treatment. */
-# define MADV_RANDOM 1 /* Expect random page references. */
-# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
-# define MADV_WILLNEED 3 /* Will need these pages. */
-# define MADV_DONTNEED 4 /* Don't need these pages. */
-#endif
-
-/* The POSIX people had to invent similar names for the same things. */
-#ifdef __USE_XOPEN2K
-# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
-# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
-# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
-# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
-# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
-#endif
diff --git a/libc/sysdeps/linux/sh64/bits/setjmp.h b/libc/sysdeps/linux/sh64/bits/setjmp.h
deleted file mode 100644
index ad1ec9d4b..000000000
--- a/libc/sysdeps/linux/sh64/bits/setjmp.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* Copyright (C) 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. */
-
-/* Define the machine-dependent type `jmp_buf'. SH-5 version. */
-#ifndef _BITS_SETJMP_H
-#define _BITS_SETJMP_H 1
-
-#if !defined _SETJMP_H && !defined _PTHREAD_H
-# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
-#endif
-
-#define __SETJMP_NUM_INT 31 /* number of integer registers to save */
-#define __SETJMP_NUM_DBL 0 /* 16 */ /* number of double registers to save */
-#define __SETJMP_NUM_TRG 3 /* number of traget registers to save */
-
-#define __SETJMP_INT(x) (x)
-#define __SETJMP_DBL(x) (__SETJMP_NUM_INT+(x))
-#define __SETJMP_TRG(x) (__SETJMP_NUM_INT+__SETJMP_NUM_DBL+(x))
-#define __SETJMP_LR (__SETJMP_NUM_INT+__SETJMP_NUM_DBL+__SETJMP_NUM_TRG)
-
-
-#ifndef _ASM
-typedef struct
- {
- /* Callee-saved registers. */
- unsigned long long __ints[__SETJMP_NUM_INT]; /* integer registers */
-#if __SETJMP_NUM_DBL > 0
- unsigned long long __dbls[__SETJMP_NUM_DBL]; /* double registers */
-#endif
- unsigned long long __trgs[__SETJMP_NUM_TRG]; /* traget registers */
- unsigned long long __lr; /* linkage register */
- } __jmp_buf[1];
-#endif
-
-#endif /* bits/setjmp.h */
diff --git a/libc/sysdeps/linux/sh64/bits/shm.h b/libc/sysdeps/linux/sh64/bits/shm.h
deleted file mode 100644
index 3a2e715ca..000000000
--- a/libc/sysdeps/linux/sh64/bits/shm.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/* Copyright (C) 1995,1996,1997,2000,2002,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.
-
- 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_SHM_H
-# error "Never include <bits/shm.h> directly; use <sys/shm.h> instead."
-#endif
-
-#include <bits/types.h>
-
-/* Permission flag for shmget. */
-#define SHM_R 0400 /* or S_IRUGO from <linux/stat.h> */
-#define SHM_W 0200 /* or S_IWUGO from <linux/stat.h> */
-
-/* Flags for `shmat'. */
-#define SHM_RDONLY 010000 /* attach read-only else read-write */
-#define SHM_RND 020000 /* round attach address to SHMLBA */
-#define SHM_REMAP 040000 /* take-over region on attach */
-
-/* Commands for `shmctl'. */
-#define SHM_LOCK 11 /* lock segment (root only) */
-#define SHM_UNLOCK 12 /* unlock segment (root only) */
-
-__BEGIN_DECLS
-
-/* Segment low boundary address multiple. */
-#define SHMLBA (__getpagesize() << 2)
-extern int __getpagesize (void) __THROW __attribute__ ((__const__));
-
-
-/* Type to count number of attaches. */
-typedef unsigned long int shmatt_t;
-
-/* Data structure describing a set of semaphores. */
-struct shmid_ds
- {
- struct ipc_perm shm_perm; /* operation permission struct */
- size_t shm_segsz; /* size of segment in bytes */
- __time_t shm_atime; /* time of last shmat() */
- unsigned long int __unused1;
- __time_t shm_dtime; /* time of last shmdt() */
- unsigned long int __unused2;
- __time_t shm_ctime; /* time of last change by shmctl() */
- unsigned long int __unused3;
- __pid_t shm_cpid; /* pid of creator */
- __pid_t shm_lpid; /* pid of last shmop */
- shmatt_t shm_nattch; /* number of current attaches */
- unsigned long int __unused4;
- unsigned long int __unused5;
- };
-
-#ifdef __USE_MISC
-
-/* ipcs ctl commands */
-# define SHM_STAT 13
-# define SHM_INFO 14
-
-/* shm_mode upper byte flags */
-# define SHM_DEST 01000 /* segment will be destroyed on last detach */
-# define SHM_LOCKED 02000 /* segment will not be swapped */
-# define SHM_HUGETLB 04000 /* segment is mapped via hugetlb */
-# define SHM_NORESERVE 010000 /* don't check for reservations */
-
-struct shminfo
- {
- unsigned long int shmmax;
- unsigned long int shmmin;
- unsigned long int shmmni;
- unsigned long int shmseg;
- unsigned long int shmall;
- unsigned long int __unused1;
- unsigned long int __unused2;
- unsigned long int __unused3;
- unsigned long int __unused4;
- };
-
-struct shm_info
- {
- int used_ids;
- unsigned long int shm_tot; /* total allocated shm */
- unsigned long int shm_rss; /* total resident shm */
- unsigned long int shm_swp; /* total swapped shm */
- unsigned long int swap_attempts;
- unsigned long int swap_successes;
- };
-
-#endif /* __USE_MISC */
-
-__END_DECLS
diff --git a/libc/sysdeps/linux/sh64/bits/syscalls.h b/libc/sysdeps/linux/sh64/bits/syscalls.h
deleted file mode 100644
index 84877d042..000000000
--- a/libc/sysdeps/linux/sh64/bits/syscalls.h
+++ /dev/null
@@ -1,126 +0,0 @@
-#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)
-
-/* user-visible error numbers are in the range -1 - -125: see <asm-sh64/errno.h> */
-#define __syscall_return(type, res) \
-do { \
- /* Note: when returning from kernel the return value is in r9 \
- ** This prevents conflicts between return value and arg1 \
- ** when dispatching signal handler, in other words makes \
- ** life easier in the system call epilogue (see entry.S) \
- */ \
- register unsigned long __sr2 __asm__ ("r2") = res; \
- if ((unsigned long)(res) >= (unsigned long)(-125)) { \
- errno = -(res); \
- __sr2 = -1; \
- } \
- return (type) (__sr2); \
-} while (0)
-
-/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
-
-#define _syscall0(type,name) \
-type name(void) \
-{ \
-register unsigned long __sc0 __asm__ ("r9") = ((0x10 << 16) | __NR_##name); \
-__asm__ __volatile__ ("trapa %1" \
- : "=r" (__sc0) \
- : "r" (__sc0) ); \
-__syscall_return(type,__sc0); \
-}
-
-#define _syscall1(type,name,type1,arg1) \
-type name(type1 arg1) \
-{ \
-register unsigned long __sc0 __asm__ ("r9") = ((0x11 << 16) | __NR_##name); \
-register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1; \
-__asm__ __volatile__ ("trapa %1" \
- : "=r" (__sc0) \
- : "r" (__sc0), "r" (__sc2)); \
-__syscall_return(type,__sc0); \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name(type1 arg1,type2 arg2) \
-{ \
-register unsigned long __sc0 __asm__ ("r9") = ((0x12 << 16) | __NR_##name); \
-register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1; \
-register unsigned long __sc3 __asm__ ("r3") = (unsigned long) arg2; \
-__asm__ __volatile__ ("trapa %1" \
- : "=r" (__sc0) \
- : "r" (__sc0), "r" (__sc2), "r" (__sc3) ); \
-__syscall_return(type,__sc0); \
-}
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name(type1 arg1,type2 arg2,type3 arg3) \
-{ \
-register unsigned long __sc0 __asm__ ("r9") = ((0x13 << 16) | __NR_##name); \
-register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1; \
-register unsigned long __sc3 __asm__ ("r3") = (unsigned long) arg2; \
-register unsigned long __sc4 __asm__ ("r4") = (unsigned long) arg3; \
-__asm__ __volatile__ ("trapa %1" \
- : "=r" (__sc0) \
- : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4) ); \
-__syscall_return(type,__sc0); \
-}
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
-{ \
-register unsigned long __sc0 __asm__ ("r9") = ((0x14 << 16) | __NR_##name); \
-register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1; \
-register unsigned long __sc3 __asm__ ("r3") = (unsigned long) arg2; \
-register unsigned long __sc4 __asm__ ("r4") = (unsigned long) arg3; \
-register unsigned long __sc5 __asm__ ("r5") = (unsigned long) arg4; \
-__asm__ __volatile__ ("trapa %1" \
- : "=r" (__sc0) \
- : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4), "r" (__sc5) );\
-__syscall_return(type,__sc0); \
-}
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
-{ \
-register unsigned long __sc0 __asm__ ("r9") = ((0x15 << 16) | __NR_##name); \
-register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1; \
-register unsigned long __sc3 __asm__ ("r3") = (unsigned long) arg2; \
-register unsigned long __sc4 __asm__ ("r4") = (unsigned long) arg3; \
-register unsigned long __sc5 __asm__ ("r5") = (unsigned long) arg4; \
-register unsigned long __sc6 __asm__ ("r6") = (unsigned long) arg5; \
-__asm__ __volatile__ ("trapa %1" \
- : "=r" (__sc0) \
- : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4), "r" (__sc5), \
- "r" (__sc6)); \
-__syscall_return(type,__sc0); \
-}
-
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5, type6, arg6) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
-{ \
-register unsigned long __sc0 __asm__ ("r9") = ((0x16 << 16) | __NR_##name); \
-register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1; \
-register unsigned long __sc3 __asm__ ("r3") = (unsigned long) arg2; \
-register unsigned long __sc4 __asm__ ("r4") = (unsigned long) arg3; \
-register unsigned long __sc5 __asm__ ("r5") = (unsigned long) arg4; \
-register unsigned long __sc6 __asm__ ("r6") = (unsigned long) arg5; \
-register unsigned long __sc7 __asm__ ("r7") = (unsigned long) arg6; \
-__asm__ __volatile__ ("trapa %1" \
- : "=r" (__sc0) \
- : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4), "r" (__sc5), \
- "r" (__sc6), "r" (__sc7)); \
-__syscall_return(type,__sc0); \
-}
-
-#endif /* __ASSEMBLER__ */
-#endif /* _BITS_SYSCALLS_H */
-
diff --git a/libc/sysdeps/linux/sh64/bits/wordsize.h b/libc/sysdeps/linux/sh64/bits/wordsize.h
deleted file mode 100644
index 7c2723be4..000000000
--- a/libc/sysdeps/linux/sh64/bits/wordsize.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * libc/sysdeps/linux/sh64/bits/wordsize.h
- *
- * Copyright (C) 2003 Paul Mundt
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- */
-
-#define __WORDSIZE 32
-
diff --git a/libc/sysdeps/linux/sh64/brk.c b/libc/sysdeps/linux/sh64/brk.c
deleted file mode 100644
index c69c97ad6..000000000
--- a/libc/sysdeps/linux/sh64/brk.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* From libc-5.3.12 */
-/*
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-#include <errno.h>
-#include <unistd.h>
-#include <sys/syscall.h>
-
-extern void * __curbrk attribute_hidden;
-extern int __init_brk (void) attribute_hidden;
-extern void *_brk(void *ptr) attribute_hidden;
-
-libc_hidden_proto(brk)
-int brk(void * end_data_seg)
-{
- if (__init_brk () == 0)
- {
- __curbrk = _brk(end_data_seg);
- if (__curbrk == end_data_seg)
- return 0;
- __set_errno(ENOMEM);
- }
- return -1;
-}
-libc_hidden_def(brk)
diff --git a/libc/sysdeps/linux/sh64/crt1.S b/libc/sysdeps/linux/sh64/crt1.S
deleted file mode 100644
index 1822e2dc3..000000000
--- a/libc/sysdeps/linux/sh64/crt1.S
+++ /dev/null
@@ -1,83 +0,0 @@
-/* Startup code for SH5 & ELF.
- Copyright (C) 1999 Free Software Foundation, Inc.
- Copyright (C) 2001 Hewlett-Packard Australia
-
- 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. */
-
-/* This is the canonical entry point, usually the first thing in the text
- segment.
-
- At this entry point, most registers' values are unspecified, except:
-
- sp The stack contains the arguments and environment:
- 0(sp) argc
- 4(sp) argv[0]
- ...
- (4*argc)(sp) NULL
- (4*(argc+1))(sp) envp[0]
- ...
- NULL
-*/
-
- .file "crt1.S"
-
- .globl _start
- .type _start,%function
- .type main,%function
-
- .section .text64,"xa"
- .align 2 /* 2^2 = 4 */
-
-_start:
- /* __uClibc_main (main, argc, argv, init, fini) */
- movi __main, r18
- or r2, r63, r18
-
- /* Pop argc off the stack and save a pointer to argv */
- ld.l r15, 0, r3 /* argc */
- addi r15, 4, r4 /* argv */
-
- movi _init, r5
- movi _fini, r6
-
- /* call main() */
- movi __uClibc_main, r17
- ptabs/l r17, tr0
- blink tr0, r18
-
- /* should never get here....*/
- movi abort, r17
- ptabs/l r17, tr0
- blink tr0, r63 /* call abort() => (r63) do not come back ... */
-
-/*
- * The following is a stub to stop the GNU toolchain
- * from calling its C-RTL initialization routines.
- */
-__main:
- movi main, r18
- ptabs/l r18, tr0
- blink tr0, r63
-
-/* Define a symbol for the first piece of initialized data. */
- .data
- .globl __data_start
-__data_start:
- .long 0
- .weak data_start
- data_start = __data_start
diff --git a/libc/sysdeps/linux/sh64/crti.S b/libc/sysdeps/linux/sh64/crti.S
deleted file mode 100644
index 597be363d..000000000
--- a/libc/sysdeps/linux/sh64/crti.S
+++ /dev/null
@@ -1,42 +0,0 @@
- .file "initfini.c"
- .section .text..SHmedia32,"ax"
- .little
-
- .section .init
- .hidden _init
- .align 2
- .global _init
- .type _init, @function
-_init:
- addi.l r15, -16, r15
- st.l r15, 4, r12
- movi (((datalabel _GLOBAL_OFFSET_TABLE_-(.LPCS0-.)) >> 16) & 65535), r12
- shori ((datalabel _GLOBAL_OFFSET_TABLE_-(.LPCS0-.)) & 65535), r12
- .LPCS0: ptrel/u r12, tr0
- st.l r15, 8, r14
- st.l r15, 12, r18
- add.l r15, r63, r14
- gettr tr0, r12
-
- .align 2
-
-
- .section .fini
- .hidden _fini
- .align 2
- .global _fini
- .type _fini, @function
-_fini:
- addi.l r15, -16, r15
- st.l r15, 4, r12
- movi (((datalabel _GLOBAL_OFFSET_TABLE_-(.LPCS1-.)) >> 16) & 65535), r12
- shori ((datalabel _GLOBAL_OFFSET_TABLE_-(.LPCS1-.)) & 65535), r12
- .LPCS1: ptrel/u r12, tr0
- st.l r15, 8, r14
- st.l r15, 12, r18
- add.l r15, r63, r14
- gettr tr0, r12
- .align 2
-
-
- .ident "GCC: (GNU) 3.3.2"
diff --git a/libc/sysdeps/linux/sh64/crtn.S b/libc/sysdeps/linux/sh64/crtn.S
deleted file mode 100644
index eb6479a56..000000000
--- a/libc/sysdeps/linux/sh64/crtn.S
+++ /dev/null
@@ -1,33 +0,0 @@
- .file "initfini.c"
- .section .text..SHmedia32,"ax"
- .little
-
- .section .init
- .hidden _init
- .align 2
- .global _init
- .type _init, @function
- add.l r14, r63, r15
- ld.l r15, 12, r18
- ld.l r15, 4, r12
- ld.l r15, 8, r14
- ptabs r18, tr0
- addi.l r15, 16, r15
- blink tr0, r63
- .size _init, .-_init
-
- .section .fini
- .hidden _fini
- .align 2
- .global _fini
- .type _fini, @function
- add.l r14, r63, r15
- ld.l r15, 12, r18
- ld.l r15, 4, r12
- ld.l r15, 8, r14
- ptabs r18, tr0
- addi.l r15, 16, r15
- blink tr0, r63
- .size _fini, .-_fini
-
- .ident "GCC: (GNU) 3.3.2"
diff --git a/libc/sysdeps/linux/sh64/setjmp.S b/libc/sysdeps/linux/sh64/setjmp.S
deleted file mode 100644
index 11d76d372..000000000
--- a/libc/sysdeps/linux/sh64/setjmp.S
+++ /dev/null
@@ -1,140 +0,0 @@
-/* setjmp for SH-5.
- Copyright (C) 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 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. */
-
-
-#define _SETJMP_H
-#define _ASM
-#include <bits/setjmp.h>
-
-
-#define INTEGER(reg,offset) st.q r2, offset*8, reg
-#define DOUBLE(reg,offset) fst.d r2, offset*8, reg
-
-
- .file "setjmp.S"
-
- .section .text64,"xa"
- .align 2
-
- .global __sigsetjmp
- .type __sigsetjmp,@function
-
-__sigsetjmp:
- /*
- * extern int __sigsetjmp(jmp_buf env, int savemask);
- *
- * r2 == env
- * r3 == savemask
- * r4 == temporary
- */
-
- /* callee-save registers R10-R16 */
- INTEGER(r10, __SETJMP_INT(0))
- INTEGER(r11, __SETJMP_INT(1))
- INTEGER(r12, __SETJMP_INT(2))
- INTEGER(r13, __SETJMP_INT(3))
- INTEGER(r14, __SETJMP_INT(4))
- INTEGER(r15, __SETJMP_INT(5))
- INTEGER(r16, __SETJMP_INT(6))
-
- /* callee-save registers R28-R35 */
- INTEGER(r28, __SETJMP_INT(7))
- INTEGER(r29, __SETJMP_INT(8))
- INTEGER(r30, __SETJMP_INT(9))
- INTEGER(r31, __SETJMP_INT(10))
- INTEGER(r32, __SETJMP_INT(11))
- INTEGER(r33, __SETJMP_INT(12))
- INTEGER(r34, __SETJMP_INT(13))
- INTEGER(r35, __SETJMP_INT(14))
-
- /* callee-save registers R44-R59 */
- INTEGER(r44, __SETJMP_INT(15))
- INTEGER(r45, __SETJMP_INT(16))
- INTEGER(r46, __SETJMP_INT(17))
- INTEGER(r47, __SETJMP_INT(18))
- INTEGER(r48, __SETJMP_INT(19))
- INTEGER(r49, __SETJMP_INT(20))
- INTEGER(r50, __SETJMP_INT(21))
- INTEGER(r51, __SETJMP_INT(22))
- INTEGER(r52, __SETJMP_INT(23))
- INTEGER(r53, __SETJMP_INT(24))
- INTEGER(r54, __SETJMP_INT(25))
- INTEGER(r55, __SETJMP_INT(26))
- INTEGER(r56, __SETJMP_INT(27))
- INTEGER(r57, __SETJMP_INT(28))
- INTEGER(r58, __SETJMP_INT(29))
- INTEGER(r59, __SETJMP_INT(30))
-
- #if __SETJMP_NUM_INT != 31
- #error __SETJMP_NUM_INT does agree with expected value
- #endif
-
-#if __SETJMP_NUM_DBL > 0
- /* callee-save registers FR12-FR15 */
- DOUBLE(d12, __SETJMP_DBL(0))
- DOUBLE(d14, __SETJMP_DBL(1))
-
- /* callee-save registers FR36-FR63 */
- DOUBLE(d36, __SETJMP_DBL(2))
- DOUBLE(d38, __SETJMP_DBL(3))
- DOUBLE(d40, __SETJMP_DBL(4))
- DOUBLE(d42, __SETJMP_DBL(5))
- DOUBLE(d44, __SETJMP_DBL(6))
- DOUBLE(d46, __SETJMP_DBL(7))
- DOUBLE(d48, __SETJMP_DBL(8))
- DOUBLE(d50, __SETJMP_DBL(9))
- DOUBLE(d52, __SETJMP_DBL(10))
- DOUBLE(d54, __SETJMP_DBL(11))
- DOUBLE(d56, __SETJMP_DBL(12))
- DOUBLE(d58, __SETJMP_DBL(13))
- DOUBLE(d60, __SETJMP_DBL(14))
- DOUBLE(d62, __SETJMP_DBL(15))
-
- #if __SETJMP_NUM_DBL != 16
- #error __SETJMP_NUM_DBL does agree with expected value
- #endif
-
-#endif /* __SETJMP_NUM_DBL > 0 */
-
- /* callee-save registers TR5-TR7 */
- gettr tr5, r4
- INTEGER(r4, __SETJMP_TRG(0))
- gettr tr6, r4
- INTEGER(r4, __SETJMP_TRG(1))
- gettr tr7, r4
- INTEGER(r4, __SETJMP_TRG(2))
-
- #if __SETJMP_NUM_TRG != 3
- #error __SETJMP_NUM_TRG does agree with expected value
- #endif
-
- /* save Linkage Register (LR) for longjmp return */
- INTEGER(r18, __SETJMP_LR)
-
- /*
- * return a value of zero if call is __sigsetjmp().
- * This is so that caller of setjmp() knows
- * we have retruned via setjmp, and not via longjmp.
- * R0 is the result register.
- */
-
- ptabs/l r18, tr0 /* return to caller */
- movi 0, r2 /* return value */
- blink tr0, r63
-
diff --git a/libc/sysdeps/linux/sh64/sys/ucontext.h b/libc/sysdeps/linux/sh64/sys/ucontext.h
deleted file mode 100644
index 74407841a..000000000
--- a/libc/sysdeps/linux/sh64/sys/ucontext.h
+++ /dev/null
@@ -1,205 +0,0 @@
-/* Copyright (C) 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 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. */
-
-/* Where is System V/SH ABI? */
-
-#ifndef _SYS_UCONTEXT_H
-#define _SYS_UCONTEXT_H 1
-
-#include <features.h>
-#include <signal.h>
-
-/* We need the signal context definitions even if they are not used
- included in <signal.h>. */
-#include <bits/sigcontext.h>
-
-
-typedef long long greg_t;
-
-/* Number of general registers. */
-#define NGREG 64
-
-/* Container for all general registers. */
-typedef greg_t gregset_t[NGREG];
-
-#ifdef __USE_GNU
-/* Number of each register is the `gregset_t' array. */
-enum
-{
- R0 = 0,
-#define R0 R0
- R1 = 1,
-#define R1 R1
- R2 = 2,
-#define R2 R2
- R3 = 3,
-#define R3 R3
- R4 = 4,
-#define R4 R4
- R5 = 5,
-#define R5 R5
- R6 = 6,
-#define R6 R6
- R7 = 7,
-#define R7 R7
- R8 = 8,
-#define R8 R8
- R9 = 9,
-#define R9 R9
- R10 = 10,
-#define R10 R10
- R11 = 11,
-#define R11 R11
- R12 = 12,
-#define R12 R12
- R13 = 13,
-#define R13 R13
- R14 = 14,
-#define R14 R14
- R15 = 15,
-#define R15 R15
- R16 = 16,
-#define R16 R16
- R17 = 17,
-#define R17 R17
- R18 = 18,
-#define R18 R18
- R19 = 19,
-#define R19 R19
- R20 = 20,
-#define R20 R20
- R21 = 21,
-#define R21 R21
- R22 = 22,
-#define R22 R22
- R23 = 23,
-#define R23 R23
- R24 = 24,
-#define R24 R24
- R25 = 25,
-#define R25 R25
- R26 = 26,
-#define R26 R26
- R27 = 27,
-#define R27 R27
- R28 = 28,
-#define R28 R28
- R29 = 29,
-#define R29 R29
- R30 = 30,
-#define R30 R30
- R31 = 31,
-#define R31 R31
- R32 = 32,
-#define R32 R32
- R33 = 33,
-#define R33 R33
- R34 = 34,
-#define R34 R34
- R35 = 35,
-#define R35 R35
- R36 = 36,
-#define R36 R36
- R37 = 37,
-#define R37 R37
- R38 = 38,
-#define R38 R38
- R39 = 39,
-#define R39 R39
- R40 = 40,
-#define R40 R40
- R41 = 41,
-#define R41 R41
- R42 = 42,
-#define R42 R42
- R43 = 43,
-#define R43 R43
- R44 = 44,
-#define R44 R44
- R45 = 45,
-#define R45 R45
- R46 = 46,
-#define R46 R46
- R47 = 47,
-#define R47 R47
- R48 = 48,
-#define R48 R48
- R49 = 49,
-#define R49 R49
- R50 = 50,
-#define R50 R50
- R51 = 51,
-#define R51 R51
- R52 = 52,
-#define R52 R52
- R53 = 53,
-#define R53 R53
- R54 = 54,
-#define R54 R54
- R55 = 55,
-#define R55 R55
- R56 = 56,
-#define R56 R56
- R57 = 57,
-#define R57 R57
- R58 = 58,
-#define R58 R58
- R59 = 59,
-#define R59 R59
- R60 = 60,
-#define R60 R60
- R61 = 61,
-#define R61 R61
- R62 = 62,
-#define R62 R62
- R63 = 63,
-#define R63 R63
-};
-#endif
-
-typedef int freg_t;
-
-/* Number of FPU registers. */
-#define NFPREG 32
-
-/* Structure to describe FPU registers. */
-typedef freg_t fpregset_t[NFPREG];
-
-/* Context to describe whole processor state. */
-typedef struct
- {
- gregset_t gregs;
- fpregset_t fpregs;
- unsigned long long sc_tregs[8];
- unsigned long long sc_pc;
- unsigned long long sc_sr;
- unsigned long long sc_fpscr;
-
- } mcontext_t;
-
-/* Userlevel context. */
-typedef struct ucontext
- {
- unsigned long int 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/sh64/syscall.c b/libc/sysdeps/linux/sh64/syscall.c
deleted file mode 100644
index a6c55ebe9..000000000
--- a/libc/sysdeps/linux/sh64/syscall.c
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-#include <features.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/syscall.h>
-
-long syscall(long sysnum,
- long arg1, long arg2, long arg3,
- long arg4, long arg5, long arg6)
-{
-register long __sc0 __asm__ ("r9") = ((0x16 << 16) | sysnum);
-register long __sc2 __asm__ ("r2") = (long) arg1;
-register long __sc3 __asm__ ("r3") = (long) arg2;
-register long __sc4 __asm__ ("r4") = (long) arg3;
-register long __sc5 __asm__ ("r5") = (long) arg4;
-register long __sc6 __asm__ ("r6") = (long) arg5;
-register long __sc7 __asm__ ("r7") = (long) arg6;
-__asm__ __volatile__ ("trapa %1" \
- : "=r" (__sc0) \
- : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4), "r" (__sc5), \
- "r" (__sc6), "r" (__sc7));
-__syscall_return(long,__sc0);
-}
diff --git a/libc/sysdeps/linux/sparc/Makefile.arch b/libc/sysdeps/linux/sparc/Makefile.arch
index 4562eaba5..0173effbf 100644
--- a/libc/sysdeps/linux/sparc/Makefile.arch
+++ b/libc/sysdeps/linux/sparc/Makefile.arch
@@ -5,10 +5,23 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-CSRC := brk.c __syscall_error.c qp_ops.c
+CSRC-y := brk.c __syscall_error.c sigaction.c
-SSRC := \
- __longjmp.S fork.S vfork.S clone.S setjmp.S bsd-setjmp.S bsd-_setjmp.S \
- syscall.S urem.S udiv.S umul.S sdiv.S rem.S
+SSRC-y := \
+ __longjmp.S setjmp.S bsd-setjmp.S bsd-_setjmp.S \
+ syscall.S urem.S udiv.S umul.S sdiv.S rem.S pipe.S
-include $(top_srcdir)libc/sysdeps/linux/Makefile.commonarch
+SSRC-$(if $(UCLIBC_HAS_THREADS_NATIVE),,y) += fork.S vfork.S clone.S
+
+# check weather __LONG_DOUBLE_128__ is defined (long double support)
+UCLIBC_SPARC_HAS_LONG_DOUBLE=$(shell if [ "x`$(CC) -E -dM -xc /dev/null 2>&1 | grep __LONG_DOUBLE_128__`" != "x" ]; then echo "y"; fi)
+ifeq ($(UCLIBC_SPARC_HAS_LONG_DOUBLE),y)
+CSRC-y += $(addprefix soft-fp/, \
+ q_div.c q_fle.c q_mul.c q_qtoll.c q_stoq.c \
+ mp_clz_tab.c q_dtoq.c q_flt.c q_neg.c q_qtos.c q_sub.c \
+ q_add.c q_feq.c q_fne.c q_qtod.c q_qtou.c q_ulltoq.c \
+ q_cmp.c q_fge.c q_itoq.c q_qtoull.c q_util.c \
+ q_cmpe.c q_fgt.c q_lltoq.c q_qtoi.c q_sqrt.c q_utoq.c)
+else
+CSRC-y += qp_ops.c
+endif
diff --git a/libc/sysdeps/linux/sparc/__longjmp.S b/libc/sysdeps/linux/sparc/__longjmp.S
index c7d4f0794..31c5314c7 100644
--- a/libc/sysdeps/linux/sparc/__longjmp.S
+++ b/libc/sysdeps/linux/sparc/__longjmp.S
@@ -12,16 +12,11 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
-#include <features.h>
-#include <sys/syscall.h>
+#include <jmpbuf-offsets.h>
-#define _ASM 1
-#define _SETJMP_H
-#include <bits/setjmp.h>
#define ENV(base,reg) [%base + (reg * 4)]
#define ST_FLUSH_WINDOWS 3
#define RW_FP [%fp + 0x48]
diff --git a/libc/sysdeps/linux/sparc/bits/atomic.h b/libc/sysdeps/linux/sparc/bits/atomic.h
new file mode 100644
index 000000000..4941c038b
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/bits/atomic.h
@@ -0,0 +1,328 @@
+/* Atomic operations. sparc32 version.
+ Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _BITS_ATOMIC_H
+#define _BITS_ATOMIC_H 1
+
+#include <stdint.h>
+
+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 int16_t atomic16_t;
+typedef uint16_t uatomic16_t;
+typedef int_fast16_t atomic_fast16_t;
+typedef uint_fast16_t uatomic_fast16_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 int64_t atomic64_t;
+typedef uint64_t uatomic64_t;
+typedef int_fast64_t atomic_fast64_t;
+typedef uint_fast64_t uatomic_fast64_t;
+
+typedef intptr_t atomicptr_t;
+typedef uintptr_t uatomicptr_t;
+typedef intmax_t atomic_max_t;
+typedef uintmax_t uatomic_max_t;
+
+
+/* We have no compare and swap, just test and set.
+ The following implementation contends on 64 global locks
+ per library and assumes no variable will be accessed using atomic.h
+ macros from two different libraries. */
+
+__make_section_unallocated
+ (".gnu.linkonce.b.__sparc32_atomic_locks, \"aw\", %nobits");
+
+volatile unsigned char __sparc32_atomic_locks[64]
+ __attribute__ ((nocommon, section (".gnu.linkonce.b.__sparc32_atomic_locks"
+ __sec_comment),
+ visibility ("hidden")));
+
+#define __sparc32_atomic_do_lock(addr) \
+ do \
+ { \
+ unsigned int __old_lock; \
+ unsigned int __idx = (((long) addr >> 2) ^ ((long) addr >> 12)) \
+ & 63; \
+ do \
+ __asm__ __volatile__ ("ldstub %1, %0" \
+ : "=r" (__old_lock), \
+ "=m" (__sparc32_atomic_locks[__idx]) \
+ : "m" (__sparc32_atomic_locks[__idx]) \
+ : "memory"); \
+ while (__old_lock); \
+ } \
+ while (0)
+
+#define __sparc32_atomic_do_unlock(addr) \
+ do \
+ { \
+ __sparc32_atomic_locks[(((long) addr >> 2) \
+ ^ ((long) addr >> 12)) & 63] = 0; \
+ __asm__ __volatile__ ("" ::: "memory"); \
+ } \
+ while (0)
+
+#define __sparc32_atomic_do_lock24(addr) \
+ do \
+ { \
+ unsigned int __old_lock; \
+ do \
+ __asm__ __volatile__ ("ldstub %1, %0" \
+ : "=r" (__old_lock), "=m" (*(addr)) \
+ : "m" (*(addr)) \
+ : "memory"); \
+ while (__old_lock); \
+ } \
+ while (0)
+
+#define __sparc32_atomic_do_unlock24(addr) \
+ do \
+ { \
+ *(char *) (addr) = 0; \
+ __asm__ __volatile__ ("" ::: "memory"); \
+ } \
+ while (0)
+
+
+#ifndef SHARED
+# define __v9_compare_and_exchange_val_32_acq(mem, newval, oldval) \
+({ \
+ register __typeof (*(mem)) __acev_tmp __asm__ ("%g6"); \
+ register __typeof (mem) __acev_mem __asm__ ("%g1") = (mem); \
+ register __typeof (*(mem)) __acev_oldval __asm__ ("%g5"); \
+ __acev_tmp = (newval); \
+ __acev_oldval = (oldval); \
+ /* .word 0xcde05005 is cas [%g1], %g5, %g6. Can't use cas here though, \
+ because as will then mark the object file as V8+ arch. */ \
+ __asm__ __volatile__ (".word 0xcde05005" \
+ : "+r" (__acev_tmp), "=m" (*__acev_mem) \
+ : "r" (__acev_oldval), "m" (*__acev_mem), \
+ "r" (__acev_mem) : "memory"); \
+ __acev_tmp; })
+#endif
+
+/* The only basic operation needed is compare and exchange. */
+#define __v7_compare_and_exchange_val_acq(mem, newval, oldval) \
+ ({ __typeof (mem) __acev_memp = (mem); \
+ __typeof (*mem) __acev_ret; \
+ __typeof (*mem) __acev_newval = (newval); \
+ \
+ __sparc32_atomic_do_lock (__acev_memp); \
+ __acev_ret = *__acev_memp; \
+ if (__acev_ret == (oldval)) \
+ *__acev_memp = __acev_newval; \
+ __sparc32_atomic_do_unlock (__acev_memp); \
+ __acev_ret; })
+
+#define __v7_compare_and_exchange_bool_acq(mem, newval, oldval) \
+ ({ __typeof (mem) __aceb_memp = (mem); \
+ int __aceb_ret; \
+ __typeof (*mem) __aceb_newval = (newval); \
+ \
+ __sparc32_atomic_do_lock (__aceb_memp); \
+ __aceb_ret = 0; \
+ if (*__aceb_memp == (oldval)) \
+ *__aceb_memp = __aceb_newval; \
+ else \
+ __aceb_ret = 1; \
+ __sparc32_atomic_do_unlock (__aceb_memp); \
+ __aceb_ret; })
+
+#define __v7_exchange_acq(mem, newval) \
+ ({ __typeof (mem) __acev_memp = (mem); \
+ __typeof (*mem) __acev_ret; \
+ __typeof (*mem) __acev_newval = (newval); \
+ \
+ __sparc32_atomic_do_lock (__acev_memp); \
+ __acev_ret = *__acev_memp; \
+ *__acev_memp = __acev_newval; \
+ __sparc32_atomic_do_unlock (__acev_memp); \
+ __acev_ret; })
+
+#define __v7_exchange_and_add(mem, value) \
+ ({ __typeof (mem) __acev_memp = (mem); \
+ __typeof (*mem) __acev_ret; \
+ \
+ __sparc32_atomic_do_lock (__acev_memp); \
+ __acev_ret = *__acev_memp; \
+ *__acev_memp = __acev_ret + (value); \
+ __sparc32_atomic_do_unlock (__acev_memp); \
+ __acev_ret; })
+
+/* Special versions, which guarantee that top 8 bits of all values
+ are cleared and use those bits as the ldstub lock. */
+#define __v7_compare_and_exchange_val_24_acq(mem, newval, oldval) \
+ ({ __typeof (mem) __acev_memp = (mem); \
+ __typeof (*mem) __acev_ret; \
+ __typeof (*mem) __acev_newval = (newval); \
+ \
+ __sparc32_atomic_do_lock24 (__acev_memp); \
+ __acev_ret = *__acev_memp & 0xffffff; \
+ if (__acev_ret == (oldval)) \
+ *__acev_memp = __acev_newval; \
+ else \
+ __sparc32_atomic_do_unlock24 (__acev_memp); \
+ __asm__ __volatile__ ("" ::: "memory"); \
+ __acev_ret; })
+
+#define __v7_exchange_24_rel(mem, newval) \
+ ({ __typeof (mem) __acev_memp = (mem); \
+ __typeof (*mem) __acev_ret; \
+ __typeof (*mem) __acev_newval = (newval); \
+ \
+ __sparc32_atomic_do_lock24 (__acev_memp); \
+ __acev_ret = *__acev_memp & 0xffffff; \
+ *__acev_memp = __acev_newval; \
+ __asm__ __volatile__ ("" ::: "memory"); \
+ __acev_ret; })
+
+#ifdef SHARED
+
+/* When dynamically linked, we assume pre-v9 libraries are only ever
+ used on pre-v9 CPU. */
+# define __atomic_is_v9 0
+
+# define atomic_compare_and_exchange_val_acq(mem, newval, oldval) \
+ __v7_compare_and_exchange_val_acq (mem, newval, oldval)
+
+# define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \
+ __v7_compare_and_exchange_bool_acq (mem, newval, oldval)
+
+# define atomic_exchange_acq(mem, newval) \
+ __v7_exchange_acq (mem, newval)
+
+# define atomic_exchange_and_add(mem, value) \
+ __v7_exchange_and_add (mem, value)
+
+# define atomic_compare_and_exchange_val_24_acq(mem, newval, oldval) \
+ ({ \
+ if (sizeof (*mem) != 4) \
+ abort (); \
+ __v7_compare_and_exchange_val_24_acq (mem, newval, oldval); })
+
+# define atomic_exchange_24_rel(mem, newval) \
+ ({ \
+ if (sizeof (*mem) != 4) \
+ abort (); \
+ __v7_exchange_24_rel (mem, newval); })
+
+#else
+
+
+
+/*
+ Here's what we'd like to do:
+
+ In libc.a/libpthread.a etc. we don't know if we'll be run on
+ pre-v9 or v9 CPU. To be interoperable with dynamically linked
+ apps on v9 CPUs e.g. with process shared primitives, use cas insn
+ on v9 CPUs and ldstub on pre-v9.
+
+ However, we have no good way to test at run time that I know of,
+ so resort to the lowest common denominator (v7 ops) -austinf
+ */
+#define __atomic_is_v9 0
+
+# define atomic_compare_and_exchange_val_acq(mem, newval, oldval) \
+ ({ \
+ __typeof (*mem) __acev_wret; \
+ if (sizeof (*mem) != 4) \
+ abort (); \
+ if (__atomic_is_v9) \
+ __acev_wret \
+ = __v9_compare_and_exchange_val_32_acq (mem, newval, oldval);\
+ else \
+ __acev_wret \
+ = __v7_compare_and_exchange_val_acq (mem, newval, oldval); \
+ __acev_wret; })
+
+# define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \
+ ({ \
+ int __acev_wret; \
+ if (sizeof (*mem) != 4) \
+ abort (); \
+ if (__atomic_is_v9) \
+ { \
+ __typeof (oldval) __acev_woldval = (oldval); \
+ __acev_wret \
+ = __v9_compare_and_exchange_val_32_acq (mem, newval, \
+ __acev_woldval) \
+ != __acev_woldval; \
+ } \
+ else \
+ __acev_wret \
+ = __v7_compare_and_exchange_bool_acq (mem, newval, oldval); \
+ __acev_wret; })
+
+# define atomic_exchange_rel(mem, newval) \
+ ({ \
+ __typeof (*mem) __acev_wret; \
+ if (sizeof (*mem) != 4) \
+ abort (); \
+ if (__atomic_is_v9) \
+ { \
+ __typeof (mem) __acev_wmemp = (mem); \
+ __typeof (*(mem)) __acev_wval = (newval); \
+ do \
+ __acev_wret = *__acev_wmemp; \
+ while (unlikely \
+ (__v9_compare_and_exchange_val_32_acq (__acev_wmemp,\
+ __acev_wval, \
+ __acev_wret) \
+ != __acev_wret)); \
+ } \
+ else \
+ __acev_wret = __v7_exchange_acq (mem, newval); \
+ __acev_wret; })
+
+# define atomic_compare_and_exchange_val_24_acq(mem, newval, oldval) \
+ ({ \
+ __typeof (*mem) __acev_wret; \
+ if (sizeof (*mem) != 4) \
+ abort (); \
+ if (__atomic_is_v9) \
+ __acev_wret \
+ = __v9_compare_and_exchange_val_32_acq (mem, newval, oldval);\
+ else \
+ __acev_wret \
+ = __v7_compare_and_exchange_val_24_acq (mem, newval, oldval);\
+ __acev_wret; })
+
+# define atomic_exchange_24_rel(mem, newval) \
+ ({ \
+ __typeof (*mem) __acev_w24ret; \
+ if (sizeof (*mem) != 4) \
+ abort (); \
+ if (__atomic_is_v9) \
+ __acev_w24ret = atomic_exchange_rel (mem, newval); \
+ else \
+ __acev_w24ret = __v7_exchange_24_rel (mem, newval); \
+ __acev_w24ret; })
+
+#endif
+
+#endif /* bits/atomic.h */
diff --git a/libc/sysdeps/linux/sparc/bits/epoll.h b/libc/sysdeps/linux/sparc/bits/epoll.h
new file mode 100644
index 000000000..532402016
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/bits/epoll.h
@@ -0,0 +1,29 @@
+/* Copyright (C) 2002-2012 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_EPOLL_H
+# error "Never use <bits/epoll.h> directly; include <sys/epoll.h> instead."
+#endif
+
+/* Flags to be passed to epoll_create1. */
+enum
+ {
+ EPOLL_CLOEXEC = 0x400000,
+#define EPOLL_CLOEXEC EPOLL_CLOEXEC
+ EPOLL_NONBLOCK = 0x004000
+#define EPOLL_NONBLOCK EPOLL_NONBLOCK
+ };
diff --git a/libc/sysdeps/linux/sparc/bits/eventfd.h b/libc/sysdeps/linux/sparc/bits/eventfd.h
new file mode 100644
index 000000000..e348cc6fb
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/bits/eventfd.h
@@ -0,0 +1,31 @@
+/* Copyright (C) 2007-2013 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_EVENTFD_H
+# error "Never use <bits/eventfd.h> directly; include <sys/eventfd.h> instead."
+#endif
+
+/* Flags for eventfd. */
+enum
+ {
+ EFD_SEMAPHORE = 0x000001,
+#define EFD_SEMAPHORE EFD_SEMAPHORE
+ EFD_CLOEXEC = 0x400000,
+#define EFD_CLOEXEC EFD_CLOEXEC
+ EFD_NONBLOCK = 0x004000
+#define EFD_NONBLOCK EFD_NONBLOCK
+ };
diff --git a/libc/sysdeps/linux/sparc/bits/fcntl.h b/libc/sysdeps/linux/sparc/bits/fcntl.h
index 5739459b0..bc744edfd 100644
--- a/libc/sysdeps/linux/sparc/bits/fcntl.h
+++ b/libc/sysdeps/linux/sparc/bits/fcntl.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FCNTL_H
# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
@@ -47,11 +46,10 @@
#ifdef __USE_GNU
# define O_DIRECTORY 0x10000 /* must be a directory */
# define O_NOFOLLOW 0x20000 /* don't follow links */
-# define O_DIRECT 0x100000 /* direct disk access hint */
-# define O_NOATIME 0x200000 /* Do not set atime. */
-# if 0
-# define O_CLOEXEC 0x400000 /* Set close_on_exit. */
-# endif
+# define O_DIRECT 0x100000 /* direct disk access hint */
+# define O_NOATIME 0x200000 /* Do not set atime. */
+# define O_CLOEXEC 0x400000 /* Set close_on_exit. */
+# define O_PATH 0x1000000 /* Resolve pathname but do not open file. */
#endif
#ifdef __USE_LARGEFILE64
@@ -109,6 +107,8 @@
# define F_NOTIFY 1026 /* Request notfications on a directory. */
# define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with
close-on-exit set on new fd. */
+# define F_SETPIPE_SZ 1031 /* Set pipe page size array. */
+# define F_GETPIPE_SZ 1032 /* Get pipe page size array. */
#endif
#if __WORDSIZE == 64
@@ -208,7 +208,7 @@ struct flock64
#endif
-#ifdef __USE_GNU
+#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
@@ -231,7 +231,7 @@ struct flock64
__BEGIN_DECLS
-#ifdef __USE_GNU
+#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)
diff --git a/libc/sysdeps/linux/sparc/bits/fenv.h b/libc/sysdeps/linux/sparc/bits/fenv.h
index d2ef97e0e..61d45591c 100644
--- a/libc/sysdeps/linux/sparc/bits/fenv.h
+++ b/libc/sysdeps/linux/sparc/bits/fenv.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FENV_H
# error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
@@ -68,11 +67,11 @@ typedef unsigned long int fexcept_t;
typedef unsigned long int fenv_t;
/* If the default argument is used we use this value. */
-#define FE_DFL_ENV ((__const fenv_t *) -1)
+#define FE_DFL_ENV ((const fenv_t *) -1)
#ifdef __USE_GNU
/* Floating-point environment where none of the exception is masked. */
-# define FE_NOMASK_ENV ((__const fenv_t *) -2)
+# define FE_NOMASK_ENV ((const fenv_t *) -2)
#endif
/* For internal use only: access the fp state register. */
diff --git a/libc/sysdeps/linux/sparc/bits/huge_vall.h b/libc/sysdeps/linux/sparc/bits/huge_vall.h
new file mode 100644
index 000000000..5c44edc57
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/bits/huge_vall.h
@@ -0,0 +1,48 @@
+/* `HUGE_VALL' constant for IEEE 754 machines (where it is infinity).
+ Used by <stdlib.h> and <math.h> functions for overflow.
+ Copyright (C) 1992, 1995, 1996, 1997, 1999, 2000, 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.
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _MATH_H
+# error "Never use <bits/huge_vall.h> directly; include <math.h> instead."
+#endif
+
+#if __GNUC_PREREQ(3,3)
+# define HUGE_VALL (__builtin_huge_vall())
+#else
+# include <bits/wordsize.h>
+# if __WORDSIZE == 32
+# define HUGE_VALL ((long double) HUGE_VAL)
+# elif __GNUC_PREREQ(2,96)
+# define HUGE_VALL (__extension__ 0x1.0p32767L)
+# elif defined __GNUC__
+
+# define HUGE_VALL \
+ (__extension__ \
+ ((union { struct { unsigned long __h, __l; } __i; long double __d; }) \
+ { __i: { __h: 0x7fff000000000000UL, __l: 0 } }).__d)
+
+# else /* not GCC */
+
+typedef union { unsigned char __c[16]; long double __d; } __huge_vall_t;
+# define __HUGE_VALL_bytes { 0x7f, 0xff, 0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
+static __huge_vall_t __huge_vall = { __HUGE_VALL_bytes };
+# define HUGE_VALL (__huge_vall.__d)
+
+# endif /* GCC. */
+#endif /* GCC 3.3. */
diff --git a/libc/sysdeps/linux/sparc/bits/inotify.h b/libc/sysdeps/linux/sparc/bits/inotify.h
new file mode 100644
index 000000000..ca62d89a0
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/bits/inotify.h
@@ -0,0 +1,29 @@
+/* Copyright (C) 2005-2012 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_INOTIFY_H
+# error "Never use <bits/inotify.h> directly; include <sys/inotify.h> instead."
+#endif
+
+/* Flags for the parameter of inotify_init1. */
+enum
+ {
+ IN_CLOEXEC = 0x400000,
+#define IN_CLOEXEC IN_CLOEXEC
+ IN_NONBLOCK = 0x004000
+#define IN_NONBLOCK IN_NONBLOCK
+ };
diff --git a/libc/sysdeps/linux/sparc/bits/ioctls.h b/libc/sysdeps/linux/sparc/bits/ioctls.h
index e86c503f2..e3bf13c4d 100644
--- a/libc/sysdeps/linux/sparc/bits/ioctls.h
+++ b/libc/sysdeps/linux/sparc/bits/ioctls.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_IOCTL_H
# error "Never use <bits/ioctls.h> directly; include <sys/ioctl.h> instead."
diff --git a/libc/sysdeps/linux/sparc/bits/ipc.h b/libc/sysdeps/linux/sparc/bits/ipc.h
index 988dc125d..88fab1e47 100644
--- a/libc/sysdeps/linux/sparc/bits/ipc.h
+++ b/libc/sysdeps/linux/sparc/bits/ipc.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_IPC_H
# error "Never use <bits/ipc.h> directly; include <sys/ipc.h> instead."
diff --git a/libc/sysdeps/linux/sparc/bits/kernel_stat.h b/libc/sysdeps/linux/sparc/bits/kernel_stat.h
index ab85be257..f09ae3734 100644
--- a/libc/sysdeps/linux/sparc/bits/kernel_stat.h
+++ b/libc/sysdeps/linux/sparc/bits/kernel_stat.h
@@ -1,13 +1,10 @@
#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... */
+
#if __WORDSIZE == 64
#define kernel_stat kernel_stat64
#else
@@ -20,12 +17,9 @@ struct kernel_stat {
unsigned short st_gid;
unsigned short st_rdev;
long st_size;
- long st_atime;
- unsigned long __unused1;
- long st_mtime;
- unsigned long __unused2;
- long st_ctime;
- unsigned long __unused3;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
long st_blksize;
long st_blocks;
unsigned long __unused4[2];
@@ -46,12 +40,9 @@ struct kernel_stat64 {
unsigned int st_blksize;
unsigned char __pad4[8];
unsigned int st_blocks;
- unsigned int st_atime;
- unsigned int st_atime_nsec;
- unsigned int st_mtime;
- unsigned int st_mtime_nsec;
- unsigned int st_ctime;
- unsigned int st_ctime_nsec;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
unsigned int __unused4;
unsigned int __unused5;
};
diff --git a/libc/sysdeps/linux/sparc/bits/kernel_types.h b/libc/sysdeps/linux/sparc/bits/kernel_types.h
index 1b2452446..a10e075de 100644
--- a/libc/sysdeps/linux/sparc/bits/kernel_types.h
+++ b/libc/sysdeps/linux/sparc/bits/kernel_types.h
@@ -4,9 +4,10 @@
* our private content, and not the kernel header, will win.
* -Erik
*/
-#if ! defined __ARCH_SPARC_POSIX_TYPES_H && ! defined __ARCH_SPARC64_POSIX_TYPES_H
+#if ! defined __ARCH_SPARC_POSIX_TYPES_H && ! defined __ARCH_SPARC64_POSIX_TYPES_H && !defined __SPARC_POSIX_TYPES_H
#define __ARCH_SPARC_POSIX_TYPES_H
#define __ARCH_SPARC64_POSIX_TYPES_H
+#define __SPARC_POSIX_TYPES_H
# if __WORDSIZE == 64
typedef unsigned long __kernel_size_t;
@@ -31,6 +32,8 @@ typedef unsigned short __kernel_gid16_t;
typedef __kernel_uid_t __kernel_old_uid_t;
typedef __kernel_gid_t __kernel_old_gid_t;
typedef __kernel_dev_t __kernel_old_dev_t;
+typedef long __kernel_long_t;
+typedef unsigned long __kernel_ulong_t;
typedef __kernel_uid_t __kernel_uid32_t;
typedef __kernel_gid_t __kernel_gid32_t;
typedef int __kernel_suseconds_t;
@@ -61,6 +64,8 @@ typedef unsigned int __kernel_gid32_t;
typedef unsigned short __kernel_old_uid_t;
typedef unsigned short __kernel_old_gid_t;
typedef __kernel_dev_t __kernel_old_dev_t;
+typedef long __kernel_long_t;
+typedef unsigned long __kernel_ulong_t;
typedef long long __kernel_loff_t;
#endif
diff --git a/libc/sysdeps/linux/sparc/bits/local_lim.h b/libc/sysdeps/linux/sparc/bits/local_lim.h
new file mode 100644
index 000000000..4e7c9b60d
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/bits/local_lim.h
@@ -0,0 +1,99 @@
+/* Minimum guaranteed maximum values for system limits. Linux/SPARC version.
+ Copyright (C) 1993-1998,2000,2002-2004,2008 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ 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,
+ see <http://www.gnu.org/licenses/>. */
+
+/* The kernel header pollutes the namespace with the NR_OPEN symbol
+ and defines LINK_MAX although filesystems have different maxima. A
+ similar thing is true for OPEN_MAX: the limit can be changed at
+ runtime and therefore the macro must not be defined. Remove this
+ after including the header if necessary. */
+#ifndef NR_OPEN
+# define __undef_NR_OPEN
+#endif
+#ifndef LINK_MAX
+# define __undef_LINK_MAX
+#endif
+#ifndef OPEN_MAX
+# define __undef_OPEN_MAX
+#endif
+#ifndef ARG_MAX
+# define __undef_ARG_MAX
+#endif
+
+/* The kernel sources contain a file with all the needed information. */
+#include <linux/limits.h>
+
+/* Have to remove NR_OPEN? */
+#ifdef __undef_NR_OPEN
+# undef NR_OPEN
+# undef __undef_NR_OPEN
+#endif
+/* Have to remove LINK_MAX? */
+#ifdef __undef_LINK_MAX
+# undef LINK_MAX
+# undef __undef_LINK_MAX
+#endif
+/* Have to remove OPEN_MAX? */
+#ifdef __undef_OPEN_MAX
+# undef OPEN_MAX
+# undef __undef_OPEN_MAX
+#endif
+/* Have to remove ARG_MAX? */
+#ifdef __undef_ARG_MAX
+# undef ARG_MAX
+# undef __undef_ARG_MAX
+#endif
+
+/* The number of data keys per process. */
+#define _POSIX_THREAD_KEYS_MAX 128
+/* This is the value this implementation supports. */
+#define PTHREAD_KEYS_MAX 1024
+
+/* Controlling the iterations of destructors for thread-specific data. */
+#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
+/* Number of iterations this implementation does. */
+#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
+
+/* The number of threads per process. */
+#define _POSIX_THREAD_THREADS_MAX 64
+/* We have no predefined limit on the number of threads. */
+#undef PTHREAD_THREADS_MAX
+
+/* Maximum amount by which a process can descrease its asynchronous I/O
+ priority level. */
+#define AIO_PRIO_DELTA_MAX 20
+
+/* Minimum size for a thread. We are free to choose a reasonable value. */
+#define PTHREAD_STACK_MIN 24576
+
+/* Maximum number of timer expiration overruns. */
+#define DELAYTIMER_MAX 2147483647
+
+/* Maximum tty name length. */
+#define TTY_NAME_MAX 32
+
+/* Maximum login name length. This is arbitrary. */
+#define LOGIN_NAME_MAX 256
+
+/* Maximum host name length. */
+#define HOST_NAME_MAX 64
+
+/* Maximum message queue priority level. */
+#define MQ_PRIO_MAX 32768
+
+/* Maximum value the semaphore can have. */
+#define SEM_VALUE_MAX (2147483647)
diff --git a/libc/sysdeps/linux/sparc/bits/mathdef.h b/libc/sysdeps/linux/sparc/bits/mathdef.h
index 7f9bbee81..15c0bc750 100644
--- a/libc/sysdeps/linux/sparc/bits/mathdef.h
+++ b/libc/sysdeps/linux/sparc/bits/mathdef.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#if !defined _MATH_H && !defined _COMPLEX_H
# error "Never use <bits/mathdef.h> directly; include <math.h> instead"
@@ -29,28 +28,10 @@
#if defined __USE_ISOC99 && defined _MATH_H && !defined _MATH_H_MATHDEF
# define _MATH_H_MATHDEF 1
-# ifdef __GNUC__
-# if __STDC__ == 1
-
-/* In GNU or ANSI mode, gcc leaves `float' expressions as-is. */
+/* SPARC has both `float' and `double' arithmetic. */
typedef float float_t;
typedef double double_t;
-# else
-
-/* For `gcc -traditional', `float' expressions are evaluated as `double'. */
-typedef double float_t;
-typedef double double_t;
-
-# endif
-# else
-
-/* Wild guess at types for float_t and double_t. */
-typedef double float_t;
-typedef double double_t;
-
-# endif
-
/* The values returned by `ilogb' for 0 and NaN respectively. */
# define FP_ILOGB0 (-2147483647)
# define FP_ILOGBNAN (2147483647)
diff --git a/libc/sysdeps/linux/sparc/bits/mathinline.h b/libc/sysdeps/linux/sparc/bits/mathinline.h
index 729145e14..ccc84bcc2 100644
--- a/libc/sysdeps/linux/sparc/bits/mathinline.h
+++ b/libc/sysdeps/linux/sparc/bits/mathinline.h
@@ -15,9 +15,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _MATH_H
# error "Never use <bits/mathinline.h> directly; include <math.h> instead."
@@ -94,7 +93,7 @@
# define __unordered_v9cmp(x, y, op, qop) \
(__extension__ \
- ({ unsigned __r; \
+ ({ unsigned __r; \
if (sizeof (x) == 4 && sizeof (y) == 4) \
{ \
float __x = (x); float __y = (y); \
@@ -111,7 +110,7 @@
{ \
long double __x = (x); long double __y = (y); \
extern int _Qp_cmp (const long double *a, const long double *b); \
- __r = qop; \
+ __r = qop; \
} \
__r; }))
@@ -131,7 +130,7 @@
# ifdef __cplusplus
# define __MATH_INLINE __inline
# else
-# define __MATH_INLINE extern __inline
+# define __MATH_INLINE __extern_inline
# endif /* __cplusplus */
/* The gcc, version 2.7 or below, has problems with all this inlining
diff --git a/libc/sysdeps/linux/sparc/bits/mman.h b/libc/sysdeps/linux/sparc/bits/mman.h
index be2b7eb28..cf1d18096 100644
--- a/libc/sysdeps/linux/sparc/bits/mman.h
+++ b/libc/sysdeps/linux/sparc/bits/mman.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_MMAN_H
# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
@@ -65,6 +64,8 @@
# define _MAP_NEW 0x80000000 /* Binary compatibility with SunOS. */
# define MAP_POPULATE 0x8000 /* Populate (prefault) pagetables. */
# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */
+# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could
+ be uninitialized. */
#endif
/* Flags to `msync'. */
diff --git a/libc/sysdeps/linux/sparc/bits/msq.h b/libc/sysdeps/linux/sparc/bits/msq.h
index 1268dc858..cdf5452dc 100644
--- a/libc/sysdeps/linux/sparc/bits/msq.h
+++ b/libc/sysdeps/linux/sparc/bits/msq.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_MSG_H
# error "Never use <bits/msq.h> directly; include <sys/msg.h> instead."
diff --git a/libc/sysdeps/linux/sparc/bits/poll.h b/libc/sysdeps/linux/sparc/bits/poll.h
index 53b94bc50..245659695 100644
--- a/libc/sysdeps/linux/sparc/bits/poll.h
+++ b/libc/sysdeps/linux/sparc/bits/poll.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_POLL_H
# error "Never use <bits/poll.h> directly; include <sys/poll.h> instead."
diff --git a/libc/sysdeps/linux/sparc/bits/resource.h b/libc/sysdeps/linux/sparc/bits/resource.h
index 3f2c60014..1da1fc074 100644
--- a/libc/sysdeps/linux/sparc/bits/resource.h
+++ b/libc/sysdeps/linux/sparc/bits/resource.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_RESOURCE_H
# error "Never use <bits/resource.h> directly; include <sys/resource.h> instead."
diff --git a/libc/sysdeps/linux/sparc/bits/sem.h b/libc/sysdeps/linux/sparc/bits/sem.h
index 288076510..e57b505fc 100644
--- a/libc/sysdeps/linux/sparc/bits/sem.h
+++ b/libc/sysdeps/linux/sparc/bits/sem.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_SEM_H
# error "Never include <bits/sem.h> directly; use <sys/sem.h> instead."
diff --git a/libc/sysdeps/linux/sparc/bits/setjmp.h b/libc/sysdeps/linux/sparc/bits/setjmp.h
index ac5a4b2d6..26f62126a 100644
--- a/libc/sysdeps/linux/sparc/bits/setjmp.h
+++ b/libc/sysdeps/linux/sparc/bits/setjmp.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997,1999,2000,2003 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1999, 2000, 2003, 2005, 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
@@ -12,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _BITS_SETJMP_H
#define _BITS_SETJMP_H 1
@@ -25,60 +25,6 @@
#include <bits/wordsize.h>
-#if 0 /*__WORDSIZE == 64*/
-
-#ifndef _ASM
-typedef struct __sparc64_jmp_buf
- {
- struct __sparc64_jmp_buf *uc_link;
- unsigned long uc_flags;
- unsigned long uc_sigmask;
- struct __sparc64_jmp_buf_mcontext
- {
- unsigned long mc_gregs[19];
- unsigned long mc_fp;
- unsigned long mc_i7;
- struct __sparc64_jmp_buf_fpu
- {
- union
- {
- unsigned int sregs[32];
- unsigned long dregs[32];
- long double qregs[16];
- } mcfpu_fpregs;
- unsigned long mcfpu_fprs;
- unsigned long mcfpu_gsr;
- void *mcfpu_fq;
- unsigned char mcfpu_qcnt;
- unsigned char mcfpu_qentsz;
- unsigned char mcfpu_enab;
- } mc_fpregs;
- } uc_mcontext;
- } __jmp_buf[1];
-#endif
-
-/* Test if longjmp to JMPBUF would unwind the frame
- containing a local variable at ADDRESS. */
-#define _JMPBUF_UNWINDS(jmpbuf, address) \
- ((unsigned long int) (address) < (jmpbuf)->uc_mcontext.mc_fp)
-
-#else
-
-#if defined __USE_MISC || defined _ASM
-# define JB_SP 0
-# define JB_FP 1
-# define JB_PC 2
-#endif
-
-#ifndef _ASM
typedef int __jmp_buf[3];
-#endif
-
-/* Test if longjmp to JMPBUF would unwind the frame
- containing a local variable at ADDRESS. */
-#define _JMPBUF_UNWINDS(jmpbuf, address) \
- ((int) (address) < (jmpbuf)[JB_SP])
-
-#endif
#endif /* bits/setjmp.h */
diff --git a/libc/sysdeps/linux/sparc/bits/shm.h b/libc/sysdeps/linux/sparc/bits/shm.h
index 03decb110..fff3769d7 100644
--- a/libc/sysdeps/linux/sparc/bits/shm.h
+++ b/libc/sysdeps/linux/sparc/bits/shm.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_SHM_H
# error "Never include <bits/shm.h> directly; use <sys/shm.h> instead."
diff --git a/libc/sysdeps/linux/sparc/bits/sigaction.h b/libc/sysdeps/linux/sparc/bits/sigaction.h
index ee4196764..767ff4fd5 100644
--- a/libc/sysdeps/linux/sparc/bits/sigaction.h
+++ b/libc/sysdeps/linux/sparc/bits/sigaction.h
@@ -13,42 +13,29 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SIGNAL_H
# error "Never include <bits/sigaction.h> directly; use <signal.h> instead."
#endif
/* Structure describing the action to be taken when a signal arrives. */
-struct sigaction
- {
- /* Signal handler. */
+struct sigaction {
#ifdef __USE_POSIX199309
- union
- {
- /* Used if SA_SIGINFO is not set. */
- __sighandler_t sa_handler;
- /* Used if SA_SIGINFO is set. */
- void (*sa_sigaction) (int, siginfo_t *, void *);
- }
- __sigaction_handler;
-# define sa_handler __sigaction_handler.sa_handler
-# define sa_sigaction __sigaction_handler.sa_sigaction
+ union {
+ __sighandler_t sa_handler;
+ void (*sa_sigaction)(int, siginfo_t *, void *);
+ } __sigaction_handler;
+# define sa_handler __sigaction_handler.sa_handler
+# define sa_sigaction __sigaction_handler.sa_sigaction
#else
- __sighandler_t sa_handler;
+ __sighandler_t sa_handler;
#endif
-
- /* Additional set of signals to be blocked. */
- __sigset_t sa_mask;
-
- /* Special flags. */
- unsigned long sa_flags;
-
- /* Not used by Linux/Sparc yet. */
- void (*sa_restorer) (void);
- };
+ unsigned long sa_flags;
+ void (*sa_restorer)(void);
+ sigset_t sa_mask;
+};
/* Bits in `sa_flags'. */
diff --git a/libc/sysdeps/linux/sparc/bits/sigcontext.h b/libc/sysdeps/linux/sparc/bits/sigcontext.h
index 42eca544e..251032f33 100644
--- a/libc/sysdeps/linux/sparc/bits/sigcontext.h
+++ b/libc/sysdeps/linux/sparc/bits/sigcontext.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H
# error "Never use <bits/sigcontext.h> directly; include <signal.h> instead."
@@ -22,8 +21,6 @@
#include <bits/wordsize.h>
-#if __WORDSIZE == 32
-
/* It is quite hard to choose what to put here, because
Linux/sparc32 had at least 3 totally incompatible
signal stack layouts.
@@ -43,36 +40,3 @@ struct sigcontext
int si_mask;
};
-#else /* sparc64 */
-
-typedef struct
- {
- unsigned int si_float_regs [64];
- unsigned long si_fsr;
- unsigned long si_gsr;
- unsigned long si_fprs;
- } __siginfo_fpu_t;
-
-struct sigcontext
- {
- char sigc_info[128];
- struct
- {
- unsigned long u_regs[16]; /* globals and ins */
- unsigned long tstate;
- unsigned long tpc;
- unsigned long tnpc;
- unsigned int y;
- unsigned int fprs;
- } sigc_regs;
- __siginfo_fpu_t * sigc_fpu_save;
- struct
- {
- void * ss_sp;
- int ss_flags;
- unsigned long ss_size;
- } sigc_stack;
- unsigned long sigc_mask;
-};
-
-#endif /* sparc64 */
diff --git a/libc/sysdeps/linux/sparc/bits/sigcontextinfo.h b/libc/sysdeps/linux/sparc/bits/sigcontextinfo.h
index 2c2770d07..103e3c377 100644
--- a/libc/sysdeps/linux/sparc/bits/sigcontextinfo.h
+++ b/libc/sysdeps/linux/sparc/bits/sigcontextinfo.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#define SIGCONTEXT struct sigcontext *
#define SIGCONTEXT_EXTRA_ARGS
diff --git a/libc/sysdeps/linux/sparc/bits/siginfo.h b/libc/sysdeps/linux/sparc/bits/siginfo.h
index 7ff1971c2..da1c83884 100644
--- a/libc/sysdeps/linux/sparc/bits/siginfo.h
+++ b/libc/sysdeps/linux/sparc/bits/siginfo.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#if !defined _SIGNAL_H && !defined __need_siginfo_t \
&& !defined __need_sigevent_t
@@ -105,6 +104,14 @@ typedef struct siginfo
int si_band; /* Band event for SIGPOLL. */
int si_fd;
} _sigpoll;
+
+ /* SIGSYS. */
+ struct
+ {
+ void *_call_addr; /* Calling user insn. */
+ int _syscall; /* Triggering system call number. */
+ unsigned int _arch; /* AUDIT_ARCH_* of syscall. */
+ } _sigsys;
} _sifields;
} siginfo_t;
@@ -124,6 +131,9 @@ typedef struct siginfo
# define si_trapno _sifields._sigfault.si_trapno
# define si_band _sifields._sigpoll.si_band
# define si_fd _sifields._sigpoll.si_fd
+# define si_call_addr _sifields._sigsys._call_addr
+# define si_syscall _sifields._sigsys._syscall
+# define si_arch _sifields._sigsys._arch
/* Values for `si_code'. Positive values are reserved for kernel-generated
@@ -289,6 +299,10 @@ typedef struct sigevent
{
int _pad[__SIGEV_PAD_SIZE];
+ /* When SIGEV_SIGNAL and SIGEV_THREAD_ID set, LWP ID of the
+ thread to receive the signal. */
+ __pid_t _tid;
+
struct
{
void (*_function) (sigval_t); /* Function to start. */
diff --git a/libc/sysdeps/linux/sparc/bits/signalfd.h b/libc/sysdeps/linux/sparc/bits/signalfd.h
new file mode 100644
index 000000000..1271e3409
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/bits/signalfd.h
@@ -0,0 +1,29 @@
+/* Copyright (C) 2007-2012 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_SIGNALFD_H
+# error "Never use <bits/signalfd.h> directly; include <sys/signalfd.h> instead."
+#endif
+
+/* Flags for signalfd. */
+enum
+ {
+ SFD_CLOEXEC = 0x400000,
+#define SFD_CLOEXEC SFD_CLOEXEC
+ SFD_NONBLOCK = 0x004000
+#define SFD_NONBLOCK SFD_NONBLOCK
+ };
diff --git a/libc/sysdeps/linux/sparc/bits/signum.h b/libc/sysdeps/linux/sparc/bits/signum.h
index 6b58ec29d..08b9e2cbb 100644
--- a/libc/sysdeps/linux/sparc/bits/signum.h
+++ b/libc/sysdeps/linux/sparc/bits/signum.h
@@ -13,21 +13,11 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifdef _SIGNAL_H
-/* Fake signal functions. */
-#define SIG_ERR ((__sighandler_t) -1) /* Error return. */
-#define SIG_DFL ((__sighandler_t) 0) /* Default action. */
-#define SIG_IGN ((__sighandler_t) 1) /* Ignore signal. */
-
-#ifdef __USE_UNIX98
-# define SIG_HOLD ((__sighandler_t) 2) /* Add signal to hold mask. */
-#endif
-
/*
* Linux/SPARC has different signal numbers that Linux/i386: I'm trying
* to make it OSF/1 binary compatible, at least for normal binaries.
@@ -70,15 +60,4 @@
#define SIGUSR1 30
#define SIGUSR2 31
-#define _NSIG 65 /* Biggest signal number + 1
- (including real-time signals). */
-
-#define SIGRTMIN (__libc_current_sigrtmin ())
-#define SIGRTMAX (__libc_current_sigrtmax ())
-
-/* These are the hard limits of the kernel. These values should not be
- used directly at user level. */
-#define __SIGRTMIN 32
-#define __SIGRTMAX (_NSIG - 1)
-
#endif /* <signal.h> included. */
diff --git a/libc/sysdeps/linux/sparc/bits/sigstack.h b/libc/sysdeps/linux/sparc/bits/sigstack.h
index df4653949..f39f9d95e 100644
--- a/libc/sysdeps/linux/sparc/bits/sigstack.h
+++ b/libc/sysdeps/linux/sparc/bits/sigstack.h
@@ -13,21 +13,22 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SIGNAL_H
# error "Never include this file directly. Use <signal.h> instead"
#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_type.h b/libc/sysdeps/linux/sparc/bits/socket_type.h
new file mode 100644
index 000000000..494655f10
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/bits/socket_type.h
@@ -0,0 +1,54 @@
+/* System-specific socket constants and types. Linux version.
+ Copyright (C) 1991,1992,1994-2001,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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_SOCKET_H
+# error "Never include <bits/socket_type.h> directly; use <sys/socket.h> instead."
+#endif
+
+/* Types of sockets. */
+enum __socket_type
+{
+ SOCK_STREAM = 1, /* Sequenced, reliable, connection-based
+ byte streams. */
+#define SOCK_STREAM SOCK_STREAM
+ SOCK_DGRAM = 2, /* Connectionless, unreliable datagrams
+ of fixed maximum length. */
+#define SOCK_DGRAM SOCK_DGRAM
+ SOCK_RAW = 3, /* Raw protocol interface. */
+#define SOCK_RAW SOCK_RAW
+ SOCK_RDM = 4, /* Reliably-delivered messages. */
+#define SOCK_RDM SOCK_RDM
+ SOCK_SEQPACKET = 5, /* Sequenced, reliable, connection-based,
+ datagrams of fixed maximum length. */
+#define SOCK_SEQPACKET SOCK_SEQPACKET
+ SOCK_DCCP = 6, /* Datagram Congestion Control Protocol. */
+#define SOCK_DCCP SOCK_DCCP
+ SOCK_PACKET = 10, /* Linux specific way of getting packets
+ at the dev level. For writing rarp and
+ other similar things on the user level. */
+#define SOCK_PACKET SOCK_PACKET
+
+ /* Flags to be ORed into the type parameter of socket and socketpair. */
+
+ SOCK_CLOEXEC = 0x400000, /* Atomically set close-on-exec flag for the
+ new descriptor(s). */
+#define SOCK_CLOEXEC SOCK_CLOEXEC
+ SOCK_NONBLOCK = 0x004000 /* Atomically mark descriptor(s) as
+ non-blocking. */
+#define SOCK_NONBLOCK SOCK_NONBLOCK
+};
diff --git a/libc/sysdeps/linux/sparc/bits/stackinfo.h b/libc/sysdeps/linux/sparc/bits/stackinfo.h
index fd34e2deb..035545683 100644
--- a/libc/sysdeps/linux/sparc/bits/stackinfo.h
+++ b/libc/sysdeps/linux/sparc/bits/stackinfo.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* This file contains a bit of information about the stack allocation
of the processor. */
diff --git a/libc/sysdeps/linux/sparc/bits/stat.h b/libc/sysdeps/linux/sparc/bits/stat.h
index 8dcfacd66..ae11d79a4 100644
--- a/libc/sysdeps/linux/sparc/bits/stat.h
+++ b/libc/sysdeps/linux/sparc/bits/stat.h
@@ -1,5 +1,4 @@
-/* Copyright (C) 1992, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2006
- Free Software Foundation, Inc.
+/* Copyright (C) 1992, 1995-2002, 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
@@ -13,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_STAT_H
# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
@@ -61,7 +59,7 @@ struct stat
#else
__blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
#endif
-#if 0 /*def __USE_MISC*/
+#ifdef __USE_MISC
/* Nanosecond resolution timestamps are stored in a format
equivalent to 'struct timespec'. This is the type used
whenever possible but the Unix namespace rules do not allow the
@@ -104,7 +102,7 @@ struct stat64
__blksize_t st_blksize; /* Optimal block size for I/O. */
__blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
-#if 0 /*def __USE_MISC*/
+#ifdef __USE_MISC
/* Nanosecond resolution timestamps are stored in a format
equivalent to 'struct timespec'. This is the type used
whenever possible but the Unix namespace rules do not allow the
@@ -163,3 +161,8 @@ struct stat64
#define __S_IREAD 0400 /* Read by owner. */
#define __S_IWRITE 0200 /* Write by owner. */
#define __S_IEXEC 0100 /* Execute by owner. */
+
+#ifdef __USE_ATFILE
+# define UTIME_NOW ((1l << 30) - 1l)
+# define UTIME_OMIT ((1l << 30) - 2l)
+#endif
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/bits/syscalls.h b/libc/sysdeps/linux/sparc/bits/syscalls.h
index fdaa4dee1..948c2fa3e 100644
--- a/libc/sysdeps/linux/sparc/bits/syscalls.h
+++ b/libc/sysdeps/linux/sparc/bits/syscalls.h
@@ -8,11 +8,6 @@
#ifndef __ASSEMBLER__
-#include <errno.h>
-
-#define SYS_ify(syscall_name) (__NR_##syscall_name)
-
-#undef __SYSCALL_STRING
#if __WORDSIZE == 32
# define __SYSCALL_STRING \
"t 0x10\n\t" \
@@ -20,136 +15,105 @@
"mov %%o0, %0\n\t" \
"sub %%g0, %%o0, %0\n\t" \
"1:\n\t"
-# define __SYSCALL_RES_CHECK (__res < -255 || __res >= 0)
#elif __WORDSIZE == 64
# define __SYSCALL_STRING \
"t 0x6d\n\t" \
"sub %%g0, %%o0, %0\n\t" \
"movcc %%xcc, %%o0, %0\n\t"
-# define __SYSCALL_RES_CHECK (__res >= 0)
#else
# error unknown __WORDSIZE
#endif
-#define __SYSCALL_RETURN(type) \
- if (__SYSCALL_RES_CHECK) \
- return (type) __res; \
- __set_errno (-__res); \
- return (type) -1;
+#define __SYSCALL_CLOBBERS "cc", "memory"
-#undef _syscall0
-#define _syscall0(type,name) \
-type name(void) \
-{ \
-long __res; \
-register long __g1 __asm__ ("g1") = __NR_##name; \
-__asm__ __volatile__ (__SYSCALL_STRING \
- : "=r" (__res)\
- : "r" (__g1) \
- : "o0", "cc"); \
-__SYSCALL_RETURN(type) \
+#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 _syscall1
-#define _syscall1(type,name,type1,arg1) \
-type name(type1 arg1) \
-{ \
-long __res; \
-register long __g1 __asm__ ("g1") = __NR_##name; \
-register long __o0 __asm__ ("o0") = (long)(arg1); \
-__asm__ __volatile__ (__SYSCALL_STRING \
- : "=r" (__res), "=&r" (__o0) \
- : "1" (__o0), "r" (__g1) \
- : "cc"); \
-__SYSCALL_RETURN(type) \
-}
+#define INTERNAL_SYSCALL_NCS(sys_num, err, nr, args...) \
+(__extension__ \
+ ({ \
+ unsigned int __res; \
+ { \
+ register long __o0 __asm__("o0"); \
+ register long __g1 __asm__("g1") = sys_num; \
+ LOAD_ARGS_##nr(args) \
+ __asm__ __volatile__( __SYSCALL_STRING \
+ : "=r" (__res), "=&r" (__o0) \
+ : "1" (__o0) ASM_ARGS_##nr, "r" (__g1) \
+ : __SYSCALL_CLOBBERS ); \
+ } \
+ (int)__res; \
+ }) \
+)
+#define INTERNAL_SYSCALL_ERROR_P(val, err) \
+ ((unsigned int) (val) >= 0xfffff001u)
-#undef _syscall2
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name(type1 arg1,type2 arg2) \
-{ \
-long __res; \
-register long __g1 __asm__ ("g1") = __NR_##name; \
-register long __o0 __asm__ ("o0") = (long)(arg1); \
-register long __o1 __asm__ ("o1") = (long)(arg2); \
-__asm__ __volatile__ (__SYSCALL_STRING \
- : "=r" (__res), "=&r" (__o0) \
- : "1" (__o0), "r" (__o1), "r" (__g1) \
- : "cc"); \
-__SYSCALL_RETURN(type) \
-}
+# define CALL_ERRNO_LOCATION "call __errno_location;"
+#define __CLONE_SYSCALL_STRING \
+ "ta 0x10;" \
+ "bcs 2f;" \
+ " sub %%o1, 1, %%o1;" \
+ "and %%o0, %%o1, %%o0;" \
+ "1:" \
+ ".subsection 2;" \
+ "2:" \
+ "save %%sp, -192, %%sp;" \
+ CALL_ERRNO_LOCATION \
+ " nop;" \
+ "st %%i0, [%%o0];" \
+ "ba 1b;" \
+ " restore %%g0, -1, %%o0;" \
+ ".previous;"
-#undef _syscall3
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name(type1 arg1,type2 arg2,type3 arg3) \
-{ \
-long __res; \
-register long __g1 __asm__ ("g1") = __NR_##name; \
-register long __o0 __asm__ ("o0") = (long)(arg1); \
-register long __o1 __asm__ ("o1") = (long)(arg2); \
-register long __o2 __asm__ ("o2") = (long)(arg3); \
-__asm__ __volatile__ (__SYSCALL_STRING \
- : "=r" (__res), "=&r" (__o0) \
- : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__g1) \
- : "cc"); \
-__SYSCALL_RETURN(type) \
-}
+#define INLINE_CLONE_SYSCALL(arg1,arg2,arg3,arg4,arg5) \
+({ \
+ register long __o0 __asm__ ("o0") = (long)(arg1); \
+ register long __o1 __asm__ ("o1") = (long)(arg2); \
+ register long __o2 __asm__ ("o2") = (long)(arg3); \
+ register long __o3 __asm__ ("o3") = (long)(arg4); \
+ register long __o4 __asm__ ("o4") = (long)(arg5); \
+ register long __g1 __asm__ ("g1") = __NR_clone; \
+ __asm__ __volatile__ (__CLONE_SYSCALL_STRING : \
+ "=r" (__g1), "=r" (__o0), "=r" (__o1) : \
+ "0" (__g1), "1" (__o0), "2" (__o1), \
+ "r" (__o2), "r" (__o3), "r" (__o4) : \
+ __SYSCALL_CLOBBERS); \
+ __o0; \
+})
-#undef _syscall4
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
-{ \
-long __res; \
-register long __g1 __asm__ ("g1") = __NR_##name; \
-register long __o0 __asm__ ("o0") = (long)(arg1); \
-register long __o1 __asm__ ("o1") = (long)(arg2); \
-register long __o2 __asm__ ("o2") = (long)(arg3); \
-register long __o3 __asm__ ("o3") = (long)(arg4); \
-__asm__ __volatile__ (__SYSCALL_STRING \
- : "=r" (__res), "=&r" (__o0) \
- : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__g1) \
- : "cc"); \
-__SYSCALL_RETURN(type) \
-}
+#define LOAD_ARGS_0()
+#define ASM_ARGS_0
+#define LOAD_ARGS_1(o0) \
+ __o0 = (int)o0; \
+ LOAD_ARGS_0()
+#define ASM_ARGS_1 ASM_ARGS_0, "r" (__o0)
+#define LOAD_ARGS_2(o0, o1) \
+ register int __o1 __asm__ ("o1") = (int) (o1); \
+ LOAD_ARGS_1 (o0)
+#define ASM_ARGS_2 ASM_ARGS_1, "r" (__o1)
+#define LOAD_ARGS_3(o0, o1, o2) \
+ register int __o2 __asm__ ("o2") = (int) (o2); \
+ LOAD_ARGS_2 (o0, o1)
+#define ASM_ARGS_3 ASM_ARGS_2, "r" (__o2)
+#define LOAD_ARGS_4(o0, o1, o2, o3) \
+ register int __o3 __asm__ ("o3") = (int) (o3); \
+ LOAD_ARGS_3 (o0, o1, o2)
+#define ASM_ARGS_4 ASM_ARGS_3, "r" (__o3)
+#define LOAD_ARGS_5(o0, o1, o2, o3, o4) \
+ register int __o4 __asm__ ("o4") = (int) (o4); \
+ LOAD_ARGS_4 (o0, o1, o2, o3)
+#define ASM_ARGS_5 ASM_ARGS_4, "r" (__o4)
+#define LOAD_ARGS_6(o0, o1, o2, o3, o4, o5) \
+ register int __o5 __asm__ ("o5") = (int) (o5); \
+ LOAD_ARGS_5 (o0, o1, o2, o3, o4)
+#define ASM_ARGS_6 ASM_ARGS_5, "r" (__o5)
-#undef _syscall5
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
- type5,arg5) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
-{ \
-long __res; \
-register long __g1 __asm__ ("g1") = __NR_##name; \
-register long __o0 __asm__ ("o0") = (long)(arg1); \
-register long __o1 __asm__ ("o1") = (long)(arg2); \
-register long __o2 __asm__ ("o2") = (long)(arg3); \
-register long __o3 __asm__ ("o3") = (long)(arg4); \
-register long __o4 __asm__ ("o4") = (long)(arg5); \
-__asm__ __volatile__ (__SYSCALL_STRING \
- : "=r" (__res), "=&r" (__o0) \
- : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__o4), "r" (__g1) \
- : "cc"); \
-__SYSCALL_RETURN(type) \
-}
-
-#undef _syscall6
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
- type5,arg5,type6,arg6) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, type6 arg6) \
-{ \
-long __res; \
-register long __g1 __asm__ ("g1") = __NR_##name; \
-register long __o0 __asm__ ("o0") = (long)(arg1); \
-register long __o1 __asm__ ("o1") = (long)(arg2); \
-register long __o2 __asm__ ("o2") = (long)(arg3); \
-register long __o3 __asm__ ("o3") = (long)(arg4); \
-register long __o4 __asm__ ("o4") = (long)(arg5); \
-register long __o5 __asm__ ("o5") = (long)(arg6); \
-__asm__ __volatile__ (__SYSCALL_STRING \
- : "=r" (__res), "=&r" (__o0) \
- : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__o4), "r" (__o5), "r" (__g1) \
- : "cc"); \
-__SYSCALL_RETURN(type) \
-}
#endif /* __ASSEMBLER__ */
#endif /* _BITS_SYSCALLS_H */
diff --git a/libc/sysdeps/linux/sparc/bits/termios.h b/libc/sysdeps/linux/sparc/bits/termios.h
index cea13227f..350601105 100644
--- a/libc/sysdeps/linux/sparc/bits/termios.h
+++ b/libc/sysdeps/linux/sparc/bits/termios.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _TERMIOS_H
# error "Never include <bits/termios.h> directly; use <termios.h> instead."
diff --git a/libc/sysdeps/linux/sparc/bits/timerfd.h b/libc/sysdeps/linux/sparc/bits/timerfd.h
new file mode 100644
index 000000000..492e50ca7
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/bits/timerfd.h
@@ -0,0 +1,29 @@
+/* Copyright (C) 2008-2012 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_TIMERFD_H
+# error "Never use <bits/timerfd.h> directly; include <sys/timerfd.h> instead."
+#endif
+
+/* Bits to be set in the FLAGS parameter of `timerfd_create'. */
+enum
+ {
+ TFD_CLOEXEC = 0x400000,
+#define TFD_CLOEXEC TFD_CLOEXEC
+ TFD_NONBLOCK = 0x004000
+#define TFD_NONBLOCK TFD_NONBLOCK
+ };
diff --git a/libc/sysdeps/linux/sparc/bits/typesizes.h b/libc/sysdeps/linux/sparc/bits/typesizes.h
index b0dd1bd89..37b7656aa 100644
--- a/libc/sysdeps/linux/sparc/bits/typesizes.h
+++ b/libc/sysdeps/linux/sparc/bits/typesizes.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _BITS_TYPES_H
# error "Never include <bits/typesizes.h> directly; use <sys/types.h> instead."
diff --git a/libc/sysdeps/linux/sparc/bits/uClibc_arch_features.h b/libc/sysdeps/linux/sparc/bits/uClibc_arch_features.h
index 41d3e7c3d..283a250bb 100644
--- a/libc/sysdeps/linux/sparc/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/sparc/bits/uClibc_arch_features.h
@@ -11,28 +11,31 @@
/* 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 align 64bit values in register pairs ? (32bit arches only) */
+#undef __UCLIBC_SYSCALL_ALIGN_64BIT__
/* 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 */
+#define __UCLIBC_HAVE_ASM_CFI_DIRECTIVES__
/* define if target supports IEEE signed zero floats */
#define __UCLIBC_HAVE_SIGNED_ZERO__
+/* only weird assemblers generally need this */
+#undef __UCLIBC_ASM_LINE_SEP__
+
#endif /* _BITS_UCLIBC_ARCH_FEATURES_H */
diff --git a/libc/sysdeps/linux/sparc/bits/wordsize.h b/libc/sysdeps/linux/sparc/bits/wordsize.h
index c0e600ed5..aa15dbc7a 100644
--- a/libc/sysdeps/linux/sparc/bits/wordsize.h
+++ b/libc/sysdeps/linux/sparc/bits/wordsize.h
@@ -2,6 +2,7 @@
#if defined __arch64__ || defined __sparcv9
# define __WORDSIZE 64
+# define __WORDSIZE_TIME64_COMPAT32 1
#else
# define __WORDSIZE 32
#endif
diff --git a/libc/sysdeps/linux/sparc/brk.c b/libc/sysdeps/linux/sparc/brk.c
index 53f2c9c1d..5221de336 100644
--- a/libc/sysdeps/linux/sparc/brk.c
+++ b/libc/sysdeps/linux/sparc/brk.c
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <errno.h>
#include <unistd.h>
@@ -25,7 +24,6 @@
/* This must be initialized data because commons can't have aliases. */
void *__curbrk attribute_hidden = 0;
-libc_hidden_proto(brk)
int brk (void *addr)
{
void *newbrk;
diff --git a/libc/sysdeps/linux/sparc/clone.S b/libc/sysdeps/linux/sparc/clone.S
index 0e41ee0cb..1d0e3e6e1 100644
--- a/libc/sysdeps/linux/sparc/clone.S
+++ b/libc/sysdeps/linux/sparc/clone.S
@@ -1,4 +1,5 @@
-/* Copyright (C) 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998, 2000, 2003, 2004, 2007
+ Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Richard Henderson (rth@tamu.edu).
@@ -13,54 +14,95 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* clone() is even more special than fork() as it mucks with stacks
and invokes a function in the right context after its all over. */
-#include <features.h>
+#include <asm/errno.h>
#include <asm/unistd.h>
+#ifdef RESET_PID
+#include <tcb-offsets.h>
+#endif
+#include <sysdep.h>
-/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */
+#define CLONE_VM 0x00000100
+#define CLONE_THREAD 0x00010000
-.text
-.global clone
-.type clone,%function
-.align 4
+/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg,
+ pid_t *ptid, void *tls, pid_t *ctid); */
-clone:
+ .text
+ENTRY (__clone)
save %sp,-96,%sp
+ cfi_def_cfa_register(%fp)
+ cfi_window_save
+ cfi_register(%o7, %i7)
/* sanity check arguments */
- tst %i0
- be __error
- orcc %i1,%g0,%o1
- be __error
- mov %i2,%o0
+ orcc %i0,%g0,%g2
+ be .Leinval
+ orcc %i1,%g0,%o1
+ be .Leinval
+ mov %i2,%o0
+
+ /* The child_stack is the top of the stack, allocate one
+ whole stack frame from that as this is what the kernel
+ expects. */
+ sub %o1, 96, %o1
+ mov %i3, %g3
+ mov %i2, %g4
+
+ /* ptid */
+ mov %i4,%o2
+ /* tls */
+ mov %i5,%o3
+ /* ctid */
+ ld [%fp+92],%o4
/* Do the system call */
set __NR_clone,%g1
ta 0x10
- bcs __error
- tst %o1
+ bcs .Lerror
+ tst %o1
bne __thread_start
- nop
- ret
- restore %o0,%g0,%o0
-
-__error:
- jmp __syscall_error
+ nop
+ jmpl %i7 + 8, %g0
+ restore %o0,%g0,%o0
-.size clone,.-clone
-
-.type __thread_start,%function
+.Leinval:
+ mov EINVAL, %o0
+.Lerror:
+ call __errno_location
+ mov %o0, %i0
+ st %i0,[%o0]
+ jmpl %i7 + 8, %g0
+ restore %g0,-1,%o0
+END(__clone)
+ .type __thread_start,@function
__thread_start:
- call %i0
- mov %i3,%o0
- call HIDDEN_JUMPTARGET(_exit),0
- nop
+#ifdef RESET_PID
+ sethi %hi(CLONE_THREAD), %l0
+ andcc %g4, %l0, %g0
+ bne 1f
+ andcc %g4, CLONE_VM, %g0
+ bne,a 2f
+ mov -1,%o0
+ set __NR_getpid,%g1
+ ta 0x10
+2:
+ st %o0,[%g7 + PID]
+ st %o0,[%g7 + TID]
+1:
+#endif
+ mov %g0, %fp /* terminate backtrace */
+ call %g2
+ mov %g3,%o0
+ call exit,0
+ nop
+
+ .size __thread_start, .-__thread_start
-.size __thread_start,.-__thread_start
+weak_alias (__clone, clone)
diff --git a/libc/sysdeps/linux/sparc/crt1.S b/libc/sysdeps/linux/sparc/crt1.S
index f33a714ef..77e9147f5 100644
--- a/libc/sysdeps/linux/sparc/crt1.S
+++ b/libc/sysdeps/linux/sparc/crt1.S
@@ -31,25 +31,17 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* Originally based on glibc's sysdeps/sparc/sparc{32,64}/elf/start.S */
#include <features.h>
#include <bits/wordsize.h>
-/* macro out the 32 / 64 bit differences */
-#if __WORDSIZE == 32
# define STACK_BIAS 0
# define ELE_SIZE 4
# define LD ld
-#else
-# define STACK_BIAS 2047 /* see glibc/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h */
-# define ELE_SIZE 8
-# define LD ldx
-#endif
.text
.align 4
@@ -117,11 +109,7 @@ _start:
nop
/* Die very horribly if exit returns. */
-#if __WORDSIZE == 32
unimp
-#else
- illtrap 0
-#endif
.size _start,.-_start
diff --git a/libc/sysdeps/linux/sparc/crtn.S b/libc/sysdeps/linux/sparc/crtn.S
index 24b4bf43c..d64ffd020 100644
--- a/libc/sysdeps/linux/sparc/crtn.S
+++ b/libc/sysdeps/linux/sparc/crtn.S
@@ -7,7 +7,6 @@
.proc 020
ret
restore
- .size _init, .-_init
.section .fini
.align 4
@@ -16,4 +15,3 @@
.proc 020
ret
restore
- .size _fini, .-_fini
diff --git a/libc/sysdeps/linux/sparc/fork.S b/libc/sysdeps/linux/sparc/fork.S
index 00157cffd..171591123 100644
--- a/libc/sysdeps/linux/sparc/fork.S
+++ b/libc/sysdeps/linux/sparc/fork.S
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* Code taken from glibc2.2.2/sysdeps/unix/sysv/linux/sparc/vfork.S */
@@ -23,11 +22,14 @@
#include <sys/syscall.h>
.text
-.global __libc_fork
-.type __libc_fork,%function
+.global fork
+#ifdef __UCLIBC_HAS_THREADS__
+.weak fork
+#endif
+.type fork,%function
.align 4
-__libc_fork:
+fork:
mov __NR_fork, %g1
ta 0x10
bcc,a 9000f
@@ -44,6 +46,8 @@ __libc_fork:
retl
and %o0, %o1, %o0
-.size __libc_fork,.-__libc_fork
-weak_alias(__libc_fork,fork)
-libc_hidden_weak(fork)
+.size fork,.-fork
+#ifdef __UCLIBC_HAS_THREADS__
+strong_alias(fork,__libc_fork)
+#endif
+libc_hidden_def(fork)
diff --git a/libc/sysdeps/linux/sparc/fpu_control.h b/libc/sysdeps/linux/sparc/fpu_control.h
index 41ab0a917..0a00044f9 100644
--- a/libc/sysdeps/linux/sparc/fpu_control.h
+++ b/libc/sysdeps/linux/sparc/fpu_control.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FPU_CONTROL_H
#define _FPU_CONTROL_H 1
diff --git a/libc/sysdeps/linux/sparc/jmpbuf-offsets.h b/libc/sysdeps/linux/sparc/jmpbuf-offsets.h
new file mode 100644
index 000000000..0d0a96d30
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/jmpbuf-offsets.h
@@ -0,0 +1,29 @@
+/* Private macros for accessing __jmp_buf contents. SPARC version.
+ Copyright (C) 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <bits/wordsize.h>
+
+#if __WORDSIZE == 64
+#define O_mask_was_saved 512
+#define O_gregs 32
+#define O_g1 (O_gregs + 4*8)
+#else
+#define JB_SP 0
+#define JB_FP 1
+#define JB_PC 2
+#endif
diff --git a/libc/sysdeps/linux/sparc/jmpbuf-unwind.h b/libc/sysdeps/linux/sparc/jmpbuf-unwind.h
new file mode 100644
index 000000000..90efb7719
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/jmpbuf-unwind.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+#include <setjmp.h>
+#include <jmpbuf-offsets.h>
+
+/* Test if longjmp to JMPBUF would unwind the frame
+ containing a local variable at ADDRESS. */
+#define _JMPBUF_UNWINDS(jmpbuf, address) \
+ ((int) (address) < (jmpbuf)[JB_SP])
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <setjmp.h>
+#include <stdint.h>
+#include <unwind.h>
+
+#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
+ _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
+
+#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
+ ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[JB_SP] - (_adj))
+#endif
diff --git a/libc/sysdeps/linux/sparc/pipe.S b/libc/sysdeps/linux/sparc/pipe.S
new file mode 100644
index 000000000..fa77f4d23
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/pipe.S
@@ -0,0 +1,59 @@
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jj@ultra.linux.cz>, 1999.
+
+ 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, see
+ <http://www.gnu.org/licenses/>.
+
+ Ported to uClibc by:
+ Austin Foxley, Ceton Corporation <austinf@cetoncorp.com>
+ */
+
+#include <features.h>
+#include <sys/syscall.h>
+#include <asm/errno.h>
+
+.text
+.global pipe
+.type pipe, @function
+.align 4
+
+pipe:
+ save %sp,-96,%sp
+
+ /* sanity check arguments */
+ tst %i0
+ be .Lerror
+ mov %i2,%o0
+
+ /* Do the system call */
+ set __NR_pipe,%g1
+ ta 0x10
+ bcs .Lerror
+ nop
+
+ st %o0,[%i0]
+ st %o1,[%i0+4]
+ ret
+ restore %g0,%g0,%o0
+
+.Lerror:
+ call __errno_location
+ or %g0,EINVAL,%i0
+ st %i0,[%o0]
+ ret
+ restore %g0,-1,%o0
+
+.size pipe,.-pipe
+libc_hidden_def(pipe)
diff --git a/libc/sysdeps/linux/sparc/qp_ops.c b/libc/sysdeps/linux/sparc/qp_ops.c
index 9080baaee..97f98da99 100644
--- a/libc/sysdeps/linux/sparc/qp_ops.c
+++ b/libc/sysdeps/linux/sparc/qp_ops.c
@@ -1,46 +1,39 @@
-// XXX add ops from glibc sysdeps/sparc/sparc64/soft-fp
+#include <stdio.h>
+#include <stdlib.h>
-#define fakedef(name) \
- void name(void) \
- { \
- printf("Unimplemented %s called, exiting\n", #name); \
- exit(-1); \
- }
+static void fakedef(void)
+{
+ fputs("Unimplemented _Q* func called, exiting\n", stderr);
+ exit(-1);
+}
-#ifdef __sparc_v9__
-fakedef(_Qp_fne)
-fakedef(_Qp_feq)
-fakedef(_Qp_div)
-fakedef(_Qp_flt)
-fakedef(_Qp_mul)
-fakedef(_Qp_fge)
-fakedef(_Qp_qtoux)
-fakedef(_Qp_uxtoq)
-fakedef(_Qp_sub)
-fakedef(_Qp_dtoq)
-fakedef(_Qp_qtod)
-fakedef(_Qp_qtos)
-fakedef(_Qp_stoq)
-fakedef(_Qp_itoq)
-fakedef(_Qp_add)
-#else
-fakedef(_Q_fne)
-fakedef(_Q_feq)
-fakedef(_Q_div)
-fakedef(_Q_flt)
-fakedef(_Q_mul)
-fakedef(_Q_fge)
-fakedef(_Q_qtoux)
-fakedef(_Q_uxtoq)
-fakedef(_Q_qtou)
-fakedef(_Q_utoq)
-fakedef(_Q_sub)
-fakedef(_Q_dtoq)
-fakedef(_Q_qtod)
-fakedef(_Q_qtos)
-fakedef(_Q_stoq)
-fakedef(_Q_itoq)
-fakedef(_Q_add)
-#endif
+# define fakedef(sym) strong_alias(fakedef, _Q_##sym)
-#undef fakedef
+fakedef(fne)
+fakedef(feq)
+fakedef(div)
+fakedef(flt)
+fakedef(fgt)
+fakedef(mul)
+fakedef(fge)
+fakedef(qtoux)
+fakedef(uxtoq)
+fakedef(sub)
+fakedef(dtoq)
+fakedef(qtod)
+fakedef(qtos)
+fakedef(stoq)
+fakedef(itoq)
+fakedef(add)
+fakedef(qtou)
+fakedef(utoq)
+fakedef(cmp)
+fakedef(cmpe)
+fakedef(fle)
+fakedef(lltoq)
+fakedef(neg)
+fakedef(qtoi)
+fakedef(qtoll)
+fakedef(qtoull)
+fakedef(sqrt)
+fakedef(ulltoq)
diff --git a/libc/sysdeps/linux/sparc/setjmp.S b/libc/sysdeps/linux/sparc/setjmp.S
index 796abc763..aa53b29f2 100644
--- a/libc/sysdeps/linux/sparc/setjmp.S
+++ b/libc/sysdeps/linux/sparc/setjmp.S
@@ -12,15 +12,11 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
-#include <sys/syscall.h>
+#include <jmpbuf-offsets.h>
-#define _ASM 1
-#define _SETJMP_H
-#include <bits/setjmp.h>
#define ST_FLUSH_WINDOWS 3
.global _setjmp
diff --git a/libc/sysdeps/linux/sparc/sigaction.c b/libc/sysdeps/linux/sparc/sigaction.c
new file mode 100644
index 000000000..7895e3acd
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/sigaction.c
@@ -0,0 +1,98 @@
+/* POSIX.1 sigaction call for Linux/SPARC.
+ Copyright (C) 1997-2000,2002,2003,2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Miguel de Icaza (miguel@nuclecu.unam.mx), 1997.
+
+ 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, see
+ <http://www.gnu.org/licenses/>.
+
+ Ported to uClibc from glibc: 090520:
+ Jan Buchholz, KIP, Uni Heidelberg <jan.buchholz@kip.uni-heidelberg.de>
+ Austin Foxley, Ceton Corporation <austinf@cetoncorp.com>
+*/
+
+#include <errno.h>
+#include <signal.h>
+#include <string.h>
+#include <sys/syscall.h>
+#include <bits/kernel_sigaction.h>
+
+
+_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);
+
+int __libc_sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
+{
+ int ret;
+ struct sigaction kact, koact;
+ unsigned long stub = 0;
+
+ if (act) {
+ kact.sa_handler = act->sa_handler;
+ memcpy (&kact.sa_mask, &act->sa_mask, sizeof (sigset_t));
+ if (((kact.sa_flags = act->sa_flags) & SA_SIGINFO) != 0)
+ stub = (unsigned long) &__rt_sigreturn_stub;
+ else
+ stub = (unsigned long) &__sigreturn_stub;
+ stub -= 8;
+ kact.sa_restorer = NULL;
+ }
+
+ /* XXX The size argument hopefully will have to be changed to the
+ * real size of the user-level sigset_t. */
+ ret = INLINE_SYSCALL (rt_sigaction, 5, sig, act ? &kact : 0,
+ oact ? &koact : 0, stub, _NSIG / 8);
+
+ if (oact && ret >= 0) {
+ oact->sa_handler = koact.sa_handler;
+ memcpy (&oact->sa_mask, &koact.sa_mask, sizeof (sigset_t));
+ oact->sa_flags = koact.sa_flags;
+ oact->sa_restorer = koact.sa_restorer;
+ }
+ return ret;
+}
+
+
+#ifndef LIBC_SIGACTION
+# ifndef __UCLIBC_HAS_THREADS__
+strong_alias(__libc_sigaction,sigaction)
+libc_hidden_def(sigaction)
+# else
+weak_alias(__libc_sigaction,sigaction)
+libc_hidden_weak(sigaction)
+# endif
+#endif
+
+
+static void
+__rt_sigreturn_stub(void)
+{
+ __asm__(
+ "mov %0, %%g1\n\t"
+ "ta 0x10\n\t"
+ : /* no outputs */
+ : "i" (__NR_rt_sigreturn)
+ );
+}
+static void
+__sigreturn_stub(void)
+{
+ __asm__(
+ "mov %0, %%g1\n\t"
+ "ta 0x10\n\t"
+ : /* no outputs */
+ : "i" (__NR_sigreturn)
+ );
+}
diff --git a/libc/sysdeps/linux/sparc/soft-fp/double.h b/libc/sysdeps/linux/sparc/soft-fp/double.h
new file mode 100644
index 000000000..9a1f78492
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/double.h
@@ -0,0 +1,263 @@
+/* Software floating-point emulation.
+ Definitions for IEEE Double Precision
+ Copyright (C) 1997,1998,1999,2006,2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com),
+ Jakub Jelinek (jj@ultra.linux.cz),
+ David S. Miller (davem@redhat.com) and
+ Peter Maydell (pmaydell@chiark.greenend.org.uk).
+
+ 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 into
+ combinations with other programs, and to distribute those
+ combinations without any restriction coming from the use of this
+ file. (The Lesser General Public License restrictions do apply in
+ other respects; for example, they cover modification of the file,
+ and distribution when not linked into a combine executable.)
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#if _FP_W_TYPE_SIZE < 32
+#error "Here's a nickel kid. Go buy yourself a real computer."
+#endif
+
+#if _FP_W_TYPE_SIZE < 64
+#define _FP_FRACTBITS_D (2 * _FP_W_TYPE_SIZE)
+#else
+#define _FP_FRACTBITS_D _FP_W_TYPE_SIZE
+#endif
+
+#define _FP_FRACBITS_D 53
+#define _FP_FRACXBITS_D (_FP_FRACTBITS_D - _FP_FRACBITS_D)
+#define _FP_WFRACBITS_D (_FP_WORKBITS + _FP_FRACBITS_D)
+#define _FP_WFRACXBITS_D (_FP_FRACTBITS_D - _FP_WFRACBITS_D)
+#define _FP_EXPBITS_D 11
+#define _FP_EXPBIAS_D 1023
+#define _FP_EXPMAX_D 2047
+
+#define _FP_QNANBIT_D \
+ ((_FP_W_TYPE)1 << (_FP_FRACBITS_D-2) % _FP_W_TYPE_SIZE)
+#define _FP_QNANBIT_SH_D \
+ ((_FP_W_TYPE)1 << (_FP_FRACBITS_D-2+_FP_WORKBITS) % _FP_W_TYPE_SIZE)
+#define _FP_IMPLBIT_D \
+ ((_FP_W_TYPE)1 << (_FP_FRACBITS_D-1) % _FP_W_TYPE_SIZE)
+#define _FP_IMPLBIT_SH_D \
+ ((_FP_W_TYPE)1 << (_FP_FRACBITS_D-1+_FP_WORKBITS) % _FP_W_TYPE_SIZE)
+#define _FP_OVERFLOW_D \
+ ((_FP_W_TYPE)1 << _FP_WFRACBITS_D % _FP_W_TYPE_SIZE)
+
+typedef float DFtype __attribute__((mode(DF)));
+
+#if _FP_W_TYPE_SIZE < 64
+
+union _FP_UNION_D
+{
+ DFtype flt;
+ struct {
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned sign : 1;
+ unsigned exp : _FP_EXPBITS_D;
+ unsigned frac1 : _FP_FRACBITS_D - (_FP_IMPLBIT_D != 0) - _FP_W_TYPE_SIZE;
+ unsigned frac0 : _FP_W_TYPE_SIZE;
+#else
+ unsigned frac0 : _FP_W_TYPE_SIZE;
+ unsigned frac1 : _FP_FRACBITS_D - (_FP_IMPLBIT_D != 0) - _FP_W_TYPE_SIZE;
+ unsigned exp : _FP_EXPBITS_D;
+ unsigned sign : 1;
+#endif
+ } bits __attribute__((packed));
+};
+
+#define FP_DECL_D(X) _FP_DECL(2,X)
+#define FP_UNPACK_RAW_D(X,val) _FP_UNPACK_RAW_2(D,X,val)
+#define FP_UNPACK_RAW_DP(X,val) _FP_UNPACK_RAW_2_P(D,X,val)
+#define FP_PACK_RAW_D(val,X) _FP_PACK_RAW_2(D,val,X)
+#define FP_PACK_RAW_DP(val,X) \
+ do { \
+ if (!FP_INHIBIT_RESULTS) \
+ _FP_PACK_RAW_2_P(D,val,X); \
+ } while (0)
+
+#define FP_UNPACK_D(X,val) \
+ do { \
+ _FP_UNPACK_RAW_2(D,X,val); \
+ _FP_UNPACK_CANONICAL(D,2,X); \
+ } while (0)
+
+#define FP_UNPACK_DP(X,val) \
+ do { \
+ _FP_UNPACK_RAW_2_P(D,X,val); \
+ _FP_UNPACK_CANONICAL(D,2,X); \
+ } while (0)
+
+#define FP_UNPACK_SEMIRAW_D(X,val) \
+ do { \
+ _FP_UNPACK_RAW_2(D,X,val); \
+ _FP_UNPACK_SEMIRAW(D,2,X); \
+ } while (0)
+
+#define FP_UNPACK_SEMIRAW_DP(X,val) \
+ do { \
+ _FP_UNPACK_RAW_2_P(D,X,val); \
+ _FP_UNPACK_SEMIRAW(D,2,X); \
+ } while (0)
+
+#define FP_PACK_D(val,X) \
+ do { \
+ _FP_PACK_CANONICAL(D,2,X); \
+ _FP_PACK_RAW_2(D,val,X); \
+ } while (0)
+
+#define FP_PACK_DP(val,X) \
+ do { \
+ _FP_PACK_CANONICAL(D,2,X); \
+ if (!FP_INHIBIT_RESULTS) \
+ _FP_PACK_RAW_2_P(D,val,X); \
+ } while (0)
+
+#define FP_PACK_SEMIRAW_D(val,X) \
+ do { \
+ _FP_PACK_SEMIRAW(D,2,X); \
+ _FP_PACK_RAW_2(D,val,X); \
+ } while (0)
+
+#define FP_PACK_SEMIRAW_DP(val,X) \
+ do { \
+ _FP_PACK_SEMIRAW(D,2,X); \
+ if (!FP_INHIBIT_RESULTS) \
+ _FP_PACK_RAW_2_P(D,val,X); \
+ } while (0)
+
+#define FP_ISSIGNAN_D(X) _FP_ISSIGNAN(D,2,X)
+#define FP_NEG_D(R,X) _FP_NEG(D,2,R,X)
+#define FP_ADD_D(R,X,Y) _FP_ADD(D,2,R,X,Y)
+#define FP_SUB_D(R,X,Y) _FP_SUB(D,2,R,X,Y)
+#define FP_MUL_D(R,X,Y) _FP_MUL(D,2,R,X,Y)
+#define FP_DIV_D(R,X,Y) _FP_DIV(D,2,R,X,Y)
+#define FP_SQRT_D(R,X) _FP_SQRT(D,2,R,X)
+#define _FP_SQRT_MEAT_D(R,S,T,X,Q) _FP_SQRT_MEAT_2(R,S,T,X,Q)
+
+#define FP_CMP_D(r,X,Y,un) _FP_CMP(D,2,r,X,Y,un)
+#define FP_CMP_EQ_D(r,X,Y) _FP_CMP_EQ(D,2,r,X,Y)
+#define FP_CMP_UNORD_D(r,X,Y) _FP_CMP_UNORD(D,2,r,X,Y)
+
+#define FP_TO_INT_D(r,X,rsz,rsg) _FP_TO_INT(D,2,r,X,rsz,rsg)
+#define FP_FROM_INT_D(X,r,rs,rt) _FP_FROM_INT(D,2,X,r,rs,rt)
+
+#define _FP_FRAC_HIGH_D(X) _FP_FRAC_HIGH_2(X)
+#define _FP_FRAC_HIGH_RAW_D(X) _FP_FRAC_HIGH_2(X)
+
+#else
+
+union _FP_UNION_D
+{
+ DFtype flt;
+ struct {
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned sign : 1;
+ unsigned exp : _FP_EXPBITS_D;
+ _FP_W_TYPE frac : _FP_FRACBITS_D - (_FP_IMPLBIT_D != 0);
+#else
+ _FP_W_TYPE frac : _FP_FRACBITS_D - (_FP_IMPLBIT_D != 0);
+ unsigned exp : _FP_EXPBITS_D;
+ unsigned sign : 1;
+#endif
+ } bits __attribute__((packed));
+};
+
+#define FP_DECL_D(X) _FP_DECL(1,X)
+#define FP_UNPACK_RAW_D(X,val) _FP_UNPACK_RAW_1(D,X,val)
+#define FP_UNPACK_RAW_DP(X,val) _FP_UNPACK_RAW_1_P(D,X,val)
+#define FP_PACK_RAW_D(val,X) _FP_PACK_RAW_1(D,val,X)
+#define FP_PACK_RAW_DP(val,X) \
+ do { \
+ if (!FP_INHIBIT_RESULTS) \
+ _FP_PACK_RAW_1_P(D,val,X); \
+ } while (0)
+
+#define FP_UNPACK_D(X,val) \
+ do { \
+ _FP_UNPACK_RAW_1(D,X,val); \
+ _FP_UNPACK_CANONICAL(D,1,X); \
+ } while (0)
+
+#define FP_UNPACK_DP(X,val) \
+ do { \
+ _FP_UNPACK_RAW_1_P(D,X,val); \
+ _FP_UNPACK_CANONICAL(D,1,X); \
+ } while (0)
+
+#define FP_UNPACK_SEMIRAW_D(X,val) \
+ do { \
+ _FP_UNPACK_RAW_2(1,X,val); \
+ _FP_UNPACK_SEMIRAW(D,1,X); \
+ } while (0)
+
+#define FP_UNPACK_SEMIRAW_DP(X,val) \
+ do { \
+ _FP_UNPACK_RAW_2_P(1,X,val); \
+ _FP_UNPACK_SEMIRAW(D,1,X); \
+ } while (0)
+
+#define FP_PACK_D(val,X) \
+ do { \
+ _FP_PACK_CANONICAL(D,1,X); \
+ _FP_PACK_RAW_1(D,val,X); \
+ } while (0)
+
+#define FP_PACK_DP(val,X) \
+ do { \
+ _FP_PACK_CANONICAL(D,1,X); \
+ if (!FP_INHIBIT_RESULTS) \
+ _FP_PACK_RAW_1_P(D,val,X); \
+ } while (0)
+
+#define FP_PACK_SEMIRAW_D(val,X) \
+ do { \
+ _FP_PACK_SEMIRAW(D,1,X); \
+ _FP_PACK_RAW_1(D,val,X); \
+ } while (0)
+
+#define FP_PACK_SEMIRAW_DP(val,X) \
+ do { \
+ _FP_PACK_SEMIRAW(D,1,X); \
+ if (!FP_INHIBIT_RESULTS) \
+ _FP_PACK_RAW_1_P(D,val,X); \
+ } while (0)
+
+#define FP_ISSIGNAN_D(X) _FP_ISSIGNAN(D,1,X)
+#define FP_NEG_D(R,X) _FP_NEG(D,1,R,X)
+#define FP_ADD_D(R,X,Y) _FP_ADD(D,1,R,X,Y)
+#define FP_SUB_D(R,X,Y) _FP_SUB(D,1,R,X,Y)
+#define FP_MUL_D(R,X,Y) _FP_MUL(D,1,R,X,Y)
+#define FP_DIV_D(R,X,Y) _FP_DIV(D,1,R,X,Y)
+#define FP_SQRT_D(R,X) _FP_SQRT(D,1,R,X)
+#define _FP_SQRT_MEAT_D(R,S,T,X,Q) _FP_SQRT_MEAT_1(R,S,T,X,Q)
+
+/* The implementation of _FP_MUL_D and _FP_DIV_D should be chosen by
+ the target machine. */
+
+#define FP_CMP_D(r,X,Y,un) _FP_CMP(D,1,r,X,Y,un)
+#define FP_CMP_EQ_D(r,X,Y) _FP_CMP_EQ(D,1,r,X,Y)
+#define FP_CMP_UNORD_D(r,X,Y) _FP_CMP_UNORD(D,1,r,X,Y)
+
+#define FP_TO_INT_D(r,X,rsz,rsg) _FP_TO_INT(D,1,r,X,rsz,rsg)
+#define FP_FROM_INT_D(X,r,rs,rt) _FP_FROM_INT(D,1,X,r,rs,rt)
+
+#define _FP_FRAC_HIGH_D(X) _FP_FRAC_HIGH_1(X)
+#define _FP_FRAC_HIGH_RAW_D(X) _FP_FRAC_HIGH_1(X)
+
+#endif /* W_TYPE_SIZE < 64 */
diff --git a/libc/sysdeps/linux/sparc/soft-fp/extended.h b/libc/sysdeps/linux/sparc/soft-fp/extended.h
new file mode 100644
index 000000000..3ab6b6aa2
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/extended.h
@@ -0,0 +1,430 @@
+/* Software floating-point emulation.
+ Definitions for IEEE Extended Precision.
+ Copyright (C) 1999,2006,2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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 into
+ combinations with other programs, and to distribute those
+ combinations without any restriction coming from the use of this
+ file. (The Lesser General Public License restrictions do apply in
+ other respects; for example, they cover modification of the file,
+ and distribution when not linked into a combine executable.)
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#if _FP_W_TYPE_SIZE < 32
+#error "Here's a nickel, kid. Go buy yourself a real computer."
+#endif
+
+#if _FP_W_TYPE_SIZE < 64
+#define _FP_FRACTBITS_E (4*_FP_W_TYPE_SIZE)
+#else
+#define _FP_FRACTBITS_E (2*_FP_W_TYPE_SIZE)
+#endif
+
+#define _FP_FRACBITS_E 64
+#define _FP_FRACXBITS_E (_FP_FRACTBITS_E - _FP_FRACBITS_E)
+#define _FP_WFRACBITS_E (_FP_WORKBITS + _FP_FRACBITS_E)
+#define _FP_WFRACXBITS_E (_FP_FRACTBITS_E - _FP_WFRACBITS_E)
+#define _FP_EXPBITS_E 15
+#define _FP_EXPBIAS_E 16383
+#define _FP_EXPMAX_E 32767
+
+#define _FP_QNANBIT_E \
+ ((_FP_W_TYPE)1 << (_FP_FRACBITS_E-2) % _FP_W_TYPE_SIZE)
+#define _FP_QNANBIT_SH_E \
+ ((_FP_W_TYPE)1 << (_FP_FRACBITS_E-2+_FP_WORKBITS) % _FP_W_TYPE_SIZE)
+#define _FP_IMPLBIT_E \
+ ((_FP_W_TYPE)1 << (_FP_FRACBITS_E-1) % _FP_W_TYPE_SIZE)
+#define _FP_IMPLBIT_SH_E \
+ ((_FP_W_TYPE)1 << (_FP_FRACBITS_E-1+_FP_WORKBITS) % _FP_W_TYPE_SIZE)
+#define _FP_OVERFLOW_E \
+ ((_FP_W_TYPE)1 << (_FP_WFRACBITS_E % _FP_W_TYPE_SIZE))
+
+typedef float XFtype __attribute__((mode(XF)));
+
+#if _FP_W_TYPE_SIZE < 64
+
+union _FP_UNION_E
+{
+ XFtype flt;
+ struct
+ {
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned long pad1 : _FP_W_TYPE_SIZE;
+ unsigned long pad2 : (_FP_W_TYPE_SIZE - 1 - _FP_EXPBITS_E);
+ unsigned long sign : 1;
+ unsigned long exp : _FP_EXPBITS_E;
+ unsigned long frac1 : _FP_W_TYPE_SIZE;
+ unsigned long frac0 : _FP_W_TYPE_SIZE;
+#else
+ unsigned long frac0 : _FP_W_TYPE_SIZE;
+ unsigned long frac1 : _FP_W_TYPE_SIZE;
+ unsigned exp : _FP_EXPBITS_E;
+ unsigned sign : 1;
+#endif /* not bigendian */
+ } bits __attribute__((packed));
+};
+
+
+#define FP_DECL_E(X) _FP_DECL(4,X)
+
+#define FP_UNPACK_RAW_E(X, val) \
+ do { \
+ union _FP_UNION_E _flo; _flo.flt = (val); \
+ \
+ X##_f[2] = 0; X##_f[3] = 0; \
+ X##_f[0] = _flo.bits.frac0; \
+ X##_f[1] = _flo.bits.frac1; \
+ X##_e = _flo.bits.exp; \
+ X##_s = _flo.bits.sign; \
+ } while (0)
+
+#define FP_UNPACK_RAW_EP(X, val) \
+ do { \
+ union _FP_UNION_E *_flo = \
+ (union _FP_UNION_E *)(val); \
+ \
+ X##_f[2] = 0; X##_f[3] = 0; \
+ X##_f[0] = _flo->bits.frac0; \
+ X##_f[1] = _flo->bits.frac1; \
+ X##_e = _flo->bits.exp; \
+ X##_s = _flo->bits.sign; \
+ } while (0)
+
+#define FP_PACK_RAW_E(val, X) \
+ do { \
+ union _FP_UNION_E _flo; \
+ \
+ if (X##_e) X##_f[1] |= _FP_IMPLBIT_E; \
+ else X##_f[1] &= ~(_FP_IMPLBIT_E); \
+ _flo.bits.frac0 = X##_f[0]; \
+ _flo.bits.frac1 = X##_f[1]; \
+ _flo.bits.exp = X##_e; \
+ _flo.bits.sign = X##_s; \
+ \
+ (val) = _flo.flt; \
+ } while (0)
+
+#define FP_PACK_RAW_EP(val, X) \
+ do { \
+ if (!FP_INHIBIT_RESULTS) \
+ { \
+ union _FP_UNION_E *_flo = \
+ (union _FP_UNION_E *)(val); \
+ \
+ if (X##_e) X##_f[1] |= _FP_IMPLBIT_E; \
+ else X##_f[1] &= ~(_FP_IMPLBIT_E); \
+ _flo->bits.frac0 = X##_f[0]; \
+ _flo->bits.frac1 = X##_f[1]; \
+ _flo->bits.exp = X##_e; \
+ _flo->bits.sign = X##_s; \
+ } \
+ } while (0)
+
+#define FP_UNPACK_E(X,val) \
+ do { \
+ FP_UNPACK_RAW_E(X,val); \
+ _FP_UNPACK_CANONICAL(E,4,X); \
+ } while (0)
+
+#define FP_UNPACK_EP(X,val) \
+ do { \
+ FP_UNPACK_RAW_EP(X,val); \
+ _FP_UNPACK_CANONICAL(E,4,X); \
+ } while (0)
+
+#define FP_UNPACK_SEMIRAW_E(X,val) \
+ do { \
+ FP_UNPACK_RAW_E(X,val); \
+ _FP_UNPACK_SEMIRAW(E,4,X); \
+ } while (0)
+
+#define FP_UNPACK_SEMIRAW_EP(X,val) \
+ do { \
+ FP_UNPACK_RAW_EP(X,val); \
+ _FP_UNPACK_SEMIRAW(E,4,X); \
+ } while (0)
+
+#define FP_PACK_E(val,X) \
+ do { \
+ _FP_PACK_CANONICAL(E,4,X); \
+ FP_PACK_RAW_E(val,X); \
+ } while (0)
+
+#define FP_PACK_EP(val,X) \
+ do { \
+ _FP_PACK_CANONICAL(E,4,X); \
+ FP_PACK_RAW_EP(val,X); \
+ } while (0)
+
+#define FP_PACK_SEMIRAW_E(val,X) \
+ do { \
+ _FP_PACK_SEMIRAW(E,4,X); \
+ FP_PACK_RAW_E(val,X); \
+ } while (0)
+
+#define FP_PACK_SEMIRAW_EP(val,X) \
+ do { \
+ _FP_PACK_SEMIRAW(E,4,X); \
+ FP_PACK_RAW_EP(val,X); \
+ } while (0)
+
+#define FP_ISSIGNAN_E(X) _FP_ISSIGNAN(E,4,X)
+#define FP_NEG_E(R,X) _FP_NEG(E,4,R,X)
+#define FP_ADD_E(R,X,Y) _FP_ADD(E,4,R,X,Y)
+#define FP_SUB_E(R,X,Y) _FP_SUB(E,4,R,X,Y)
+#define FP_MUL_E(R,X,Y) _FP_MUL(E,4,R,X,Y)
+#define FP_DIV_E(R,X,Y) _FP_DIV(E,4,R,X,Y)
+#define FP_SQRT_E(R,X) _FP_SQRT(E,4,R,X)
+
+/*
+ * Square root algorithms:
+ * We have just one right now, maybe Newton approximation
+ * should be added for those machines where division is fast.
+ * This has special _E version because standard _4 square
+ * root would not work (it has to start normally with the
+ * second word and not the first), but as we have to do it
+ * anyway, we optimize it by doing most of the calculations
+ * in two UWtype registers instead of four.
+ */
+
+#define _FP_SQRT_MEAT_E(R, S, T, X, q) \
+ do { \
+ q = (_FP_W_TYPE)1 << (_FP_W_TYPE_SIZE - 1); \
+ _FP_FRAC_SRL_4(X, (_FP_WORKBITS)); \
+ while (q) \
+ { \
+ T##_f[1] = S##_f[1] + q; \
+ if (T##_f[1] <= X##_f[1]) \
+ { \
+ S##_f[1] = T##_f[1] + q; \
+ X##_f[1] -= T##_f[1]; \
+ R##_f[1] += q; \
+ } \
+ _FP_FRAC_SLL_2(X, 1); \
+ q >>= 1; \
+ } \
+ q = (_FP_W_TYPE)1 << (_FP_W_TYPE_SIZE - 1); \
+ while (q) \
+ { \
+ T##_f[0] = S##_f[0] + q; \
+ T##_f[1] = S##_f[1]; \
+ if (T##_f[1] < X##_f[1] || \
+ (T##_f[1] == X##_f[1] && \
+ T##_f[0] <= X##_f[0])) \
+ { \
+ S##_f[0] = T##_f[0] + q; \
+ S##_f[1] += (T##_f[0] > S##_f[0]); \
+ _FP_FRAC_DEC_2(X, T); \
+ R##_f[0] += q; \
+ } \
+ _FP_FRAC_SLL_2(X, 1); \
+ q >>= 1; \
+ } \
+ _FP_FRAC_SLL_4(R, (_FP_WORKBITS)); \
+ if (X##_f[0] | X##_f[1]) \
+ { \
+ if (S##_f[1] < X##_f[1] || \
+ (S##_f[1] == X##_f[1] && \
+ S##_f[0] < X##_f[0])) \
+ R##_f[0] |= _FP_WORK_ROUND; \
+ R##_f[0] |= _FP_WORK_STICKY; \
+ } \
+ } while (0)
+
+#define FP_CMP_E(r,X,Y,un) _FP_CMP(E,4,r,X,Y,un)
+#define FP_CMP_EQ_E(r,X,Y) _FP_CMP_EQ(E,4,r,X,Y)
+#define FP_CMP_UNORD_E(r,X,Y) _FP_CMP_UNORD(E,4,r,X,Y)
+
+#define FP_TO_INT_E(r,X,rsz,rsg) _FP_TO_INT(E,4,r,X,rsz,rsg)
+#define FP_FROM_INT_E(X,r,rs,rt) _FP_FROM_INT(E,4,X,r,rs,rt)
+
+#define _FP_FRAC_HIGH_E(X) (X##_f[2])
+#define _FP_FRAC_HIGH_RAW_E(X) (X##_f[1])
+
+#else /* not _FP_W_TYPE_SIZE < 64 */
+union _FP_UNION_E
+{
+ XFtype flt;
+ struct {
+#if __BYTE_ORDER == __BIG_ENDIAN
+ _FP_W_TYPE pad : (_FP_W_TYPE_SIZE - 1 - _FP_EXPBITS_E);
+ unsigned sign : 1;
+ unsigned exp : _FP_EXPBITS_E;
+ _FP_W_TYPE frac : _FP_W_TYPE_SIZE;
+#else
+ _FP_W_TYPE frac : _FP_W_TYPE_SIZE;
+ unsigned exp : _FP_EXPBITS_E;
+ unsigned sign : 1;
+#endif
+ } bits;
+};
+
+#define FP_DECL_E(X) _FP_DECL(2,X)
+
+#define FP_UNPACK_RAW_E(X, val) \
+ do { \
+ union _FP_UNION_E _flo; _flo.flt = (val); \
+ \
+ X##_f0 = _flo.bits.frac; \
+ X##_f1 = 0; \
+ X##_e = _flo.bits.exp; \
+ X##_s = _flo.bits.sign; \
+ } while (0)
+
+#define FP_UNPACK_RAW_EP(X, val) \
+ do { \
+ union _FP_UNION_E *_flo = \
+ (union _FP_UNION_E *)(val); \
+ \
+ X##_f0 = _flo->bits.frac; \
+ X##_f1 = 0; \
+ X##_e = _flo->bits.exp; \
+ X##_s = _flo->bits.sign; \
+ } while (0)
+
+#define FP_PACK_RAW_E(val, X) \
+ do { \
+ union _FP_UNION_E _flo; \
+ \
+ if (X##_e) X##_f0 |= _FP_IMPLBIT_E; \
+ else X##_f0 &= ~(_FP_IMPLBIT_E); \
+ _flo.bits.frac = X##_f0; \
+ _flo.bits.exp = X##_e; \
+ _flo.bits.sign = X##_s; \
+ \
+ (val) = _flo.flt; \
+ } while (0)
+
+#define FP_PACK_RAW_EP(fs, val, X) \
+ do { \
+ if (!FP_INHIBIT_RESULTS) \
+ { \
+ union _FP_UNION_E *_flo = \
+ (union _FP_UNION_E *)(val); \
+ \
+ if (X##_e) X##_f0 |= _FP_IMPLBIT_E; \
+ else X##_f0 &= ~(_FP_IMPLBIT_E); \
+ _flo->bits.frac = X##_f0; \
+ _flo->bits.exp = X##_e; \
+ _flo->bits.sign = X##_s; \
+ } \
+ } while (0)
+
+
+#define FP_UNPACK_E(X,val) \
+ do { \
+ FP_UNPACK_RAW_E(X,val); \
+ _FP_UNPACK_CANONICAL(E,2,X); \
+ } while (0)
+
+#define FP_UNPACK_EP(X,val) \
+ do { \
+ FP_UNPACK_RAW_EP(X,val); \
+ _FP_UNPACK_CANONICAL(E,2,X); \
+ } while (0)
+
+#define FP_UNPACK_SEMIRAW_E(X,val) \
+ do { \
+ FP_UNPACK_RAW_E(X,val); \
+ _FP_UNPACK_SEMIRAW(E,2,X); \
+ } while (0)
+
+#define FP_UNPACK_SEMIRAW_EP(X,val) \
+ do { \
+ FP_UNPACK_RAW_EP(X,val); \
+ _FP_UNPACK_SEMIRAW(E,2,X); \
+ } while (0)
+
+#define FP_PACK_E(val,X) \
+ do { \
+ _FP_PACK_CANONICAL(E,2,X); \
+ FP_PACK_RAW_E(val,X); \
+ } while (0)
+
+#define FP_PACK_EP(val,X) \
+ do { \
+ _FP_PACK_CANONICAL(E,2,X); \
+ FP_PACK_RAW_EP(val,X); \
+ } while (0)
+
+#define FP_PACK_SEMIRAW_E(val,X) \
+ do { \
+ _FP_PACK_SEMIRAW(E,2,X); \
+ FP_PACK_RAW_E(val,X); \
+ } while (0)
+
+#define FP_PACK_SEMIRAW_EP(val,X) \
+ do { \
+ _FP_PACK_SEMIRAW(E,2,X); \
+ FP_PACK_RAW_EP(val,X); \
+ } while (0)
+
+#define FP_ISSIGNAN_E(X) _FP_ISSIGNAN(E,2,X)
+#define FP_NEG_E(R,X) _FP_NEG(E,2,R,X)
+#define FP_ADD_E(R,X,Y) _FP_ADD(E,2,R,X,Y)
+#define FP_SUB_E(R,X,Y) _FP_SUB(E,2,R,X,Y)
+#define FP_MUL_E(R,X,Y) _FP_MUL(E,2,R,X,Y)
+#define FP_DIV_E(R,X,Y) _FP_DIV(E,2,R,X,Y)
+#define FP_SQRT_E(R,X) _FP_SQRT(E,2,R,X)
+
+/*
+ * Square root algorithms:
+ * We have just one right now, maybe Newton approximation
+ * should be added for those machines where division is fast.
+ * We optimize it by doing most of the calculations
+ * in one UWtype registers instead of two, although we don't
+ * have to.
+ */
+#define _FP_SQRT_MEAT_E(R, S, T, X, q) \
+ do { \
+ q = (_FP_W_TYPE)1 << (_FP_W_TYPE_SIZE - 1); \
+ _FP_FRAC_SRL_2(X, (_FP_WORKBITS)); \
+ while (q) \
+ { \
+ T##_f0 = S##_f0 + q; \
+ if (T##_f0 <= X##_f0) \
+ { \
+ S##_f0 = T##_f0 + q; \
+ X##_f0 -= T##_f0; \
+ R##_f0 += q; \
+ } \
+ _FP_FRAC_SLL_1(X, 1); \
+ q >>= 1; \
+ } \
+ _FP_FRAC_SLL_2(R, (_FP_WORKBITS)); \
+ if (X##_f0) \
+ { \
+ if (S##_f0 < X##_f0) \
+ R##_f0 |= _FP_WORK_ROUND; \
+ R##_f0 |= _FP_WORK_STICKY; \
+ } \
+ } while (0)
+
+#define FP_CMP_E(r,X,Y,un) _FP_CMP(E,2,r,X,Y,un)
+#define FP_CMP_EQ_E(r,X,Y) _FP_CMP_EQ(E,2,r,X,Y)
+#define FP_CMP_UNORD_E(r,X,Y) _FP_CMP_UNORD(E,2,r,X,Y)
+
+#define FP_TO_INT_E(r,X,rsz,rsg) _FP_TO_INT(E,2,r,X,rsz,rsg)
+#define FP_FROM_INT_E(X,r,rs,rt) _FP_FROM_INT(E,2,X,r,rs,rt)
+
+#define _FP_FRAC_HIGH_E(X) (X##_f1)
+#define _FP_FRAC_HIGH_RAW_E(X) (X##_f0)
+
+#endif /* not _FP_W_TYPE_SIZE < 64 */
diff --git a/libc/sysdeps/linux/sparc/soft-fp/longlong.h b/libc/sysdeps/linux/sparc/soft-fp/longlong.h
new file mode 100644
index 000000000..bd0d9be01
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/longlong.h
@@ -0,0 +1,1396 @@
+/* longlong.h -- definitions for mixed size 32/64 bit arithmetic.
+ Copyright (C) 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+ 2002, 2003, 2004, 2005, 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, see
+ <http://www.gnu.org/licenses/>. */
+
+/* You have to define the following before including this file:
+
+ UWtype -- An unsigned type, default type for operations (typically a "word")
+ UHWtype -- An unsigned type, at least half the size of UWtype.
+ UDWtype -- An unsigned type, at least twice as large a UWtype
+ W_TYPE_SIZE -- size in bits of UWtype
+
+ UQItype -- Unsigned 8 bit type.
+ SItype, USItype -- Signed and unsigned 32 bit types.
+ DItype, UDItype -- Signed and unsigned 64 bit types.
+
+ On a 32 bit machine UWtype should typically be USItype;
+ on a 64 bit machine, UWtype should typically be UDItype. */
+
+#define __BITS4 (W_TYPE_SIZE / 4)
+#define __ll_B ((UWtype) 1 << (W_TYPE_SIZE / 2))
+#define __ll_lowpart(t) ((UWtype) (t) & (__ll_B - 1))
+#define __ll_highpart(t) ((UWtype) (t) >> (W_TYPE_SIZE / 2))
+
+#ifndef W_TYPE_SIZE
+#define W_TYPE_SIZE 32
+#define UWtype USItype
+#define UHWtype USItype
+#define UDWtype UDItype
+#endif
+
+extern const UQItype __clz_tab[256] attribute_hidden;
+
+/* Define auxiliary asm macros.
+
+ 1) umul_ppmm(high_prod, low_prod, multiplier, multiplicand) multiplies two
+ UWtype integers MULTIPLIER and MULTIPLICAND, and generates a two UWtype
+ word product in HIGH_PROD and LOW_PROD.
+
+ 2) __umulsidi3(a,b) multiplies two UWtype integers A and B, and returns a
+ UDWtype product. This is just a variant of umul_ppmm.
+
+ 3) udiv_qrnnd(quotient, remainder, high_numerator, low_numerator,
+ denominator) divides a UDWtype, composed by the UWtype integers
+ HIGH_NUMERATOR and LOW_NUMERATOR, by DENOMINATOR and places the quotient
+ in QUOTIENT and the remainder in REMAINDER. HIGH_NUMERATOR must be less
+ than DENOMINATOR for correct operation. If, in addition, the most
+ significant bit of DENOMINATOR must be 1, then the pre-processor symbol
+ UDIV_NEEDS_NORMALIZATION is defined to 1.
+
+ 4) sdiv_qrnnd(quotient, remainder, high_numerator, low_numerator,
+ denominator). Like udiv_qrnnd but the numbers are signed. The quotient
+ is rounded towards 0.
+
+ 5) count_leading_zeros(count, x) counts the number of zero-bits from the
+ msb to the first nonzero bit in the UWtype X. This is the number of
+ steps X needs to be shifted left to set the msb. Undefined for X == 0,
+ unless the symbol COUNT_LEADING_ZEROS_0 is defined to some value.
+
+ 6) count_trailing_zeros(count, x) like count_leading_zeros, but counts
+ from the least significant end.
+
+ 7) add_ssaaaa(high_sum, low_sum, high_addend_1, low_addend_1,
+ high_addend_2, low_addend_2) adds two UWtype integers, composed by
+ HIGH_ADDEND_1 and LOW_ADDEND_1, and HIGH_ADDEND_2 and LOW_ADDEND_2
+ respectively. The result is placed in HIGH_SUM and LOW_SUM. Overflow
+ (i.e. carry out) is not stored anywhere, and is lost.
+
+ 8) sub_ddmmss(high_difference, low_difference, high_minuend, low_minuend,
+ high_subtrahend, low_subtrahend) subtracts two two-word UWtype integers,
+ composed by HIGH_MINUEND_1 and LOW_MINUEND_1, and HIGH_SUBTRAHEND_2 and
+ LOW_SUBTRAHEND_2 respectively. The result is placed in HIGH_DIFFERENCE
+ and LOW_DIFFERENCE. Overflow (i.e. carry out) is not stored anywhere,
+ and is lost.
+
+ If any of these macros are left undefined for a particular CPU,
+ C macros are used. */
+
+/* The CPUs come in alphabetical order below.
+
+ Please add support for more CPUs here, or improve the current support
+ for the CPUs below!
+ (E.g. WE32100, IBM360.) */
+
+#if defined (__GNUC__) && !defined (NO_ASM)
+
+/* We sometimes need to clobber "cc" with gcc2, but that would not be
+ understood by gcc1. Use cpp to avoid major code duplication. */
+#if __GNUC__ < 2
+#define __CLOBBER_CC
+#define __AND_CLOBBER_CC
+#else /* __GNUC__ >= 2 */
+#define __CLOBBER_CC : "cc"
+#define __AND_CLOBBER_CC , "cc"
+#endif /* __GNUC__ < 2 */
+
+#if defined (__alpha) && W_TYPE_SIZE == 64
+#define umul_ppmm(ph, pl, m0, m1) \
+ do { \
+ UDItype __m0 = (m0), __m1 = (m1); \
+ (ph) = __builtin_alpha_umulh (__m0, __m1); \
+ (pl) = __m0 * __m1; \
+ } while (0)
+#define UMUL_TIME 46
+#ifndef LONGLONG_STANDALONE
+#define udiv_qrnnd(q, r, n1, n0, d) \
+ do { UDItype __r; \
+ (q) = __udiv_qrnnd (&__r, (n1), (n0), (d)); \
+ (r) = __r; \
+ } while (0)
+extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype);
+#define UDIV_TIME 220
+#endif /* LONGLONG_STANDALONE */
+#ifdef __alpha_cix__
+#define count_leading_zeros(COUNT,X) ((COUNT) = __builtin_clzl (X))
+#define count_trailing_zeros(COUNT,X) ((COUNT) = __builtin_ctzl (X))
+#define COUNT_LEADING_ZEROS_0 64
+#else
+#define count_leading_zeros(COUNT,X) \
+ do { \
+ UDItype __xr = (X), __t, __a; \
+ __t = __builtin_alpha_cmpbge (0, __xr); \
+ __a = __clz_tab[__t ^ 0xff] - 1; \
+ __t = __builtin_alpha_extbl (__xr, __a); \
+ (COUNT) = 64 - (__clz_tab[__t] + __a*8); \
+ } while (0)
+#define count_trailing_zeros(COUNT,X) \
+ do { \
+ UDItype __xr = (X), __t, __a; \
+ __t = __builtin_alpha_cmpbge (0, __xr); \
+ __t = ~__t & -~__t; \
+ __a = ((__t & 0xCC) != 0) * 2; \
+ __a += ((__t & 0xF0) != 0) * 4; \
+ __a += ((__t & 0xAA) != 0); \
+ __t = __builtin_alpha_extbl (__xr, __a); \
+ __a <<= 3; \
+ __t &= -__t; \
+ __a += ((__t & 0xCC) != 0) * 2; \
+ __a += ((__t & 0xF0) != 0) * 4; \
+ __a += ((__t & 0xAA) != 0); \
+ (COUNT) = __a; \
+ } while (0)
+#endif /* __alpha_cix__ */
+#endif /* __alpha */
+
+#if defined (__arc__) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("add.f %1, %4, %5\n\tadc %0, %2, %3" \
+ : "=r" ((USItype) (sh)), \
+ "=&r" ((USItype) (sl)) \
+ : "%r" ((USItype) (ah)), \
+ "rIJ" ((USItype) (bh)), \
+ "%r" ((USItype) (al)), \
+ "rIJ" ((USItype) (bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("sub.f %1, %4, %5\n\tsbc %0, %2, %3" \
+ : "=r" ((USItype) (sh)), \
+ "=&r" ((USItype) (sl)) \
+ : "r" ((USItype) (ah)), \
+ "rIJ" ((USItype) (bh)), \
+ "r" ((USItype) (al)), \
+ "rIJ" ((USItype) (bl)))
+/* Call libgcc routine. */
+#define umul_ppmm(w1, w0, u, v) \
+do { \
+ DWunion __w; \
+ __w.ll = __umulsidi3 (u, v); \
+ w1 = __w.s.high; \
+ w0 = __w.s.low; \
+} while (0)
+#define __umulsidi3 __umulsidi3
+UDItype __umulsidi3 (USItype, USItype);
+#endif
+
+#if defined (__arm__) && !defined (__thumb__) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("adds %1, %4, %5\n\tadc %0, %2, %3" \
+ : "=r" ((USItype) (sh)), \
+ "=&r" ((USItype) (sl)) \
+ : "%r" ((USItype) (ah)), \
+ "rI" ((USItype) (bh)), \
+ "%r" ((USItype) (al)), \
+ "rI" ((USItype) (bl)) __CLOBBER_CC)
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("subs %1, %4, %5\n\tsbc %0, %2, %3" \
+ : "=r" ((USItype) (sh)), \
+ "=&r" ((USItype) (sl)) \
+ : "r" ((USItype) (ah)), \
+ "rI" ((USItype) (bh)), \
+ "r" ((USItype) (al)), \
+ "rI" ((USItype) (bl)) __CLOBBER_CC)
+#define umul_ppmm(xh, xl, a, b) \
+{register USItype __t0, __t1, __t2; \
+ __asm__ ("%@ Inlined umul_ppmm\n" \
+ " mov %2, %5, lsr #16\n" \
+ " mov %0, %6, lsr #16\n" \
+ " bic %3, %5, %2, lsl #16\n" \
+ " bic %4, %6, %0, lsl #16\n" \
+ " mul %1, %3, %4\n" \
+ " mul %4, %2, %4\n" \
+ " mul %3, %0, %3\n" \
+ " mul %0, %2, %0\n" \
+ " adds %3, %4, %3\n" \
+ " addcs %0, %0, #65536\n" \
+ " adds %1, %1, %3, lsl #16\n" \
+ " adc %0, %0, %3, lsr #16" \
+ : "=&r" ((USItype) (xh)), \
+ "=r" ((USItype) (xl)), \
+ "=&r" (__t0), "=&r" (__t1), "=r" (__t2) \
+ : "r" ((USItype) (a)), \
+ "r" ((USItype) (b)) __CLOBBER_CC );}
+#define UMUL_TIME 20
+#define UDIV_TIME 100
+#endif /* __arm__ */
+
+#if defined(__arm__)
+/* Let gcc decide how best to implement count_leading_zeros. */
+#define count_leading_zeros(COUNT,X) ((COUNT) = __builtin_clz (X))
+#define COUNT_LEADING_ZEROS_0 32
+#endif
+
+#if defined (__CRIS__) && __CRIS_arch_version >= 3
+#define count_leading_zeros(COUNT, X) ((COUNT) = __builtin_clz (X))
+#if __CRIS_arch_version >= 8
+#define count_trailing_zeros(COUNT, X) ((COUNT) = __builtin_ctz (X))
+#endif
+#endif /* __CRIS__ */
+
+#if defined (__hppa) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("add %4,%5,%1\n\taddc %2,%3,%0" \
+ : "=r" ((USItype) (sh)), \
+ "=&r" ((USItype) (sl)) \
+ : "%rM" ((USItype) (ah)), \
+ "rM" ((USItype) (bh)), \
+ "%rM" ((USItype) (al)), \
+ "rM" ((USItype) (bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("sub %4,%5,%1\n\tsubb %2,%3,%0" \
+ : "=r" ((USItype) (sh)), \
+ "=&r" ((USItype) (sl)) \
+ : "rM" ((USItype) (ah)), \
+ "rM" ((USItype) (bh)), \
+ "rM" ((USItype) (al)), \
+ "rM" ((USItype) (bl)))
+#if defined (_PA_RISC1_1)
+#define umul_ppmm(w1, w0, u, v) \
+ do { \
+ union \
+ { \
+ UDItype __f; \
+ struct {USItype __w1, __w0;} __w1w0; \
+ } __t; \
+ __asm__ ("xmpyu %1,%2,%0" \
+ : "=x" (__t.__f) \
+ : "x" ((USItype) (u)), \
+ "x" ((USItype) (v))); \
+ (w1) = __t.__w1w0.__w1; \
+ (w0) = __t.__w1w0.__w0; \
+ } while (0)
+#define UMUL_TIME 8
+#else
+#define UMUL_TIME 30
+#endif
+#define UDIV_TIME 40
+#define count_leading_zeros(count, x) \
+ do { \
+ USItype __tmp; \
+ __asm__ ( \
+ "ldi 1,%0\n" \
+" extru,= %1,15,16,%%r0 ; Bits 31..16 zero?\n" \
+" extru,tr %1,15,16,%1 ; No. Shift down, skip add.\n"\
+" ldo 16(%0),%0 ; Yes. Perform add.\n" \
+" extru,= %1,23,8,%%r0 ; Bits 15..8 zero?\n" \
+" extru,tr %1,23,8,%1 ; No. Shift down, skip add.\n"\
+" ldo 8(%0),%0 ; Yes. Perform add.\n" \
+" extru,= %1,27,4,%%r0 ; Bits 7..4 zero?\n" \
+" extru,tr %1,27,4,%1 ; No. Shift down, skip add.\n"\
+" ldo 4(%0),%0 ; Yes. Perform add.\n" \
+" extru,= %1,29,2,%%r0 ; Bits 3..2 zero?\n" \
+" extru,tr %1,29,2,%1 ; No. Shift down, skip add.\n"\
+" ldo 2(%0),%0 ; Yes. Perform add.\n" \
+" extru %1,30,1,%1 ; Extract bit 1.\n" \
+" sub %0,%1,%0 ; Subtract it.\n" \
+ : "=r" (count), "=r" (__tmp) : "1" (x)); \
+ } while (0)
+#endif
+
+#if (defined (__i370__) || defined (__s390__) || defined (__mvs__)) && W_TYPE_SIZE == 32
+#define smul_ppmm(xh, xl, m0, m1) \
+ do { \
+ union {DItype __ll; \
+ struct {USItype __h, __l;} __i; \
+ } __x; \
+ __asm__ ("lr %N0,%1\n\tmr %0,%2" \
+ : "=&r" (__x.__ll) \
+ : "r" (m0), "r" (m1)); \
+ (xh) = __x.__i.__h; (xl) = __x.__i.__l; \
+ } while (0)
+#define sdiv_qrnnd(q, r, n1, n0, d) \
+ do { \
+ union {DItype __ll; \
+ struct {USItype __h, __l;} __i; \
+ } __x; \
+ __x.__i.__h = n1; __x.__i.__l = n0; \
+ __asm__ ("dr %0,%2" \
+ : "=r" (__x.__ll) \
+ : "0" (__x.__ll), "r" (d)); \
+ (q) = __x.__i.__l; (r) = __x.__i.__h; \
+ } while (0)
+#endif
+
+#if (defined (__i386__) || defined (__i486__)) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("add{l} {%5,%1|%1,%5}\n\tadc{l} {%3,%0|%0,%3}" \
+ : "=r" ((USItype) (sh)), \
+ "=&r" ((USItype) (sl)) \
+ : "%0" ((USItype) (ah)), \
+ "g" ((USItype) (bh)), \
+ "%1" ((USItype) (al)), \
+ "g" ((USItype) (bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("sub{l} {%5,%1|%1,%5}\n\tsbb{l} {%3,%0|%0,%3}" \
+ : "=r" ((USItype) (sh)), \
+ "=&r" ((USItype) (sl)) \
+ : "0" ((USItype) (ah)), \
+ "g" ((USItype) (bh)), \
+ "1" ((USItype) (al)), \
+ "g" ((USItype) (bl)))
+#define umul_ppmm(w1, w0, u, v) \
+ __asm__ ("mul{l} %3" \
+ : "=a" ((USItype) (w0)), \
+ "=d" ((USItype) (w1)) \
+ : "%0" ((USItype) (u)), \
+ "rm" ((USItype) (v)))
+#define udiv_qrnnd(q, r, n1, n0, dv) \
+ __asm__ ("div{l} %4" \
+ : "=a" ((USItype) (q)), \
+ "=d" ((USItype) (r)) \
+ : "0" ((USItype) (n0)), \
+ "1" ((USItype) (n1)), \
+ "rm" ((USItype) (dv)))
+#define count_leading_zeros(count, x) ((count) = __builtin_clz (x))
+#define count_trailing_zeros(count, x) ((count) = __builtin_ctz (x))
+#define UMUL_TIME 40
+#define UDIV_TIME 40
+#endif /* 80x86 */
+
+#if (defined (__x86_64__) || defined (__i386__)) && W_TYPE_SIZE == 64
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("add{q} {%5,%1|%1,%5}\n\tadc{q} {%3,%0|%0,%3}" \
+ : "=r" ((UDItype) (sh)), \
+ "=&r" ((UDItype) (sl)) \
+ : "%0" ((UDItype) (ah)), \
+ "rme" ((UDItype) (bh)), \
+ "%1" ((UDItype) (al)), \
+ "rme" ((UDItype) (bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("sub{q} {%5,%1|%1,%5}\n\tsbb{q} {%3,%0|%0,%3}" \
+ : "=r" ((UDItype) (sh)), \
+ "=&r" ((UDItype) (sl)) \
+ : "0" ((UDItype) (ah)), \
+ "rme" ((UDItype) (bh)), \
+ "1" ((UDItype) (al)), \
+ "rme" ((UDItype) (bl)))
+#define umul_ppmm(w1, w0, u, v) \
+ __asm__ ("mul{q} %3" \
+ : "=a" ((UDItype) (w0)), \
+ "=d" ((UDItype) (w1)) \
+ : "%0" ((UDItype) (u)), \
+ "rm" ((UDItype) (v)))
+#define udiv_qrnnd(q, r, n1, n0, dv) \
+ __asm__ ("div{q} %4" \
+ : "=a" ((UDItype) (q)), \
+ "=d" ((UDItype) (r)) \
+ : "0" ((UDItype) (n0)), \
+ "1" ((UDItype) (n1)), \
+ "rm" ((UDItype) (dv)))
+#define count_leading_zeros(count, x) ((count) = __builtin_clzl (x))
+#define count_trailing_zeros(count, x) ((count) = __builtin_ctzl (x))
+#define UMUL_TIME 40
+#define UDIV_TIME 40
+#endif /* x86_64 */
+
+#if defined (__M32R__) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ /* The cmp clears the condition bit. */ \
+ __asm__ ("cmp %0,%0\n\taddx %1,%5\n\taddx %0,%3" \
+ : "=r" ((USItype) (sh)), \
+ "=&r" ((USItype) (sl)) \
+ : "0" ((USItype) (ah)), \
+ "r" ((USItype) (bh)), \
+ "1" ((USItype) (al)), \
+ "r" ((USItype) (bl)) \
+ : "cbit")
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ /* The cmp clears the condition bit. */ \
+ __asm__ ("cmp %0,%0\n\tsubx %1,%5\n\tsubx %0,%3" \
+ : "=r" ((USItype) (sh)), \
+ "=&r" ((USItype) (sl)) \
+ : "0" ((USItype) (ah)), \
+ "r" ((USItype) (bh)), \
+ "1" ((USItype) (al)), \
+ "r" ((USItype) (bl)) \
+ : "cbit")
+#endif /* __M32R__ */
+
+#if defined (__mc68000__) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("add%.l %5,%1\n\taddx%.l %3,%0" \
+ : "=d" ((USItype) (sh)), \
+ "=&d" ((USItype) (sl)) \
+ : "%0" ((USItype) (ah)), \
+ "d" ((USItype) (bh)), \
+ "%1" ((USItype) (al)), \
+ "g" ((USItype) (bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("sub%.l %5,%1\n\tsubx%.l %3,%0" \
+ : "=d" ((USItype) (sh)), \
+ "=&d" ((USItype) (sl)) \
+ : "0" ((USItype) (ah)), \
+ "d" ((USItype) (bh)), \
+ "1" ((USItype) (al)), \
+ "g" ((USItype) (bl)))
+
+/* The '020, '030, '040, '060 and CPU32 have 32x32->64 and 64/32->32q-32r. */
+#if (defined (__mc68020__) && !defined (__mc68060__))
+#define umul_ppmm(w1, w0, u, v) \
+ __asm__ ("mulu%.l %3,%1:%0" \
+ : "=d" ((USItype) (w0)), \
+ "=d" ((USItype) (w1)) \
+ : "%0" ((USItype) (u)), \
+ "dmi" ((USItype) (v)))
+#define UMUL_TIME 45
+#define udiv_qrnnd(q, r, n1, n0, d) \
+ __asm__ ("divu%.l %4,%1:%0" \
+ : "=d" ((USItype) (q)), \
+ "=d" ((USItype) (r)) \
+ : "0" ((USItype) (n0)), \
+ "1" ((USItype) (n1)), \
+ "dmi" ((USItype) (d)))
+#define UDIV_TIME 90
+#define sdiv_qrnnd(q, r, n1, n0, d) \
+ __asm__ ("divs%.l %4,%1:%0" \
+ : "=d" ((USItype) (q)), \
+ "=d" ((USItype) (r)) \
+ : "0" ((USItype) (n0)), \
+ "1" ((USItype) (n1)), \
+ "dmi" ((USItype) (d)))
+
+#elif defined (__mcoldfire__) /* not mc68020 */
+
+#define umul_ppmm(xh, xl, a, b) \
+ __asm__ ("| Inlined umul_ppmm\n" \
+ " move%.l %2,%/d0\n" \
+ " move%.l %3,%/d1\n" \
+ " move%.l %/d0,%/d2\n" \
+ " swap %/d0\n" \
+ " move%.l %/d1,%/d3\n" \
+ " swap %/d1\n" \
+ " move%.w %/d2,%/d4\n" \
+ " mulu %/d3,%/d4\n" \
+ " mulu %/d1,%/d2\n" \
+ " mulu %/d0,%/d3\n" \
+ " mulu %/d0,%/d1\n" \
+ " move%.l %/d4,%/d0\n" \
+ " clr%.w %/d0\n" \
+ " swap %/d0\n" \
+ " add%.l %/d0,%/d2\n" \
+ " add%.l %/d3,%/d2\n" \
+ " jcc 1f\n" \
+ " add%.l %#65536,%/d1\n" \
+ "1: swap %/d2\n" \
+ " moveq %#0,%/d0\n" \
+ " move%.w %/d2,%/d0\n" \
+ " move%.w %/d4,%/d2\n" \
+ " move%.l %/d2,%1\n" \
+ " add%.l %/d1,%/d0\n" \
+ " move%.l %/d0,%0" \
+ : "=g" ((USItype) (xh)), \
+ "=g" ((USItype) (xl)) \
+ : "g" ((USItype) (a)), \
+ "g" ((USItype) (b)) \
+ : "d0", "d1", "d2", "d3", "d4")
+#define UMUL_TIME 100
+#define UDIV_TIME 400
+#else /* not ColdFire */
+/* %/ inserts REGISTER_PREFIX, %# inserts IMMEDIATE_PREFIX. */
+#define umul_ppmm(xh, xl, a, b) \
+ __asm__ ("| Inlined umul_ppmm\n" \
+ " move%.l %2,%/d0\n" \
+ " move%.l %3,%/d1\n" \
+ " move%.l %/d0,%/d2\n" \
+ " swap %/d0\n" \
+ " move%.l %/d1,%/d3\n" \
+ " swap %/d1\n" \
+ " move%.w %/d2,%/d4\n" \
+ " mulu %/d3,%/d4\n" \
+ " mulu %/d1,%/d2\n" \
+ " mulu %/d0,%/d3\n" \
+ " mulu %/d0,%/d1\n" \
+ " move%.l %/d4,%/d0\n" \
+ " eor%.w %/d0,%/d0\n" \
+ " swap %/d0\n" \
+ " add%.l %/d0,%/d2\n" \
+ " add%.l %/d3,%/d2\n" \
+ " jcc 1f\n" \
+ " add%.l %#65536,%/d1\n" \
+ "1: swap %/d2\n" \
+ " moveq %#0,%/d0\n" \
+ " move%.w %/d2,%/d0\n" \
+ " move%.w %/d4,%/d2\n" \
+ " move%.l %/d2,%1\n" \
+ " add%.l %/d1,%/d0\n" \
+ " move%.l %/d0,%0" \
+ : "=g" ((USItype) (xh)), \
+ "=g" ((USItype) (xl)) \
+ : "g" ((USItype) (a)), \
+ "g" ((USItype) (b)) \
+ : "d0", "d1", "d2", "d3", "d4")
+#define UMUL_TIME 100
+#define UDIV_TIME 400
+
+#endif /* not mc68020 */
+
+/* The '020, '030, '040 and '060 have bitfield insns.
+ cpu32 disguises as a 68020, but lacks them. */
+#if defined (__mc68020__) && !defined (__mcpu32__)
+#define count_leading_zeros(count, x) \
+ __asm__ ("bfffo %1{%b2:%b2},%0" \
+ : "=d" ((USItype) (count)) \
+ : "od" ((USItype) (x)), "n" (0))
+/* Some ColdFire architectures have a ff1 instruction supported via
+ __builtin_clz. */
+#elif defined (__mcfisaaplus__) || defined (__mcfisac__)
+#define count_leading_zeros(count,x) ((count) = __builtin_clz (x))
+#define COUNT_LEADING_ZEROS_0 32
+#endif
+#endif /* mc68000 */
+
+#if defined (__m88000__) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("addu.co %1,%r4,%r5\n\taddu.ci %0,%r2,%r3" \
+ : "=r" ((USItype) (sh)), \
+ "=&r" ((USItype) (sl)) \
+ : "%rJ" ((USItype) (ah)), \
+ "rJ" ((USItype) (bh)), \
+ "%rJ" ((USItype) (al)), \
+ "rJ" ((USItype) (bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("subu.co %1,%r4,%r5\n\tsubu.ci %0,%r2,%r3" \
+ : "=r" ((USItype) (sh)), \
+ "=&r" ((USItype) (sl)) \
+ : "rJ" ((USItype) (ah)), \
+ "rJ" ((USItype) (bh)), \
+ "rJ" ((USItype) (al)), \
+ "rJ" ((USItype) (bl)))
+#define count_leading_zeros(count, x) \
+ do { \
+ USItype __cbtmp; \
+ __asm__ ("ff1 %0,%1" \
+ : "=r" (__cbtmp) \
+ : "r" ((USItype) (x))); \
+ (count) = __cbtmp ^ 31; \
+ } while (0)
+#define COUNT_LEADING_ZEROS_0 63 /* sic */
+#if defined (__mc88110__)
+#define umul_ppmm(wh, wl, u, v) \
+ do { \
+ union {UDItype __ll; \
+ struct {USItype __h, __l;} __i; \
+ } __xx; \
+ __asm__ ("mulu.d %0,%1,%2" \
+ : "=r" (__xx.__ll) \
+ : "r" ((USItype) (u)), \
+ "r" ((USItype) (v))); \
+ (wh) = __xx.__i.__h; \
+ (wl) = __xx.__i.__l; \
+ } while (0)
+#define udiv_qrnnd(q, r, n1, n0, d) \
+ ({union {UDItype __ll; \
+ struct {USItype __h, __l;} __i; \
+ } __xx; \
+ USItype __q; \
+ __xx.__i.__h = (n1); __xx.__i.__l = (n0); \
+ __asm__ ("divu.d %0,%1,%2" \
+ : "=r" (__q) \
+ : "r" (__xx.__ll), \
+ "r" ((USItype) (d))); \
+ (r) = (n0) - __q * (d); (q) = __q; })
+#define UMUL_TIME 5
+#define UDIV_TIME 25
+#else
+#define UMUL_TIME 17
+#define UDIV_TIME 150
+#endif /* __mc88110__ */
+#endif /* __m88000__ */
+
+#if defined (__mips__) && W_TYPE_SIZE == 32
+#define umul_ppmm(w1, w0, u, v) \
+ do { \
+ UDItype __x = (UDItype) (USItype) (u) * (USItype) (v); \
+ (w1) = (USItype) (__x >> 32); \
+ (w0) = (USItype) (__x); \
+ } while (0)
+#define UMUL_TIME 10
+#define UDIV_TIME 100
+
+#if (__mips == 32 || __mips == 64) && ! __mips16
+#define count_leading_zeros(COUNT,X) ((COUNT) = __builtin_clz (X))
+#define COUNT_LEADING_ZEROS_0 32
+#endif
+#endif /* __mips__ */
+
+#if defined (__ns32000__) && W_TYPE_SIZE == 32
+#define umul_ppmm(w1, w0, u, v) \
+ ({union {UDItype __ll; \
+ struct {USItype __l, __h;} __i; \
+ } __xx; \
+ __asm__ ("meid %2,%0" \
+ : "=g" (__xx.__ll) \
+ : "%0" ((USItype) (u)), \
+ "g" ((USItype) (v))); \
+ (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
+#define __umulsidi3(u, v) \
+ ({UDItype __w; \
+ __asm__ ("meid %2,%0" \
+ : "=g" (__w) \
+ : "%0" ((USItype) (u)), \
+ "g" ((USItype) (v))); \
+ __w; })
+#define udiv_qrnnd(q, r, n1, n0, d) \
+ ({union {UDItype __ll; \
+ struct {USItype __l, __h;} __i; \
+ } __xx; \
+ __xx.__i.__h = (n1); __xx.__i.__l = (n0); \
+ __asm__ ("deid %2,%0" \
+ : "=g" (__xx.__ll) \
+ : "0" (__xx.__ll), \
+ "g" ((USItype) (d))); \
+ (r) = __xx.__i.__l; (q) = __xx.__i.__h; })
+#define count_trailing_zeros(count,x) \
+ do { \
+ __asm__ ("ffsd %2,%0" \
+ : "=r" ((USItype) (count)) \
+ : "0" ((USItype) 0), \
+ "r" ((USItype) (x))); \
+ } while (0)
+#endif /* __ns32000__ */
+
+/* FIXME: We should test _IBMR2 here when we add assembly support for the
+ system vendor compilers.
+ FIXME: What's needed for gcc PowerPC VxWorks? __vxworks__ is not good
+ enough, since that hits ARM and m68k too. */
+#if (defined (_ARCH_PPC) /* AIX */ \
+ || defined (_ARCH_PWR) /* AIX */ \
+ || defined (_ARCH_COM) /* AIX */ \
+ || defined (__powerpc__) /* gcc */ \
+ || defined (__POWERPC__) /* BEOS */ \
+ || defined (__ppc__) /* Darwin */ \
+ || (defined (PPC) && ! defined (CPU_FAMILY)) /* gcc 2.7.x GNU&SysV */ \
+ || (defined (PPC) && defined (CPU_FAMILY) /* VxWorks */ \
+ && CPU_FAMILY == PPC) \
+ ) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ do { \
+ if (__builtin_constant_p (bh) && (bh) == 0) \
+ __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{aze|addze} %0,%2" \
+ : "=r" (sh), "=&r" (sl) : "r" (ah), "%r" (al), "rI" (bl));\
+ else if (__builtin_constant_p (bh) && (bh) == ~(USItype) 0) \
+ __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{ame|addme} %0,%2" \
+ : "=r" (sh), "=&r" (sl) : "r" (ah), "%r" (al), "rI" (bl));\
+ else \
+ __asm__ ("{a%I5|add%I5c} %1,%4,%5\n\t{ae|adde} %0,%2,%3" \
+ : "=r" (sh), "=&r" (sl) \
+ : "%r" (ah), "r" (bh), "%r" (al), "rI" (bl)); \
+ } while (0)
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ do { \
+ if (__builtin_constant_p (ah) && (ah) == 0) \
+ __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfze|subfze} %0,%2" \
+ : "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\
+ else if (__builtin_constant_p (ah) && (ah) == ~(USItype) 0) \
+ __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfme|subfme} %0,%2" \
+ : "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\
+ else if (__builtin_constant_p (bh) && (bh) == 0) \
+ __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{ame|addme} %0,%2" \
+ : "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\
+ else if (__builtin_constant_p (bh) && (bh) == ~(USItype) 0) \
+ __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{aze|addze} %0,%2" \
+ : "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\
+ else \
+ __asm__ ("{sf%I4|subf%I4c} %1,%5,%4\n\t{sfe|subfe} %0,%3,%2" \
+ : "=r" (sh), "=&r" (sl) \
+ : "r" (ah), "r" (bh), "rI" (al), "r" (bl)); \
+ } while (0)
+#define count_leading_zeros(count, x) \
+ __asm__ ("{cntlz|cntlzw} %0,%1" : "=r" (count) : "r" (x))
+#define COUNT_LEADING_ZEROS_0 32
+#if defined (_ARCH_PPC) || defined (__powerpc__) || defined (__POWERPC__) \
+ || defined (__ppc__) \
+ || (defined (PPC) && ! defined (CPU_FAMILY)) /* gcc 2.7.x GNU&SysV */ \
+ || (defined (PPC) && defined (CPU_FAMILY) /* VxWorks */ \
+ && CPU_FAMILY == PPC)
+#define umul_ppmm(ph, pl, m0, m1) \
+ do { \
+ USItype __m0 = (m0), __m1 = (m1); \
+ __asm__ ("mulhwu %0,%1,%2" : "=r" (ph) : "%r" (m0), "r" (m1)); \
+ (pl) = __m0 * __m1; \
+ } while (0)
+#define UMUL_TIME 15
+#define smul_ppmm(ph, pl, m0, m1) \
+ do { \
+ SItype __m0 = (m0), __m1 = (m1); \
+ __asm__ ("mulhw %0,%1,%2" : "=r" (ph) : "%r" (m0), "r" (m1)); \
+ (pl) = __m0 * __m1; \
+ } while (0)
+#define SMUL_TIME 14
+#define UDIV_TIME 120
+#elif defined (_ARCH_PWR)
+#define UMUL_TIME 8
+#define smul_ppmm(xh, xl, m0, m1) \
+ __asm__ ("mul %0,%2,%3" : "=r" (xh), "=q" (xl) : "r" (m0), "r" (m1))
+#define SMUL_TIME 4
+#define sdiv_qrnnd(q, r, nh, nl, d) \
+ __asm__ ("div %0,%2,%4" : "=r" (q), "=q" (r) : "r" (nh), "1" (nl), "r" (d))
+#define UDIV_TIME 100
+#endif
+#endif /* 32-bit POWER architecture variants. */
+
+/* We should test _IBMR2 here when we add assembly support for the system
+ vendor compilers. */
+#if (defined (_ARCH_PPC64) || defined (__powerpc64__)) && W_TYPE_SIZE == 64
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ do { \
+ if (__builtin_constant_p (bh) && (bh) == 0) \
+ __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{aze|addze} %0,%2" \
+ : "=r" (sh), "=&r" (sl) : "r" (ah), "%r" (al), "rI" (bl));\
+ else if (__builtin_constant_p (bh) && (bh) == ~(UDItype) 0) \
+ __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{ame|addme} %0,%2" \
+ : "=r" (sh), "=&r" (sl) : "r" (ah), "%r" (al), "rI" (bl));\
+ else \
+ __asm__ ("{a%I5|add%I5c} %1,%4,%5\n\t{ae|adde} %0,%2,%3" \
+ : "=r" (sh), "=&r" (sl) \
+ : "%r" (ah), "r" (bh), "%r" (al), "rI" (bl)); \
+ } while (0)
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ do { \
+ if (__builtin_constant_p (ah) && (ah) == 0) \
+ __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfze|subfze} %0,%2" \
+ : "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\
+ else if (__builtin_constant_p (ah) && (ah) == ~(UDItype) 0) \
+ __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfme|subfme} %0,%2" \
+ : "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\
+ else if (__builtin_constant_p (bh) && (bh) == 0) \
+ __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{ame|addme} %0,%2" \
+ : "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\
+ else if (__builtin_constant_p (bh) && (bh) == ~(UDItype) 0) \
+ __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{aze|addze} %0,%2" \
+ : "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\
+ else \
+ __asm__ ("{sf%I4|subf%I4c} %1,%5,%4\n\t{sfe|subfe} %0,%3,%2" \
+ : "=r" (sh), "=&r" (sl) \
+ : "r" (ah), "r" (bh), "rI" (al), "r" (bl)); \
+ } while (0)
+#define count_leading_zeros(count, x) \
+ __asm__ ("cntlzd %0,%1" : "=r" (count) : "r" (x))
+#define COUNT_LEADING_ZEROS_0 64
+#define umul_ppmm(ph, pl, m0, m1) \
+ do { \
+ UDItype __m0 = (m0), __m1 = (m1); \
+ __asm__ ("mulhdu %0,%1,%2" : "=r" (ph) : "%r" (m0), "r" (m1)); \
+ (pl) = __m0 * __m1; \
+ } while (0)
+#define UMUL_TIME 15
+#define smul_ppmm(ph, pl, m0, m1) \
+ do { \
+ DItype __m0 = (m0), __m1 = (m1); \
+ __asm__ ("mulhd %0,%1,%2" : "=r" (ph) : "%r" (m0), "r" (m1)); \
+ (pl) = __m0 * __m1; \
+ } while (0)
+#define SMUL_TIME 14 /* ??? */
+#define UDIV_TIME 120 /* ??? */
+#endif /* 64-bit PowerPC. */
+
+#if defined (__ibm032__) /* RT/ROMP */ && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("a %1,%5\n\tae %0,%3" \
+ : "=r" ((USItype) (sh)), \
+ "=&r" ((USItype) (sl)) \
+ : "%0" ((USItype) (ah)), \
+ "r" ((USItype) (bh)), \
+ "%1" ((USItype) (al)), \
+ "r" ((USItype) (bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("s %1,%5\n\tse %0,%3" \
+ : "=r" ((USItype) (sh)), \
+ "=&r" ((USItype) (sl)) \
+ : "0" ((USItype) (ah)), \
+ "r" ((USItype) (bh)), \
+ "1" ((USItype) (al)), \
+ "r" ((USItype) (bl)))
+#define umul_ppmm(ph, pl, m0, m1) \
+ do { \
+ USItype __m0 = (m0), __m1 = (m1); \
+ __asm__ ( \
+ "s r2,r2\n" \
+" mts r10,%2\n" \
+" m r2,%3\n" \
+" m r2,%3\n" \
+" m r2,%3\n" \
+" m r2,%3\n" \
+" m r2,%3\n" \
+" m r2,%3\n" \
+" m r2,%3\n" \
+" m r2,%3\n" \
+" m r2,%3\n" \
+" m r2,%3\n" \
+" m r2,%3\n" \
+" m r2,%3\n" \
+" m r2,%3\n" \
+" m r2,%3\n" \
+" m r2,%3\n" \
+" m r2,%3\n" \
+" cas %0,r2,r0\n" \
+" mfs r10,%1" \
+ : "=r" ((USItype) (ph)), \
+ "=r" ((USItype) (pl)) \
+ : "%r" (__m0), \
+ "r" (__m1) \
+ : "r2"); \
+ (ph) += ((((SItype) __m0 >> 31) & __m1) \
+ + (((SItype) __m1 >> 31) & __m0)); \
+ } while (0)
+#define UMUL_TIME 20
+#define UDIV_TIME 200
+#define count_leading_zeros(count, x) \
+ do { \
+ if ((x) >= 0x10000) \
+ __asm__ ("clz %0,%1" \
+ : "=r" ((USItype) (count)) \
+ : "r" ((USItype) (x) >> 16)); \
+ else \
+ { \
+ __asm__ ("clz %0,%1" \
+ : "=r" ((USItype) (count)) \
+ : "r" ((USItype) (x))); \
+ (count) += 16; \
+ } \
+ } while (0)
+#endif
+
+#if defined(__sh__) && !__SHMEDIA__ && W_TYPE_SIZE == 32
+#ifndef __sh1__
+#define umul_ppmm(w1, w0, u, v) \
+ __asm__ ( \
+ "dmulu.l %2,%3\n\tsts%M1 macl,%1\n\tsts%M0 mach,%0" \
+ : "=r<" ((USItype)(w1)), \
+ "=r<" ((USItype)(w0)) \
+ : "r" ((USItype)(u)), \
+ "r" ((USItype)(v)) \
+ : "macl", "mach")
+#define UMUL_TIME 5
+#endif
+
+/* This is the same algorithm as __udiv_qrnnd_c. */
+#define UDIV_NEEDS_NORMALIZATION 1
+
+#define udiv_qrnnd(q, r, n1, n0, d) \
+ do { \
+ extern UWtype __udiv_qrnnd_16 (UWtype, UWtype) \
+ __attribute__ ((visibility ("hidden"))); \
+ /* r0: rn r1: qn */ /* r0: n1 r4: n0 r5: d r6: d1 */ /* r2: __m */ \
+ __asm__ ( \
+ "mov%M4 %4,r5\n" \
+" swap.w %3,r4\n" \
+" swap.w r5,r6\n" \
+" jsr @%5\n" \
+" shll16 r6\n" \
+" swap.w r4,r4\n" \
+" jsr @%5\n" \
+" swap.w r1,%0\n" \
+" or r1,%0" \
+ : "=r" (q), "=&z" (r) \
+ : "1" (n1), "r" (n0), "rm" (d), "r" (&__udiv_qrnnd_16) \
+ : "r1", "r2", "r4", "r5", "r6", "pr"); \
+ } while (0)
+
+#define UDIV_TIME 80
+
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("clrt;subc %5,%1; subc %4,%0" \
+ : "=r" (sh), "=r" (sl) \
+ : "0" (ah), "1" (al), "r" (bh), "r" (bl))
+
+#endif /* __sh__ */
+
+#if defined (__SH5__) && __SHMEDIA__ && W_TYPE_SIZE == 32
+#define __umulsidi3(u,v) ((UDItype)(USItype)u*(USItype)v)
+#define count_leading_zeros(count, x) \
+ do \
+ { \
+ UDItype x_ = (USItype)(x); \
+ SItype c_; \
+ \
+ __asm__ ("nsb %1, %0" : "=r" (c_) : "r" (x_)); \
+ (count) = c_ - 31; \
+ } \
+ while (0)
+#define COUNT_LEADING_ZEROS_0 32
+#endif
+
+#if defined (__sparc__) && !defined (__arch64__) && !defined (__sparcv9) \
+ && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("addcc %r4,%5,%1\n\taddx %r2,%3,%0" \
+ : "=r" ((USItype) (sh)), \
+ "=&r" ((USItype) (sl)) \
+ : "%rJ" ((USItype) (ah)), \
+ "rI" ((USItype) (bh)), \
+ "%rJ" ((USItype) (al)), \
+ "rI" ((USItype) (bl)) \
+ __CLOBBER_CC)
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("subcc %r4,%5,%1\n\tsubx %r2,%3,%0" \
+ : "=r" ((USItype) (sh)), \
+ "=&r" ((USItype) (sl)) \
+ : "rJ" ((USItype) (ah)), \
+ "rI" ((USItype) (bh)), \
+ "rJ" ((USItype) (al)), \
+ "rI" ((USItype) (bl)) \
+ __CLOBBER_CC)
+#if defined (__sparc_v8__)
+#define umul_ppmm(w1, w0, u, v) \
+ __asm__ ("umul %2,%3,%1;rd %%y,%0" \
+ : "=r" ((USItype) (w1)), \
+ "=r" ((USItype) (w0)) \
+ : "r" ((USItype) (u)), \
+ "r" ((USItype) (v)))
+#define udiv_qrnnd(__q, __r, __n1, __n0, __d) \
+ __asm__ ("mov %2,%%y;nop;nop;nop;udiv %3,%4,%0;umul %0,%4,%1;sub %3,%1,%1"\
+ : "=&r" ((USItype) (__q)), \
+ "=&r" ((USItype) (__r)) \
+ : "r" ((USItype) (__n1)), \
+ "r" ((USItype) (__n0)), \
+ "r" ((USItype) (__d)))
+#else
+#if defined (__sparclite__)
+/* This has hardware multiply but not divide. It also has two additional
+ instructions scan (ffs from high bit) and divscc. */
+#define umul_ppmm(w1, w0, u, v) \
+ __asm__ ("umul %2,%3,%1;rd %%y,%0" \
+ : "=r" ((USItype) (w1)), \
+ "=r" ((USItype) (w0)) \
+ : "r" ((USItype) (u)), \
+ "r" ((USItype) (v)))
+#define udiv_qrnnd(q, r, n1, n0, d) \
+ __asm__ ("! Inlined udiv_qrnnd\n" \
+" wr %%g0,%2,%%y ! Not a delayed write for sparclite\n" \
+" tst %%g0\n" \
+" divscc %3,%4,%%g1\n" \
+" divscc %%g1,%4,%%g1\n" \
+" divscc %%g1,%4,%%g1\n" \
+" divscc %%g1,%4,%%g1\n" \
+" divscc %%g1,%4,%%g1\n" \
+" divscc %%g1,%4,%%g1\n" \
+" divscc %%g1,%4,%%g1\n" \
+" divscc %%g1,%4,%%g1\n" \
+" divscc %%g1,%4,%%g1\n" \
+" divscc %%g1,%4,%%g1\n" \
+" divscc %%g1,%4,%%g1\n" \
+" divscc %%g1,%4,%%g1\n" \
+" divscc %%g1,%4,%%g1\n" \
+" divscc %%g1,%4,%%g1\n" \
+" divscc %%g1,%4,%%g1\n" \
+" divscc %%g1,%4,%%g1\n" \
+" divscc %%g1,%4,%%g1\n" \
+" divscc %%g1,%4,%%g1\n" \
+" divscc %%g1,%4,%%g1\n" \
+" divscc %%g1,%4,%%g1\n" \
+" divscc %%g1,%4,%%g1\n" \
+" divscc %%g1,%4,%%g1\n" \
+" divscc %%g1,%4,%%g1\n" \
+" divscc %%g1,%4,%%g1\n" \
+" divscc %%g1,%4,%%g1\n" \
+" divscc %%g1,%4,%%g1\n" \
+" divscc %%g1,%4,%%g1\n" \
+" divscc %%g1,%4,%%g1\n" \
+" divscc %%g1,%4,%%g1\n" \
+" divscc %%g1,%4,%%g1\n" \
+" divscc %%g1,%4,%%g1\n" \
+" divscc %%g1,%4,%0\n" \
+" rd %%y,%1\n" \
+" bl,a 1f\n" \
+" add %1,%4,%1\n" \
+"1: ! End of inline udiv_qrnnd" \
+ : "=r" ((USItype) (q)), \
+ "=r" ((USItype) (r)) \
+ : "r" ((USItype) (n1)), \
+ "r" ((USItype) (n0)), \
+ "rI" ((USItype) (d)) \
+ : "g1" __AND_CLOBBER_CC)
+#define UDIV_TIME 37
+#define count_leading_zeros(count, x) \
+ do { \
+ __asm__ ("scan %1,1,%0" \
+ : "=r" ((USItype) (count)) \
+ : "r" ((USItype) (x))); \
+ } while (0)
+/* Early sparclites return 63 for an argument of 0, but they warn that future
+ implementations might change this. Therefore, leave COUNT_LEADING_ZEROS_0
+ undefined. */
+#else
+/* SPARC without integer multiplication and divide instructions.
+ (i.e. at least Sun4/20,40,60,65,75,110,260,280,330,360,380,470,490) */
+#define umul_ppmm(w1, w0, u, v) \
+ __asm__ ("! Inlined umul_ppmm\n" \
+" wr %%g0,%2,%%y ! SPARC has 0-3 delay insn after a wr\n"\
+" sra %3,31,%%o5 ! Don't move this insn\n" \
+" and %2,%%o5,%%o5 ! Don't move this insn\n" \
+" andcc %%g0,0,%%g1 ! Don't move this insn\n" \
+" mulscc %%g1,%3,%%g1\n" \
+" mulscc %%g1,%3,%%g1\n" \
+" mulscc %%g1,%3,%%g1\n" \
+" mulscc %%g1,%3,%%g1\n" \
+" mulscc %%g1,%3,%%g1\n" \
+" mulscc %%g1,%3,%%g1\n" \
+" mulscc %%g1,%3,%%g1\n" \
+" mulscc %%g1,%3,%%g1\n" \
+" mulscc %%g1,%3,%%g1\n" \
+" mulscc %%g1,%3,%%g1\n" \
+" mulscc %%g1,%3,%%g1\n" \
+" mulscc %%g1,%3,%%g1\n" \
+" mulscc %%g1,%3,%%g1\n" \
+" mulscc %%g1,%3,%%g1\n" \
+" mulscc %%g1,%3,%%g1\n" \
+" mulscc %%g1,%3,%%g1\n" \
+" mulscc %%g1,%3,%%g1\n" \
+" mulscc %%g1,%3,%%g1\n" \
+" mulscc %%g1,%3,%%g1\n" \
+" mulscc %%g1,%3,%%g1\n" \
+" mulscc %%g1,%3,%%g1\n" \
+" mulscc %%g1,%3,%%g1\n" \
+" mulscc %%g1,%3,%%g1\n" \
+" mulscc %%g1,%3,%%g1\n" \
+" mulscc %%g1,%3,%%g1\n" \
+" mulscc %%g1,%3,%%g1\n" \
+" mulscc %%g1,%3,%%g1\n" \
+" mulscc %%g1,%3,%%g1\n" \
+" mulscc %%g1,%3,%%g1\n" \
+" mulscc %%g1,%3,%%g1\n" \
+" mulscc %%g1,%3,%%g1\n" \
+" mulscc %%g1,%3,%%g1\n" \
+" mulscc %%g1,0,%%g1\n" \
+" add %%g1,%%o5,%0\n" \
+" rd %%y,%1" \
+ : "=r" ((USItype) (w1)), \
+ "=r" ((USItype) (w0)) \
+ : "%rI" ((USItype) (u)), \
+ "r" ((USItype) (v)) \
+ : "g1", "o5" __AND_CLOBBER_CC)
+#define UMUL_TIME 39 /* 39 instructions */
+/* It's quite necessary to add this much assembler for the sparc.
+ The default udiv_qrnnd (in C) is more than 10 times slower! */
+#define udiv_qrnnd(__q, __r, __n1, __n0, __d) \
+ __asm__ ("! Inlined udiv_qrnnd\n" \
+" mov 32,%%g1\n" \
+" subcc %1,%2,%%g0\n" \
+"1: bcs 5f\n" \
+" addxcc %0,%0,%0 ! shift n1n0 and a q-bit in lsb\n" \
+" sub %1,%2,%1 ! this kills msb of n\n" \
+" addx %1,%1,%1 ! so this can't give carry\n" \
+" subcc %%g1,1,%%g1\n" \
+"2: bne 1b\n" \
+" subcc %1,%2,%%g0\n" \
+" bcs 3f\n" \
+" addxcc %0,%0,%0 ! shift n1n0 and a q-bit in lsb\n" \
+" b 3f\n" \
+" sub %1,%2,%1 ! this kills msb of n\n" \
+"4: sub %1,%2,%1\n" \
+"5: addxcc %1,%1,%1\n" \
+" bcc 2b\n" \
+" subcc %%g1,1,%%g1\n" \
+"! Got carry from n. Subtract next step to cancel this carry.\n" \
+" bne 4b\n" \
+" addcc %0,%0,%0 ! shift n1n0 and a 0-bit in lsb\n" \
+" sub %1,%2,%1\n" \
+"3: xnor %0,0,%0\n" \
+" ! End of inline udiv_qrnnd" \
+ : "=&r" ((USItype) (__q)), \
+ "=&r" ((USItype) (__r)) \
+ : "r" ((USItype) (__d)), \
+ "1" ((USItype) (__n1)), \
+ "0" ((USItype) (__n0)) : "g1" __AND_CLOBBER_CC)
+#define UDIV_TIME (3+7*32) /* 7 instructions/iteration. 32 iterations. */
+#endif /* __sparclite__ */
+#endif /* __sparc_v8__ */
+#endif /* sparc32 */
+
+#if ((defined (__sparc__) && defined (__arch64__)) || defined (__sparcv9)) \
+ && W_TYPE_SIZE == 64
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("addcc %r4,%5,%1\n\t" \
+ "add %r2,%3,%0\n\t" \
+ "bcs,a,pn %%xcc, 1f\n\t" \
+ "add %0, 1, %0\n" \
+ "1:" \
+ : "=r" ((UDItype)(sh)), \
+ "=&r" ((UDItype)(sl)) \
+ : "%rJ" ((UDItype)(ah)), \
+ "rI" ((UDItype)(bh)), \
+ "%rJ" ((UDItype)(al)), \
+ "rI" ((UDItype)(bl)) \
+ __CLOBBER_CC)
+
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("subcc %r4,%5,%1\n\t" \
+ "sub %r2,%3,%0\n\t" \
+ "bcs,a,pn %%xcc, 1f\n\t" \
+ "sub %0, 1, %0\n\t" \
+ "1:" \
+ : "=r" ((UDItype)(sh)), \
+ "=&r" ((UDItype)(sl)) \
+ : "rJ" ((UDItype)(ah)), \
+ "rI" ((UDItype)(bh)), \
+ "rJ" ((UDItype)(al)), \
+ "rI" ((UDItype)(bl)) \
+ __CLOBBER_CC)
+
+#define umul_ppmm(wh, wl, u, v) \
+ do { \
+ UDItype tmp1, tmp2, tmp3, tmp4; \
+ __asm__ __volatile__ ( \
+ "srl %7,0,%3\n\t" \
+ "mulx %3,%6,%1\n\t" \
+ "srlx %6,32,%2\n\t" \
+ "mulx %2,%3,%4\n\t" \
+ "sllx %4,32,%5\n\t" \
+ "srl %6,0,%3\n\t" \
+ "sub %1,%5,%5\n\t" \
+ "srlx %5,32,%5\n\t" \
+ "addcc %4,%5,%4\n\t" \
+ "srlx %7,32,%5\n\t" \
+ "mulx %3,%5,%3\n\t" \
+ "mulx %2,%5,%5\n\t" \
+ "sethi %%hi(0x80000000),%2\n\t" \
+ "addcc %4,%3,%4\n\t" \
+ "srlx %4,32,%4\n\t" \
+ "add %2,%2,%2\n\t" \
+ "movcc %%xcc,%%g0,%2\n\t" \
+ "addcc %5,%4,%5\n\t" \
+ "sllx %3,32,%3\n\t" \
+ "add %1,%3,%1\n\t" \
+ "add %5,%2,%0" \
+ : "=r" ((UDItype)(wh)), \
+ "=&r" ((UDItype)(wl)), \
+ "=&r" (tmp1), "=&r" (tmp2), "=&r" (tmp3), "=&r" (tmp4) \
+ : "r" ((UDItype)(u)), \
+ "r" ((UDItype)(v)) \
+ __CLOBBER_CC); \
+ } while (0)
+#define UMUL_TIME 96
+#define UDIV_TIME 230
+#endif /* sparc64 */
+
+#if defined (__xtensa__) && W_TYPE_SIZE == 32
+/* This code is not Xtensa-configuration-specific, so rely on the compiler
+ to expand builtin functions depending on what configuration features
+ are available. This avoids library calls when the operation can be
+ performed in-line. */
+#define umul_ppmm(w1, w0, u, v) \
+ do { \
+ DWunion __w; \
+ __w.ll = __builtin_umulsidi3 (u, v); \
+ w1 = __w.s.high; \
+ w0 = __w.s.low; \
+ } while (0)
+#define __umulsidi3(u, v) __builtin_umulsidi3 (u, v)
+#define count_leading_zeros(COUNT, X) ((COUNT) = __builtin_clz (X))
+#define count_trailing_zeros(COUNT, X) ((COUNT) = __builtin_ctz (X))
+#endif /* __xtensa__ */
+
+#if defined (__z8000__) && W_TYPE_SIZE == 16
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("add %H1,%H5\n\tadc %H0,%H3" \
+ : "=r" ((unsigned int)(sh)), \
+ "=&r" ((unsigned int)(sl)) \
+ : "%0" ((unsigned int)(ah)), \
+ "r" ((unsigned int)(bh)), \
+ "%1" ((unsigned int)(al)), \
+ "rQR" ((unsigned int)(bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("sub %H1,%H5\n\tsbc %H0,%H3" \
+ : "=r" ((unsigned int)(sh)), \
+ "=&r" ((unsigned int)(sl)) \
+ : "0" ((unsigned int)(ah)), \
+ "r" ((unsigned int)(bh)), \
+ "1" ((unsigned int)(al)), \
+ "rQR" ((unsigned int)(bl)))
+#define umul_ppmm(xh, xl, m0, m1) \
+ do { \
+ union {long int __ll; \
+ struct {unsigned int __h, __l;} __i; \
+ } __xx; \
+ unsigned int __m0 = (m0), __m1 = (m1); \
+ __asm__ ("mult %S0,%H3" \
+ : "=r" (__xx.__i.__h), \
+ "=r" (__xx.__i.__l) \
+ : "%1" (__m0), \
+ "rQR" (__m1)); \
+ (xh) = __xx.__i.__h; (xl) = __xx.__i.__l; \
+ (xh) += ((((signed int) __m0 >> 15) & __m1) \
+ + (((signed int) __m1 >> 15) & __m0)); \
+ } while (0)
+#endif /* __z8000__ */
+
+#endif /* __GNUC__ */
+
+/* If this machine has no inline assembler, use C macros. */
+
+#if !defined (add_ssaaaa)
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ do { \
+ UWtype __x; \
+ __x = (al) + (bl); \
+ (sh) = (ah) + (bh) + (__x < (al)); \
+ (sl) = __x; \
+ } while (0)
+#endif
+
+#if !defined (sub_ddmmss)
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ do { \
+ UWtype __x; \
+ __x = (al) - (bl); \
+ (sh) = (ah) - (bh) - (__x > (al)); \
+ (sl) = __x; \
+ } while (0)
+#endif
+
+/* If we lack umul_ppmm but have smul_ppmm, define umul_ppmm in terms of
+ smul_ppmm. */
+#if !defined (umul_ppmm) && defined (smul_ppmm)
+#define umul_ppmm(w1, w0, u, v) \
+ do { \
+ UWtype __w1; \
+ UWtype __xm0 = (u), __xm1 = (v); \
+ smul_ppmm (__w1, w0, __xm0, __xm1); \
+ (w1) = __w1 + (-(__xm0 >> (W_TYPE_SIZE - 1)) & __xm1) \
+ + (-(__xm1 >> (W_TYPE_SIZE - 1)) & __xm0); \
+ } while (0)
+#endif
+
+/* If we still don't have umul_ppmm, define it using plain C. */
+#if !defined (umul_ppmm)
+#define umul_ppmm(w1, w0, u, v) \
+ do { \
+ UWtype __x0, __x1, __x2, __x3; \
+ UHWtype __ul, __vl, __uh, __vh; \
+ \
+ __ul = __ll_lowpart (u); \
+ __uh = __ll_highpart (u); \
+ __vl = __ll_lowpart (v); \
+ __vh = __ll_highpart (v); \
+ \
+ __x0 = (UWtype) __ul * __vl; \
+ __x1 = (UWtype) __ul * __vh; \
+ __x2 = (UWtype) __uh * __vl; \
+ __x3 = (UWtype) __uh * __vh; \
+ \
+ __x1 += __ll_highpart (__x0);/* this can't give carry */ \
+ __x1 += __x2; /* but this indeed can */ \
+ if (__x1 < __x2) /* did we get it? */ \
+ __x3 += __ll_B; /* yes, add it in the proper pos. */ \
+ \
+ (w1) = __x3 + __ll_highpart (__x1); \
+ (w0) = __ll_lowpart (__x1) * __ll_B + __ll_lowpart (__x0); \
+ } while (0)
+#endif
+
+#if !defined (__umulsidi3)
+#define __umulsidi3(u, v) \
+ ({DWunion __w; \
+ umul_ppmm (__w.s.high, __w.s.low, u, v); \
+ __w.ll; })
+#endif
+
+/* Define this unconditionally, so it can be used for debugging. */
+#define __udiv_qrnnd_c(q, r, n1, n0, d) \
+ do { \
+ UWtype __d1, __d0, __q1, __q0; \
+ UWtype __r1, __r0, __m; \
+ __d1 = __ll_highpart (d); \
+ __d0 = __ll_lowpart (d); \
+ \
+ __r1 = (n1) % __d1; \
+ __q1 = (n1) / __d1; \
+ __m = (UWtype) __q1 * __d0; \
+ __r1 = __r1 * __ll_B | __ll_highpart (n0); \
+ if (__r1 < __m) \
+ { \
+ __q1--, __r1 += (d); \
+ if (__r1 >= (d)) /* i.e. we didn't get carry when adding to __r1 */\
+ if (__r1 < __m) \
+ __q1--, __r1 += (d); \
+ } \
+ __r1 -= __m; \
+ \
+ __r0 = __r1 % __d1; \
+ __q0 = __r1 / __d1; \
+ __m = (UWtype) __q0 * __d0; \
+ __r0 = __r0 * __ll_B | __ll_lowpart (n0); \
+ if (__r0 < __m) \
+ { \
+ __q0--, __r0 += (d); \
+ if (__r0 >= (d)) \
+ if (__r0 < __m) \
+ __q0--, __r0 += (d); \
+ } \
+ __r0 -= __m; \
+ \
+ (q) = (UWtype) __q1 * __ll_B | __q0; \
+ (r) = __r0; \
+ } while (0)
+
+/* If the processor has no udiv_qrnnd but sdiv_qrnnd, go through
+ __udiv_w_sdiv (defined in libgcc or elsewhere). */
+#if !defined (udiv_qrnnd) && defined (sdiv_qrnnd)
+#define udiv_qrnnd(q, r, nh, nl, d) \
+ do { \
+ USItype __r; \
+ (q) = __udiv_w_sdiv (&__r, nh, nl, d); \
+ (r) = __r; \
+ } while (0)
+#endif
+
+/* If udiv_qrnnd was not defined for this processor, use __udiv_qrnnd_c. */
+#if !defined (udiv_qrnnd)
+#define UDIV_NEEDS_NORMALIZATION 1
+#define udiv_qrnnd __udiv_qrnnd_c
+#endif
+
+#if !defined (count_leading_zeros)
+#define count_leading_zeros(count, x) \
+ do { \
+ UWtype __xr = (x); \
+ UWtype __a; \
+ \
+ if (W_TYPE_SIZE <= 32) \
+ { \
+ __a = __xr < ((UWtype)1<<2*__BITS4) \
+ ? (__xr < ((UWtype)1<<__BITS4) ? 0 : __BITS4) \
+ : (__xr < ((UWtype)1<<3*__BITS4) ? 2*__BITS4 : 3*__BITS4); \
+ } \
+ else \
+ { \
+ for (__a = W_TYPE_SIZE - 8; __a > 0; __a -= 8) \
+ if (((__xr >> __a) & 0xff) != 0) \
+ break; \
+ } \
+ \
+ (count) = W_TYPE_SIZE - (__clz_tab[__xr >> __a] + __a); \
+ } while (0)
+#define COUNT_LEADING_ZEROS_0 W_TYPE_SIZE
+#endif
+
+#if !defined (count_trailing_zeros)
+/* Define count_trailing_zeros using count_leading_zeros. The latter might be
+ defined in asm, but if it is not, the C version above is good enough. */
+#define count_trailing_zeros(count, x) \
+ do { \
+ UWtype __ctz_x = (x); \
+ UWtype __ctz_c; \
+ count_leading_zeros (__ctz_c, __ctz_x & -__ctz_x); \
+ (count) = W_TYPE_SIZE - 1 - __ctz_c; \
+ } while (0)
+#endif
+
+#ifndef UDIV_NEEDS_NORMALIZATION
+#define UDIV_NEEDS_NORMALIZATION 0
+#endif
diff --git a/libc/sysdeps/linux/sparc/soft-fp/mp_clz_tab.c b/libc/sysdeps/linux/sparc/soft-fp/mp_clz_tab.c
new file mode 100644
index 000000000..14052a108
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/mp_clz_tab.c
@@ -0,0 +1,36 @@
+/* __clz_tab -- support for longlong.h
+ Copyright (C) 1991, 1993, 1994, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library. Its master source is NOT part of
+ the C library, however. The master source lives in the GNU MP 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#if 0
+#include <gmp.h>
+#include "gmp-impl.h"
+#endif
+
+const
+unsigned char __clz_tab[] =
+{
+ 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
+ 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+};
diff --git a/libc/sysdeps/linux/sparc/soft-fp/op-1.h b/libc/sysdeps/linux/sparc/soft-fp/op-1.h
new file mode 100644
index 000000000..2cffb7fb3
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/op-1.h
@@ -0,0 +1,301 @@
+/* Software floating-point emulation.
+ Basic one-word fraction declaration and manipulation.
+ Copyright (C) 1997,1998,1999,2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com),
+ Jakub Jelinek (jj@ultra.linux.cz),
+ David S. Miller (davem@redhat.com) and
+ Peter Maydell (pmaydell@chiark.greenend.org.uk).
+
+ 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 into
+ combinations with other programs, and to distribute those
+ combinations without any restriction coming from the use of this
+ file. (The Lesser General Public License restrictions do apply in
+ other respects; for example, they cover modification of the file,
+ and distribution when not linked into a combine executable.)
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#define _FP_FRAC_DECL_1(X) _FP_W_TYPE X##_f
+#define _FP_FRAC_COPY_1(D,S) (D##_f = S##_f)
+#define _FP_FRAC_SET_1(X,I) (X##_f = I)
+#define _FP_FRAC_HIGH_1(X) (X##_f)
+#define _FP_FRAC_LOW_1(X) (X##_f)
+#define _FP_FRAC_WORD_1(X,w) (X##_f)
+
+#define _FP_FRAC_ADDI_1(X,I) (X##_f += I)
+#define _FP_FRAC_SLL_1(X,N) \
+ do { \
+ if (__builtin_constant_p(N) && (N) == 1) \
+ X##_f += X##_f; \
+ else \
+ X##_f <<= (N); \
+ } while (0)
+#define _FP_FRAC_SRL_1(X,N) (X##_f >>= N)
+
+/* Right shift with sticky-lsb. */
+#define _FP_FRAC_SRST_1(X,S,N,sz) __FP_FRAC_SRST_1(X##_f, S, N, sz)
+#define _FP_FRAC_SRS_1(X,N,sz) __FP_FRAC_SRS_1(X##_f, N, sz)
+
+#define __FP_FRAC_SRST_1(X,S,N,sz) \
+do { \
+ S = (__builtin_constant_p(N) && (N) == 1 \
+ ? X & 1 : (X << (_FP_W_TYPE_SIZE - (N))) != 0); \
+ X = X >> (N); \
+} while (0)
+
+#define __FP_FRAC_SRS_1(X,N,sz) \
+ (X = (X >> (N) | (__builtin_constant_p(N) && (N) == 1 \
+ ? X & 1 : (X << (_FP_W_TYPE_SIZE - (N))) != 0)))
+
+#define _FP_FRAC_ADD_1(R,X,Y) (R##_f = X##_f + Y##_f)
+#define _FP_FRAC_SUB_1(R,X,Y) (R##_f = X##_f - Y##_f)
+#define _FP_FRAC_DEC_1(X,Y) (X##_f -= Y##_f)
+#define _FP_FRAC_CLZ_1(z, X) __FP_CLZ(z, X##_f)
+
+/* Predicates */
+#define _FP_FRAC_NEGP_1(X) ((_FP_WS_TYPE)X##_f < 0)
+#define _FP_FRAC_ZEROP_1(X) (X##_f == 0)
+#define _FP_FRAC_OVERP_1(fs,X) (X##_f & _FP_OVERFLOW_##fs)
+#define _FP_FRAC_CLEAR_OVERP_1(fs,X) (X##_f &= ~_FP_OVERFLOW_##fs)
+#define _FP_FRAC_EQ_1(X, Y) (X##_f == Y##_f)
+#define _FP_FRAC_GE_1(X, Y) (X##_f >= Y##_f)
+#define _FP_FRAC_GT_1(X, Y) (X##_f > Y##_f)
+
+#define _FP_ZEROFRAC_1 0
+#define _FP_MINFRAC_1 1
+#define _FP_MAXFRAC_1 (~(_FP_WS_TYPE)0)
+
+/*
+ * Unpack the raw bits of a native fp value. Do not classify or
+ * normalize the data.
+ */
+
+#define _FP_UNPACK_RAW_1(fs, X, val) \
+ do { \
+ union _FP_UNION_##fs _flo; _flo.flt = (val); \
+ \
+ X##_f = _flo.bits.frac; \
+ X##_e = _flo.bits.exp; \
+ X##_s = _flo.bits.sign; \
+ } while (0)
+
+#define _FP_UNPACK_RAW_1_P(fs, X, val) \
+ do { \
+ union _FP_UNION_##fs *_flo = \
+ (union _FP_UNION_##fs *)(val); \
+ \
+ X##_f = _flo->bits.frac; \
+ X##_e = _flo->bits.exp; \
+ X##_s = _flo->bits.sign; \
+ } while (0)
+
+/*
+ * Repack the raw bits of a native fp value.
+ */
+
+#define _FP_PACK_RAW_1(fs, val, X) \
+ do { \
+ union _FP_UNION_##fs _flo; \
+ \
+ _flo.bits.frac = X##_f; \
+ _flo.bits.exp = X##_e; \
+ _flo.bits.sign = X##_s; \
+ \
+ (val) = _flo.flt; \
+ } while (0)
+
+#define _FP_PACK_RAW_1_P(fs, val, X) \
+ do { \
+ union _FP_UNION_##fs *_flo = \
+ (union _FP_UNION_##fs *)(val); \
+ \
+ _flo->bits.frac = X##_f; \
+ _flo->bits.exp = X##_e; \
+ _flo->bits.sign = X##_s; \
+ } while (0)
+
+
+/*
+ * Multiplication algorithms:
+ */
+
+/* Basic. Assuming the host word size is >= 2*FRACBITS, we can do the
+ multiplication immediately. */
+
+#define _FP_MUL_MEAT_1_imm(wfracbits, R, X, Y) \
+ do { \
+ R##_f = X##_f * Y##_f; \
+ /* Normalize since we know where the msb of the multiplicands \
+ were (bit B), we know that the msb of the of the product is \
+ at either 2B or 2B-1. */ \
+ _FP_FRAC_SRS_1(R, wfracbits-1, 2*wfracbits); \
+ } while (0)
+
+/* Given a 1W * 1W => 2W primitive, do the extended multiplication. */
+
+#define _FP_MUL_MEAT_1_wide(wfracbits, R, X, Y, doit) \
+ do { \
+ _FP_W_TYPE _Z_f0, _Z_f1; \
+ doit(_Z_f1, _Z_f0, X##_f, Y##_f); \
+ /* Normalize since we know where the msb of the multiplicands \
+ were (bit B), we know that the msb of the of the product is \
+ at either 2B or 2B-1. */ \
+ _FP_FRAC_SRS_2(_Z, wfracbits-1, 2*wfracbits); \
+ R##_f = _Z_f0; \
+ } while (0)
+
+/* Finally, a simple widening multiply algorithm. What fun! */
+
+#define _FP_MUL_MEAT_1_hard(wfracbits, R, X, Y) \
+ do { \
+ _FP_W_TYPE _xh, _xl, _yh, _yl, _z_f0, _z_f1, _a_f0, _a_f1; \
+ \
+ /* split the words in half */ \
+ _xh = X##_f >> (_FP_W_TYPE_SIZE/2); \
+ _xl = X##_f & (((_FP_W_TYPE)1 << (_FP_W_TYPE_SIZE/2)) - 1); \
+ _yh = Y##_f >> (_FP_W_TYPE_SIZE/2); \
+ _yl = Y##_f & (((_FP_W_TYPE)1 << (_FP_W_TYPE_SIZE/2)) - 1); \
+ \
+ /* multiply the pieces */ \
+ _z_f0 = _xl * _yl; \
+ _a_f0 = _xh * _yl; \
+ _a_f1 = _xl * _yh; \
+ _z_f1 = _xh * _yh; \
+ \
+ /* reassemble into two full words */ \
+ if ((_a_f0 += _a_f1) < _a_f1) \
+ _z_f1 += (_FP_W_TYPE)1 << (_FP_W_TYPE_SIZE/2); \
+ _a_f1 = _a_f0 >> (_FP_W_TYPE_SIZE/2); \
+ _a_f0 = _a_f0 << (_FP_W_TYPE_SIZE/2); \
+ _FP_FRAC_ADD_2(_z, _z, _a); \
+ \
+ /* normalize */ \
+ _FP_FRAC_SRS_2(_z, wfracbits - 1, 2*wfracbits); \
+ R##_f = _z_f0; \
+ } while (0)
+
+
+/*
+ * Division algorithms:
+ */
+
+/* Basic. Assuming the host word size is >= 2*FRACBITS, we can do the
+ division immediately. Give this macro either _FP_DIV_HELP_imm for
+ C primitives or _FP_DIV_HELP_ldiv for the ISO function. Which you
+ choose will depend on what the compiler does with divrem4. */
+
+#define _FP_DIV_MEAT_1_imm(fs, R, X, Y, doit) \
+ do { \
+ _FP_W_TYPE _q, _r; \
+ X##_f <<= (X##_f < Y##_f \
+ ? R##_e--, _FP_WFRACBITS_##fs \
+ : _FP_WFRACBITS_##fs - 1); \
+ doit(_q, _r, X##_f, Y##_f); \
+ R##_f = _q | (_r != 0); \
+ } while (0)
+
+/* GCC's longlong.h defines a 2W / 1W => (1W,1W) primitive udiv_qrnnd
+ that may be useful in this situation. This first is for a primitive
+ that requires normalization, the second for one that does not. Look
+ for UDIV_NEEDS_NORMALIZATION to tell which your machine needs. */
+
+#define _FP_DIV_MEAT_1_udiv_norm(fs, R, X, Y) \
+ do { \
+ _FP_W_TYPE _nh, _nl, _q, _r, _y; \
+ \
+ /* Normalize Y -- i.e. make the most significant bit set. */ \
+ _y = Y##_f << _FP_WFRACXBITS_##fs; \
+ \
+ /* Shift X op correspondingly high, that is, up one full word. */ \
+ if (X##_f < Y##_f) \
+ { \
+ R##_e--; \
+ _nl = 0; \
+ _nh = X##_f; \
+ } \
+ else \
+ { \
+ _nl = X##_f << (_FP_W_TYPE_SIZE - 1); \
+ _nh = X##_f >> 1; \
+ } \
+ \
+ udiv_qrnnd(_q, _r, _nh, _nl, _y); \
+ R##_f = _q | (_r != 0); \
+ } while (0)
+
+#define _FP_DIV_MEAT_1_udiv(fs, R, X, Y) \
+ do { \
+ _FP_W_TYPE _nh, _nl, _q, _r; \
+ if (X##_f < Y##_f) \
+ { \
+ R##_e--; \
+ _nl = X##_f << _FP_WFRACBITS_##fs; \
+ _nh = X##_f >> _FP_WFRACXBITS_##fs; \
+ } \
+ else \
+ { \
+ _nl = X##_f << (_FP_WFRACBITS_##fs - 1); \
+ _nh = X##_f >> (_FP_WFRACXBITS_##fs + 1); \
+ } \
+ udiv_qrnnd(_q, _r, _nh, _nl, Y##_f); \
+ R##_f = _q | (_r != 0); \
+ } while (0)
+
+
+/*
+ * Square root algorithms:
+ * We have just one right now, maybe Newton approximation
+ * should be added for those machines where division is fast.
+ */
+
+#define _FP_SQRT_MEAT_1(R, S, T, X, q) \
+ do { \
+ while (q != _FP_WORK_ROUND) \
+ { \
+ T##_f = S##_f + q; \
+ if (T##_f <= X##_f) \
+ { \
+ S##_f = T##_f + q; \
+ X##_f -= T##_f; \
+ R##_f += q; \
+ } \
+ _FP_FRAC_SLL_1(X, 1); \
+ q >>= 1; \
+ } \
+ if (X##_f) \
+ { \
+ if (S##_f < X##_f) \
+ R##_f |= _FP_WORK_ROUND; \
+ R##_f |= _FP_WORK_STICKY; \
+ } \
+ } while (0)
+
+/*
+ * Assembly/disassembly for converting to/from integral types.
+ * No shifting or overflow handled here.
+ */
+
+#define _FP_FRAC_ASSEMBLE_1(r, X, rsize) (r = X##_f)
+#define _FP_FRAC_DISASSEMBLE_1(X, r, rsize) (X##_f = r)
+
+
+/*
+ * Convert FP values between word sizes
+ */
+
+#define _FP_FRAC_COPY_1_1(D, S) (D##_f = S##_f)
diff --git a/libc/sysdeps/linux/sparc/soft-fp/op-2.h b/libc/sysdeps/linux/sparc/soft-fp/op-2.h
new file mode 100644
index 000000000..7c7a95836
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/op-2.h
@@ -0,0 +1,616 @@
+/* Software floating-point emulation.
+ Basic two-word fraction declaration and manipulation.
+ Copyright (C) 1997,1998,1999,2006,2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com),
+ Jakub Jelinek (jj@ultra.linux.cz),
+ David S. Miller (davem@redhat.com) and
+ Peter Maydell (pmaydell@chiark.greenend.org.uk).
+
+ 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 into
+ combinations with other programs, and to distribute those
+ combinations without any restriction coming from the use of this
+ file. (The Lesser General Public License restrictions do apply in
+ other respects; for example, they cover modification of the file,
+ and distribution when not linked into a combine executable.)
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#define _FP_FRAC_DECL_2(X) _FP_W_TYPE X##_f0, X##_f1
+#define _FP_FRAC_COPY_2(D,S) (D##_f0 = S##_f0, D##_f1 = S##_f1)
+#define _FP_FRAC_SET_2(X,I) __FP_FRAC_SET_2(X, I)
+#define _FP_FRAC_HIGH_2(X) (X##_f1)
+#define _FP_FRAC_LOW_2(X) (X##_f0)
+#define _FP_FRAC_WORD_2(X,w) (X##_f##w)
+
+#define _FP_FRAC_SLL_2(X,N) \
+(void)(((N) < _FP_W_TYPE_SIZE) \
+ ? ({ \
+ if (__builtin_constant_p(N) && (N) == 1) \
+ { \
+ X##_f1 = X##_f1 + X##_f1 + (((_FP_WS_TYPE)(X##_f0)) < 0); \
+ X##_f0 += X##_f0; \
+ } \
+ else \
+ { \
+ X##_f1 = X##_f1 << (N) | X##_f0 >> (_FP_W_TYPE_SIZE - (N)); \
+ X##_f0 <<= (N); \
+ } \
+ 0; \
+ }) \
+ : ({ \
+ X##_f1 = X##_f0 << ((N) - _FP_W_TYPE_SIZE); \
+ X##_f0 = 0; \
+ }))
+
+
+#define _FP_FRAC_SRL_2(X,N) \
+(void)(((N) < _FP_W_TYPE_SIZE) \
+ ? ({ \
+ X##_f0 = X##_f0 >> (N) | X##_f1 << (_FP_W_TYPE_SIZE - (N)); \
+ X##_f1 >>= (N); \
+ }) \
+ : ({ \
+ X##_f0 = X##_f1 >> ((N) - _FP_W_TYPE_SIZE); \
+ X##_f1 = 0; \
+ }))
+
+/* Right shift with sticky-lsb. */
+#define _FP_FRAC_SRST_2(X,S, N,sz) \
+(void)(((N) < _FP_W_TYPE_SIZE) \
+ ? ({ \
+ S = (__builtin_constant_p(N) && (N) == 1 \
+ ? X##_f0 & 1 \
+ : (X##_f0 << (_FP_W_TYPE_SIZE - (N))) != 0); \
+ X##_f0 = (X##_f1 << (_FP_W_TYPE_SIZE - (N)) | X##_f0 >> (N)); \
+ X##_f1 >>= (N); \
+ }) \
+ : ({ \
+ S = ((((N) == _FP_W_TYPE_SIZE \
+ ? 0 \
+ : (X##_f1 << (2*_FP_W_TYPE_SIZE - (N)))) \
+ | X##_f0) != 0); \
+ X##_f0 = (X##_f1 >> ((N) - _FP_W_TYPE_SIZE)); \
+ X##_f1 = 0; \
+ }))
+
+#define _FP_FRAC_SRS_2(X,N,sz) \
+(void)(((N) < _FP_W_TYPE_SIZE) \
+ ? ({ \
+ X##_f0 = (X##_f1 << (_FP_W_TYPE_SIZE - (N)) | X##_f0 >> (N) | \
+ (__builtin_constant_p(N) && (N) == 1 \
+ ? X##_f0 & 1 \
+ : (X##_f0 << (_FP_W_TYPE_SIZE - (N))) != 0)); \
+ X##_f1 >>= (N); \
+ }) \
+ : ({ \
+ X##_f0 = (X##_f1 >> ((N) - _FP_W_TYPE_SIZE) | \
+ ((((N) == _FP_W_TYPE_SIZE \
+ ? 0 \
+ : (X##_f1 << (2*_FP_W_TYPE_SIZE - (N)))) \
+ | X##_f0) != 0)); \
+ X##_f1 = 0; \
+ }))
+
+#define _FP_FRAC_ADDI_2(X,I) \
+ __FP_FRAC_ADDI_2(X##_f1, X##_f0, I)
+
+#define _FP_FRAC_ADD_2(R,X,Y) \
+ __FP_FRAC_ADD_2(R##_f1, R##_f0, X##_f1, X##_f0, Y##_f1, Y##_f0)
+
+#define _FP_FRAC_SUB_2(R,X,Y) \
+ __FP_FRAC_SUB_2(R##_f1, R##_f0, X##_f1, X##_f0, Y##_f1, Y##_f0)
+
+#define _FP_FRAC_DEC_2(X,Y) \
+ __FP_FRAC_DEC_2(X##_f1, X##_f0, Y##_f1, Y##_f0)
+
+#define _FP_FRAC_CLZ_2(R,X) \
+ do { \
+ if (X##_f1) \
+ __FP_CLZ(R,X##_f1); \
+ else \
+ { \
+ __FP_CLZ(R,X##_f0); \
+ R += _FP_W_TYPE_SIZE; \
+ } \
+ } while(0)
+
+/* Predicates */
+#define _FP_FRAC_NEGP_2(X) ((_FP_WS_TYPE)X##_f1 < 0)
+#define _FP_FRAC_ZEROP_2(X) ((X##_f1 | X##_f0) == 0)
+#define _FP_FRAC_OVERP_2(fs,X) (_FP_FRAC_HIGH_##fs(X) & _FP_OVERFLOW_##fs)
+#define _FP_FRAC_CLEAR_OVERP_2(fs,X) (_FP_FRAC_HIGH_##fs(X) &= ~_FP_OVERFLOW_##fs)
+#define _FP_FRAC_EQ_2(X, Y) (X##_f1 == Y##_f1 && X##_f0 == Y##_f0)
+#define _FP_FRAC_GT_2(X, Y) \
+ (X##_f1 > Y##_f1 || (X##_f1 == Y##_f1 && X##_f0 > Y##_f0))
+#define _FP_FRAC_GE_2(X, Y) \
+ (X##_f1 > Y##_f1 || (X##_f1 == Y##_f1 && X##_f0 >= Y##_f0))
+
+#define _FP_ZEROFRAC_2 0, 0
+#define _FP_MINFRAC_2 0, 1
+#define _FP_MAXFRAC_2 (~(_FP_WS_TYPE)0), (~(_FP_WS_TYPE)0)
+
+/*
+ * Internals
+ */
+
+#define __FP_FRAC_SET_2(X,I1,I0) (X##_f0 = I0, X##_f1 = I1)
+
+#define __FP_CLZ_2(R, xh, xl) \
+ do { \
+ if (xh) \
+ __FP_CLZ(R,xh); \
+ else \
+ { \
+ __FP_CLZ(R,xl); \
+ R += _FP_W_TYPE_SIZE; \
+ } \
+ } while(0)
+
+#if 0
+
+#ifndef __FP_FRAC_ADDI_2
+#define __FP_FRAC_ADDI_2(xh, xl, i) \
+ (xh += ((xl += i) < i))
+#endif
+#ifndef __FP_FRAC_ADD_2
+#define __FP_FRAC_ADD_2(rh, rl, xh, xl, yh, yl) \
+ (rh = xh + yh + ((rl = xl + yl) < xl))
+#endif
+#ifndef __FP_FRAC_SUB_2
+#define __FP_FRAC_SUB_2(rh, rl, xh, xl, yh, yl) \
+ (rh = xh - yh - ((rl = xl - yl) > xl))
+#endif
+#ifndef __FP_FRAC_DEC_2
+#define __FP_FRAC_DEC_2(xh, xl, yh, yl) \
+ do { \
+ UWtype _t = xl; \
+ xh -= yh + ((xl -= yl) > _t); \
+ } while (0)
+#endif
+
+#else
+
+#undef __FP_FRAC_ADDI_2
+#define __FP_FRAC_ADDI_2(xh, xl, i) add_ssaaaa(xh, xl, xh, xl, 0, i)
+#undef __FP_FRAC_ADD_2
+#define __FP_FRAC_ADD_2 add_ssaaaa
+#undef __FP_FRAC_SUB_2
+#define __FP_FRAC_SUB_2 sub_ddmmss
+#undef __FP_FRAC_DEC_2
+#define __FP_FRAC_DEC_2(xh, xl, yh, yl) sub_ddmmss(xh, xl, xh, xl, yh, yl)
+
+#endif
+
+/*
+ * Unpack the raw bits of a native fp value. Do not classify or
+ * normalize the data.
+ */
+
+#define _FP_UNPACK_RAW_2(fs, X, val) \
+ do { \
+ union _FP_UNION_##fs _flo; _flo.flt = (val); \
+ \
+ X##_f0 = _flo.bits.frac0; \
+ X##_f1 = _flo.bits.frac1; \
+ X##_e = _flo.bits.exp; \
+ X##_s = _flo.bits.sign; \
+ } while (0)
+
+#define _FP_UNPACK_RAW_2_P(fs, X, val) \
+ do { \
+ union _FP_UNION_##fs *_flo = \
+ (union _FP_UNION_##fs *)(val); \
+ \
+ X##_f0 = _flo->bits.frac0; \
+ X##_f1 = _flo->bits.frac1; \
+ X##_e = _flo->bits.exp; \
+ X##_s = _flo->bits.sign; \
+ } while (0)
+
+
+/*
+ * Repack the raw bits of a native fp value.
+ */
+
+#define _FP_PACK_RAW_2(fs, val, X) \
+ do { \
+ union _FP_UNION_##fs _flo; \
+ \
+ _flo.bits.frac0 = X##_f0; \
+ _flo.bits.frac1 = X##_f1; \
+ _flo.bits.exp = X##_e; \
+ _flo.bits.sign = X##_s; \
+ \
+ (val) = _flo.flt; \
+ } while (0)
+
+#define _FP_PACK_RAW_2_P(fs, val, X) \
+ do { \
+ union _FP_UNION_##fs *_flo = \
+ (union _FP_UNION_##fs *)(val); \
+ \
+ _flo->bits.frac0 = X##_f0; \
+ _flo->bits.frac1 = X##_f1; \
+ _flo->bits.exp = X##_e; \
+ _flo->bits.sign = X##_s; \
+ } while (0)
+
+
+/*
+ * Multiplication algorithms:
+ */
+
+/* Given a 1W * 1W => 2W primitive, do the extended multiplication. */
+
+#define _FP_MUL_MEAT_2_wide(wfracbits, R, X, Y, doit) \
+ do { \
+ _FP_FRAC_DECL_4(_z); _FP_FRAC_DECL_2(_b); _FP_FRAC_DECL_2(_c); \
+ \
+ doit(_FP_FRAC_WORD_4(_z,1), _FP_FRAC_WORD_4(_z,0), X##_f0, Y##_f0); \
+ doit(_b_f1, _b_f0, X##_f0, Y##_f1); \
+ doit(_c_f1, _c_f0, X##_f1, Y##_f0); \
+ doit(_FP_FRAC_WORD_4(_z,3), _FP_FRAC_WORD_4(_z,2), X##_f1, Y##_f1); \
+ \
+ __FP_FRAC_ADD_3(_FP_FRAC_WORD_4(_z,3),_FP_FRAC_WORD_4(_z,2), \
+ _FP_FRAC_WORD_4(_z,1), 0, _b_f1, _b_f0, \
+ _FP_FRAC_WORD_4(_z,3),_FP_FRAC_WORD_4(_z,2), \
+ _FP_FRAC_WORD_4(_z,1)); \
+ __FP_FRAC_ADD_3(_FP_FRAC_WORD_4(_z,3),_FP_FRAC_WORD_4(_z,2), \
+ _FP_FRAC_WORD_4(_z,1), 0, _c_f1, _c_f0, \
+ _FP_FRAC_WORD_4(_z,3),_FP_FRAC_WORD_4(_z,2), \
+ _FP_FRAC_WORD_4(_z,1)); \
+ \
+ /* Normalize since we know where the msb of the multiplicands \
+ were (bit B), we know that the msb of the of the product is \
+ at either 2B or 2B-1. */ \
+ _FP_FRAC_SRS_4(_z, wfracbits-1, 2*wfracbits); \
+ R##_f0 = _FP_FRAC_WORD_4(_z,0); \
+ R##_f1 = _FP_FRAC_WORD_4(_z,1); \
+ } while (0)
+
+/* Given a 1W * 1W => 2W primitive, do the extended multiplication.
+ Do only 3 multiplications instead of four. This one is for machines
+ where multiplication is much more expensive than subtraction. */
+
+#define _FP_MUL_MEAT_2_wide_3mul(wfracbits, R, X, Y, doit) \
+ do { \
+ _FP_FRAC_DECL_4(_z); _FP_FRAC_DECL_2(_b); _FP_FRAC_DECL_2(_c); \
+ _FP_W_TYPE _d; \
+ int _c1, _c2; \
+ \
+ _b_f0 = X##_f0 + X##_f1; \
+ _c1 = _b_f0 < X##_f0; \
+ _b_f1 = Y##_f0 + Y##_f1; \
+ _c2 = _b_f1 < Y##_f0; \
+ doit(_d, _FP_FRAC_WORD_4(_z,0), X##_f0, Y##_f0); \
+ doit(_FP_FRAC_WORD_4(_z,2), _FP_FRAC_WORD_4(_z,1), _b_f0, _b_f1); \
+ doit(_c_f1, _c_f0, X##_f1, Y##_f1); \
+ \
+ _b_f0 &= -_c2; \
+ _b_f1 &= -_c1; \
+ __FP_FRAC_ADD_3(_FP_FRAC_WORD_4(_z,3),_FP_FRAC_WORD_4(_z,2), \
+ _FP_FRAC_WORD_4(_z,1), (_c1 & _c2), 0, _d, \
+ 0, _FP_FRAC_WORD_4(_z,2), _FP_FRAC_WORD_4(_z,1)); \
+ __FP_FRAC_ADDI_2(_FP_FRAC_WORD_4(_z,3),_FP_FRAC_WORD_4(_z,2), \
+ _b_f0); \
+ __FP_FRAC_ADDI_2(_FP_FRAC_WORD_4(_z,3),_FP_FRAC_WORD_4(_z,2), \
+ _b_f1); \
+ __FP_FRAC_DEC_3(_FP_FRAC_WORD_4(_z,3),_FP_FRAC_WORD_4(_z,2), \
+ _FP_FRAC_WORD_4(_z,1), \
+ 0, _d, _FP_FRAC_WORD_4(_z,0)); \
+ __FP_FRAC_DEC_3(_FP_FRAC_WORD_4(_z,3),_FP_FRAC_WORD_4(_z,2), \
+ _FP_FRAC_WORD_4(_z,1), 0, _c_f1, _c_f0); \
+ __FP_FRAC_ADD_2(_FP_FRAC_WORD_4(_z,3), _FP_FRAC_WORD_4(_z,2), \
+ _c_f1, _c_f0, \
+ _FP_FRAC_WORD_4(_z,3), _FP_FRAC_WORD_4(_z,2)); \
+ \
+ /* Normalize since we know where the msb of the multiplicands \
+ were (bit B), we know that the msb of the of the product is \
+ at either 2B or 2B-1. */ \
+ _FP_FRAC_SRS_4(_z, wfracbits-1, 2*wfracbits); \
+ R##_f0 = _FP_FRAC_WORD_4(_z,0); \
+ R##_f1 = _FP_FRAC_WORD_4(_z,1); \
+ } while (0)
+
+#define _FP_MUL_MEAT_2_gmp(wfracbits, R, X, Y) \
+ do { \
+ _FP_FRAC_DECL_4(_z); \
+ _FP_W_TYPE _x[2], _y[2]; \
+ _x[0] = X##_f0; _x[1] = X##_f1; \
+ _y[0] = Y##_f0; _y[1] = Y##_f1; \
+ \
+ mpn_mul_n(_z_f, _x, _y, 2); \
+ \
+ /* Normalize since we know where the msb of the multiplicands \
+ were (bit B), we know that the msb of the of the product is \
+ at either 2B or 2B-1. */ \
+ _FP_FRAC_SRS_4(_z, wfracbits-1, 2*wfracbits); \
+ R##_f0 = _z_f[0]; \
+ R##_f1 = _z_f[1]; \
+ } while (0)
+
+/* Do at most 120x120=240 bits multiplication using double floating
+ point multiplication. This is useful if floating point
+ multiplication has much bigger throughput than integer multiply.
+ It is supposed to work for _FP_W_TYPE_SIZE 64 and wfracbits
+ between 106 and 120 only.
+ Caller guarantees that X and Y has (1LLL << (wfracbits - 1)) set.
+ SETFETZ is a macro which will disable all FPU exceptions and set rounding
+ towards zero, RESETFE should optionally reset it back. */
+
+#define _FP_MUL_MEAT_2_120_240_double(wfracbits, R, X, Y, setfetz, resetfe) \
+ do { \
+ static const double _const[] = { \
+ /* 2^-24 */ 5.9604644775390625e-08, \
+ /* 2^-48 */ 3.5527136788005009e-15, \
+ /* 2^-72 */ 2.1175823681357508e-22, \
+ /* 2^-96 */ 1.2621774483536189e-29, \
+ /* 2^28 */ 2.68435456e+08, \
+ /* 2^4 */ 1.600000e+01, \
+ /* 2^-20 */ 9.5367431640625e-07, \
+ /* 2^-44 */ 5.6843418860808015e-14, \
+ /* 2^-68 */ 3.3881317890172014e-21, \
+ /* 2^-92 */ 2.0194839173657902e-28, \
+ /* 2^-116 */ 1.2037062152420224e-35}; \
+ double _a240, _b240, _c240, _d240, _e240, _f240, \
+ _g240, _h240, _i240, _j240, _k240; \
+ union { double d; UDItype i; } _l240, _m240, _n240, _o240, \
+ _p240, _q240, _r240, _s240; \
+ UDItype _t240, _u240, _v240, _w240, _x240, _y240 = 0; \
+ \
+ if (wfracbits < 106 || wfracbits > 120) \
+ abort(); \
+ \
+ setfetz; \
+ \
+ _e240 = (double)(long)(X##_f0 & 0xffffff); \
+ _j240 = (double)(long)(Y##_f0 & 0xffffff); \
+ _d240 = (double)(long)((X##_f0 >> 24) & 0xffffff); \
+ _i240 = (double)(long)((Y##_f0 >> 24) & 0xffffff); \
+ _c240 = (double)(long)(((X##_f1 << 16) & 0xffffff) | (X##_f0 >> 48)); \
+ _h240 = (double)(long)(((Y##_f1 << 16) & 0xffffff) | (Y##_f0 >> 48)); \
+ _b240 = (double)(long)((X##_f1 >> 8) & 0xffffff); \
+ _g240 = (double)(long)((Y##_f1 >> 8) & 0xffffff); \
+ _a240 = (double)(long)(X##_f1 >> 32); \
+ _f240 = (double)(long)(Y##_f1 >> 32); \
+ _e240 *= _const[3]; \
+ _j240 *= _const[3]; \
+ _d240 *= _const[2]; \
+ _i240 *= _const[2]; \
+ _c240 *= _const[1]; \
+ _h240 *= _const[1]; \
+ _b240 *= _const[0]; \
+ _g240 *= _const[0]; \
+ _s240.d = _e240*_j240;\
+ _r240.d = _d240*_j240 + _e240*_i240;\
+ _q240.d = _c240*_j240 + _d240*_i240 + _e240*_h240;\
+ _p240.d = _b240*_j240 + _c240*_i240 + _d240*_h240 + _e240*_g240;\
+ _o240.d = _a240*_j240 + _b240*_i240 + _c240*_h240 + _d240*_g240 + _e240*_f240;\
+ _n240.d = _a240*_i240 + _b240*_h240 + _c240*_g240 + _d240*_f240; \
+ _m240.d = _a240*_h240 + _b240*_g240 + _c240*_f240; \
+ _l240.d = _a240*_g240 + _b240*_f240; \
+ _k240 = _a240*_f240; \
+ _r240.d += _s240.d; \
+ _q240.d += _r240.d; \
+ _p240.d += _q240.d; \
+ _o240.d += _p240.d; \
+ _n240.d += _o240.d; \
+ _m240.d += _n240.d; \
+ _l240.d += _m240.d; \
+ _k240 += _l240.d; \
+ _s240.d -= ((_const[10]+_s240.d)-_const[10]); \
+ _r240.d -= ((_const[9]+_r240.d)-_const[9]); \
+ _q240.d -= ((_const[8]+_q240.d)-_const[8]); \
+ _p240.d -= ((_const[7]+_p240.d)-_const[7]); \
+ _o240.d += _const[7]; \
+ _n240.d += _const[6]; \
+ _m240.d += _const[5]; \
+ _l240.d += _const[4]; \
+ if (_s240.d != 0.0) _y240 = 1; \
+ if (_r240.d != 0.0) _y240 = 1; \
+ if (_q240.d != 0.0) _y240 = 1; \
+ if (_p240.d != 0.0) _y240 = 1; \
+ _t240 = (DItype)_k240; \
+ _u240 = _l240.i; \
+ _v240 = _m240.i; \
+ _w240 = _n240.i; \
+ _x240 = _o240.i; \
+ R##_f1 = (_t240 << (128 - (wfracbits - 1))) \
+ | ((_u240 & 0xffffff) >> ((wfracbits - 1) - 104)); \
+ R##_f0 = ((_u240 & 0xffffff) << (168 - (wfracbits - 1))) \
+ | ((_v240 & 0xffffff) << (144 - (wfracbits - 1))) \
+ | ((_w240 & 0xffffff) << (120 - (wfracbits - 1))) \
+ | ((_x240 & 0xffffff) >> ((wfracbits - 1) - 96)) \
+ | _y240; \
+ resetfe; \
+ } while (0)
+
+/*
+ * Division algorithms:
+ */
+
+#define _FP_DIV_MEAT_2_udiv(fs, R, X, Y) \
+ do { \
+ _FP_W_TYPE _n_f2, _n_f1, _n_f0, _r_f1, _r_f0, _m_f1, _m_f0; \
+ if (_FP_FRAC_GT_2(X, Y)) \
+ { \
+ _n_f2 = X##_f1 >> 1; \
+ _n_f1 = X##_f1 << (_FP_W_TYPE_SIZE - 1) | X##_f0 >> 1; \
+ _n_f0 = X##_f0 << (_FP_W_TYPE_SIZE - 1); \
+ } \
+ else \
+ { \
+ R##_e--; \
+ _n_f2 = X##_f1; \
+ _n_f1 = X##_f0; \
+ _n_f0 = 0; \
+ } \
+ \
+ /* Normalize, i.e. make the most significant bit of the \
+ denominator set. */ \
+ _FP_FRAC_SLL_2(Y, _FP_WFRACXBITS_##fs); \
+ \
+ udiv_qrnnd(R##_f1, _r_f1, _n_f2, _n_f1, Y##_f1); \
+ umul_ppmm(_m_f1, _m_f0, R##_f1, Y##_f0); \
+ _r_f0 = _n_f0; \
+ if (_FP_FRAC_GT_2(_m, _r)) \
+ { \
+ R##_f1--; \
+ _FP_FRAC_ADD_2(_r, Y, _r); \
+ if (_FP_FRAC_GE_2(_r, Y) && _FP_FRAC_GT_2(_m, _r)) \
+ { \
+ R##_f1--; \
+ _FP_FRAC_ADD_2(_r, Y, _r); \
+ } \
+ } \
+ _FP_FRAC_DEC_2(_r, _m); \
+ \
+ if (_r_f1 == Y##_f1) \
+ { \
+ /* This is a special case, not an optimization \
+ (_r/Y##_f1 would not fit into UWtype). \
+ As _r is guaranteed to be < Y, R##_f0 can be either \
+ (UWtype)-1 or (UWtype)-2. But as we know what kind \
+ of bits it is (sticky, guard, round), we don't care. \
+ We also don't care what the reminder is, because the \
+ guard bit will be set anyway. -jj */ \
+ R##_f0 = -1; \
+ } \
+ else \
+ { \
+ udiv_qrnnd(R##_f0, _r_f1, _r_f1, _r_f0, Y##_f1); \
+ umul_ppmm(_m_f1, _m_f0, R##_f0, Y##_f0); \
+ _r_f0 = 0; \
+ if (_FP_FRAC_GT_2(_m, _r)) \
+ { \
+ R##_f0--; \
+ _FP_FRAC_ADD_2(_r, Y, _r); \
+ if (_FP_FRAC_GE_2(_r, Y) && _FP_FRAC_GT_2(_m, _r)) \
+ { \
+ R##_f0--; \
+ _FP_FRAC_ADD_2(_r, Y, _r); \
+ } \
+ } \
+ if (!_FP_FRAC_EQ_2(_r, _m)) \
+ R##_f0 |= _FP_WORK_STICKY; \
+ } \
+ } while (0)
+
+
+#define _FP_DIV_MEAT_2_gmp(fs, R, X, Y) \
+ do { \
+ _FP_W_TYPE _x[4], _y[2], _z[4]; \
+ _y[0] = Y##_f0; _y[1] = Y##_f1; \
+ _x[0] = _x[3] = 0; \
+ if (_FP_FRAC_GT_2(X, Y)) \
+ { \
+ R##_e++; \
+ _x[1] = (X##_f0 << (_FP_WFRACBITS_##fs-1 - _FP_W_TYPE_SIZE) | \
+ X##_f1 >> (_FP_W_TYPE_SIZE - \
+ (_FP_WFRACBITS_##fs-1 - _FP_W_TYPE_SIZE))); \
+ _x[2] = X##_f1 << (_FP_WFRACBITS_##fs-1 - _FP_W_TYPE_SIZE); \
+ } \
+ else \
+ { \
+ _x[1] = (X##_f0 << (_FP_WFRACBITS_##fs - _FP_W_TYPE_SIZE) | \
+ X##_f1 >> (_FP_W_TYPE_SIZE - \
+ (_FP_WFRACBITS_##fs - _FP_W_TYPE_SIZE))); \
+ _x[2] = X##_f1 << (_FP_WFRACBITS_##fs - _FP_W_TYPE_SIZE); \
+ } \
+ \
+ (void) mpn_divrem (_z, 0, _x, 4, _y, 2); \
+ R##_f1 = _z[1]; \
+ R##_f0 = _z[0] | ((_x[0] | _x[1]) != 0); \
+ } while (0)
+
+
+/*
+ * Square root algorithms:
+ * We have just one right now, maybe Newton approximation
+ * should be added for those machines where division is fast.
+ */
+
+#define _FP_SQRT_MEAT_2(R, S, T, X, q) \
+ do { \
+ while (q) \
+ { \
+ T##_f1 = S##_f1 + q; \
+ if (T##_f1 <= X##_f1) \
+ { \
+ S##_f1 = T##_f1 + q; \
+ X##_f1 -= T##_f1; \
+ R##_f1 += q; \
+ } \
+ _FP_FRAC_SLL_2(X, 1); \
+ q >>= 1; \
+ } \
+ q = (_FP_W_TYPE)1 << (_FP_W_TYPE_SIZE - 1); \
+ while (q != _FP_WORK_ROUND) \
+ { \
+ T##_f0 = S##_f0 + q; \
+ T##_f1 = S##_f1; \
+ if (T##_f1 < X##_f1 || \
+ (T##_f1 == X##_f1 && T##_f0 <= X##_f0)) \
+ { \
+ S##_f0 = T##_f0 + q; \
+ S##_f1 += (T##_f0 > S##_f0); \
+ _FP_FRAC_DEC_2(X, T); \
+ R##_f0 += q; \
+ } \
+ _FP_FRAC_SLL_2(X, 1); \
+ q >>= 1; \
+ } \
+ if (X##_f0 | X##_f1) \
+ { \
+ if (S##_f1 < X##_f1 || \
+ (S##_f1 == X##_f1 && S##_f0 < X##_f0)) \
+ R##_f0 |= _FP_WORK_ROUND; \
+ R##_f0 |= _FP_WORK_STICKY; \
+ } \
+ } while (0)
+
+
+/*
+ * Assembly/disassembly for converting to/from integral types.
+ * No shifting or overflow handled here.
+ */
+
+#define _FP_FRAC_ASSEMBLE_2(r, X, rsize) \
+(void)((rsize <= _FP_W_TYPE_SIZE) \
+ ? ({ r = X##_f0; }) \
+ : ({ \
+ r = X##_f1; \
+ r <<= _FP_W_TYPE_SIZE; \
+ r += X##_f0; \
+ }))
+
+#define _FP_FRAC_DISASSEMBLE_2(X, r, rsize) \
+ do { \
+ X##_f0 = r; \
+ X##_f1 = (rsize <= _FP_W_TYPE_SIZE ? 0 : r >> _FP_W_TYPE_SIZE); \
+ } while (0)
+
+/*
+ * Convert FP values between word sizes
+ */
+
+#define _FP_FRAC_COPY_1_2(D, S) (D##_f = S##_f0)
+
+#define _FP_FRAC_COPY_2_1(D, S) ((D##_f0 = S##_f), (D##_f1 = 0))
+
+#define _FP_FRAC_COPY_2_2(D,S) _FP_FRAC_COPY_2(D,S)
diff --git a/libc/sysdeps/linux/sparc/soft-fp/op-4.h b/libc/sysdeps/linux/sparc/soft-fp/op-4.h
new file mode 100644
index 000000000..a81e7ab7c
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/op-4.h
@@ -0,0 +1,687 @@
+/* Software floating-point emulation.
+ Basic four-word fraction declaration and manipulation.
+ Copyright (C) 1997,1998,1999,2006,2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com),
+ Jakub Jelinek (jj@ultra.linux.cz),
+ David S. Miller (davem@redhat.com) and
+ Peter Maydell (pmaydell@chiark.greenend.org.uk).
+
+ 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 into
+ combinations with other programs, and to distribute those
+ combinations without any restriction coming from the use of this
+ file. (The Lesser General Public License restrictions do apply in
+ other respects; for example, they cover modification of the file,
+ and distribution when not linked into a combine executable.)
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#define _FP_FRAC_DECL_4(X) _FP_W_TYPE X##_f[4]
+#define _FP_FRAC_COPY_4(D,S) \
+ (D##_f[0] = S##_f[0], D##_f[1] = S##_f[1], \
+ D##_f[2] = S##_f[2], D##_f[3] = S##_f[3])
+#define _FP_FRAC_SET_4(X,I) __FP_FRAC_SET_4(X, I)
+#define _FP_FRAC_HIGH_4(X) (X##_f[3])
+#define _FP_FRAC_LOW_4(X) (X##_f[0])
+#define _FP_FRAC_WORD_4(X,w) (X##_f[w])
+
+#define _FP_FRAC_SLL_4(X,N) \
+ do { \
+ _FP_I_TYPE _up, _down, _skip, _i; \
+ _skip = (N) / _FP_W_TYPE_SIZE; \
+ _up = (N) % _FP_W_TYPE_SIZE; \
+ _down = _FP_W_TYPE_SIZE - _up; \
+ if (!_up) \
+ for (_i = 3; _i >= _skip; --_i) \
+ X##_f[_i] = X##_f[_i-_skip]; \
+ else \
+ { \
+ for (_i = 3; _i > _skip; --_i) \
+ X##_f[_i] = X##_f[_i-_skip] << _up \
+ | X##_f[_i-_skip-1] >> _down; \
+ X##_f[_i--] = X##_f[0] << _up; \
+ } \
+ for (; _i >= 0; --_i) \
+ X##_f[_i] = 0; \
+ } while (0)
+
+/* This one was broken too */
+#define _FP_FRAC_SRL_4(X,N) \
+ do { \
+ _FP_I_TYPE _up, _down, _skip, _i; \
+ _skip = (N) / _FP_W_TYPE_SIZE; \
+ _down = (N) % _FP_W_TYPE_SIZE; \
+ _up = _FP_W_TYPE_SIZE - _down; \
+ if (!_down) \
+ for (_i = 0; _i <= 3-_skip; ++_i) \
+ X##_f[_i] = X##_f[_i+_skip]; \
+ else \
+ { \
+ for (_i = 0; _i < 3-_skip; ++_i) \
+ X##_f[_i] = X##_f[_i+_skip] >> _down \
+ | X##_f[_i+_skip+1] << _up; \
+ X##_f[_i++] = X##_f[3] >> _down; \
+ } \
+ for (; _i < 4; ++_i) \
+ X##_f[_i] = 0; \
+ } while (0)
+
+
+/* Right shift with sticky-lsb.
+ * What this actually means is that we do a standard right-shift,
+ * but that if any of the bits that fall off the right hand side
+ * were one then we always set the LSbit.
+ */
+#define _FP_FRAC_SRST_4(X,S,N,size) \
+ do { \
+ _FP_I_TYPE _up, _down, _skip, _i; \
+ _FP_W_TYPE _s; \
+ _skip = (N) / _FP_W_TYPE_SIZE; \
+ _down = (N) % _FP_W_TYPE_SIZE; \
+ _up = _FP_W_TYPE_SIZE - _down; \
+ for (_s = _i = 0; _i < _skip; ++_i) \
+ _s |= X##_f[_i]; \
+ if (!_down) \
+ for (_i = 0; _i <= 3-_skip; ++_i) \
+ X##_f[_i] = X##_f[_i+_skip]; \
+ else \
+ { \
+ _s |= X##_f[_i] << _up; \
+ for (_i = 0; _i < 3-_skip; ++_i) \
+ X##_f[_i] = X##_f[_i+_skip] >> _down \
+ | X##_f[_i+_skip+1] << _up; \
+ X##_f[_i++] = X##_f[3] >> _down; \
+ } \
+ for (; _i < 4; ++_i) \
+ X##_f[_i] = 0; \
+ S = (_s != 0); \
+ } while (0)
+
+#define _FP_FRAC_SRS_4(X,N,size) \
+ do { \
+ int _sticky; \
+ _FP_FRAC_SRST_4(X, _sticky, N, size); \
+ X##_f[0] |= _sticky; \
+ } while (0)
+
+#define _FP_FRAC_ADD_4(R,X,Y) \
+ __FP_FRAC_ADD_4(R##_f[3], R##_f[2], R##_f[1], R##_f[0], \
+ X##_f[3], X##_f[2], X##_f[1], X##_f[0], \
+ Y##_f[3], Y##_f[2], Y##_f[1], Y##_f[0])
+
+#define _FP_FRAC_SUB_4(R,X,Y) \
+ __FP_FRAC_SUB_4(R##_f[3], R##_f[2], R##_f[1], R##_f[0], \
+ X##_f[3], X##_f[2], X##_f[1], X##_f[0], \
+ Y##_f[3], Y##_f[2], Y##_f[1], Y##_f[0])
+
+#define _FP_FRAC_DEC_4(X,Y) \
+ __FP_FRAC_DEC_4(X##_f[3], X##_f[2], X##_f[1], X##_f[0], \
+ Y##_f[3], Y##_f[2], Y##_f[1], Y##_f[0])
+
+#define _FP_FRAC_ADDI_4(X,I) \
+ __FP_FRAC_ADDI_4(X##_f[3], X##_f[2], X##_f[1], X##_f[0], I)
+
+#define _FP_ZEROFRAC_4 0,0,0,0
+#define _FP_MINFRAC_4 0,0,0,1
+#define _FP_MAXFRAC_4 (~(_FP_WS_TYPE)0), (~(_FP_WS_TYPE)0), (~(_FP_WS_TYPE)0), (~(_FP_WS_TYPE)0)
+
+#define _FP_FRAC_ZEROP_4(X) ((X##_f[0] | X##_f[1] | X##_f[2] | X##_f[3]) == 0)
+#define _FP_FRAC_NEGP_4(X) ((_FP_WS_TYPE)X##_f[3] < 0)
+#define _FP_FRAC_OVERP_4(fs,X) (_FP_FRAC_HIGH_##fs(X) & _FP_OVERFLOW_##fs)
+#define _FP_FRAC_CLEAR_OVERP_4(fs,X) (_FP_FRAC_HIGH_##fs(X) &= ~_FP_OVERFLOW_##fs)
+
+#define _FP_FRAC_EQ_4(X,Y) \
+ (X##_f[0] == Y##_f[0] && X##_f[1] == Y##_f[1] \
+ && X##_f[2] == Y##_f[2] && X##_f[3] == Y##_f[3])
+
+#define _FP_FRAC_GT_4(X,Y) \
+ (X##_f[3] > Y##_f[3] || \
+ (X##_f[3] == Y##_f[3] && (X##_f[2] > Y##_f[2] || \
+ (X##_f[2] == Y##_f[2] && (X##_f[1] > Y##_f[1] || \
+ (X##_f[1] == Y##_f[1] && X##_f[0] > Y##_f[0]) \
+ )) \
+ )) \
+ )
+
+#define _FP_FRAC_GE_4(X,Y) \
+ (X##_f[3] > Y##_f[3] || \
+ (X##_f[3] == Y##_f[3] && (X##_f[2] > Y##_f[2] || \
+ (X##_f[2] == Y##_f[2] && (X##_f[1] > Y##_f[1] || \
+ (X##_f[1] == Y##_f[1] && X##_f[0] >= Y##_f[0]) \
+ )) \
+ )) \
+ )
+
+
+#define _FP_FRAC_CLZ_4(R,X) \
+ do { \
+ if (X##_f[3]) \
+ { \
+ __FP_CLZ(R,X##_f[3]); \
+ } \
+ else if (X##_f[2]) \
+ { \
+ __FP_CLZ(R,X##_f[2]); \
+ R += _FP_W_TYPE_SIZE; \
+ } \
+ else if (X##_f[1]) \
+ { \
+ __FP_CLZ(R,X##_f[1]); \
+ R += _FP_W_TYPE_SIZE*2; \
+ } \
+ else \
+ { \
+ __FP_CLZ(R,X##_f[0]); \
+ R += _FP_W_TYPE_SIZE*3; \
+ } \
+ } while(0)
+
+
+#define _FP_UNPACK_RAW_4(fs, X, val) \
+ do { \
+ union _FP_UNION_##fs _flo; _flo.flt = (val); \
+ X##_f[0] = _flo.bits.frac0; \
+ X##_f[1] = _flo.bits.frac1; \
+ X##_f[2] = _flo.bits.frac2; \
+ X##_f[3] = _flo.bits.frac3; \
+ X##_e = _flo.bits.exp; \
+ X##_s = _flo.bits.sign; \
+ } while (0)
+
+#define _FP_UNPACK_RAW_4_P(fs, X, val) \
+ do { \
+ union _FP_UNION_##fs *_flo = \
+ (union _FP_UNION_##fs *)(val); \
+ \
+ X##_f[0] = _flo->bits.frac0; \
+ X##_f[1] = _flo->bits.frac1; \
+ X##_f[2] = _flo->bits.frac2; \
+ X##_f[3] = _flo->bits.frac3; \
+ X##_e = _flo->bits.exp; \
+ X##_s = _flo->bits.sign; \
+ } while (0)
+
+#define _FP_PACK_RAW_4(fs, val, X) \
+ do { \
+ union _FP_UNION_##fs _flo; \
+ _flo.bits.frac0 = X##_f[0]; \
+ _flo.bits.frac1 = X##_f[1]; \
+ _flo.bits.frac2 = X##_f[2]; \
+ _flo.bits.frac3 = X##_f[3]; \
+ _flo.bits.exp = X##_e; \
+ _flo.bits.sign = X##_s; \
+ (val) = _flo.flt; \
+ } while (0)
+
+#define _FP_PACK_RAW_4_P(fs, val, X) \
+ do { \
+ union _FP_UNION_##fs *_flo = \
+ (union _FP_UNION_##fs *)(val); \
+ \
+ _flo->bits.frac0 = X##_f[0]; \
+ _flo->bits.frac1 = X##_f[1]; \
+ _flo->bits.frac2 = X##_f[2]; \
+ _flo->bits.frac3 = X##_f[3]; \
+ _flo->bits.exp = X##_e; \
+ _flo->bits.sign = X##_s; \
+ } while (0)
+
+/*
+ * Multiplication algorithms:
+ */
+
+/* Given a 1W * 1W => 2W primitive, do the extended multiplication. */
+
+#define _FP_MUL_MEAT_4_wide(wfracbits, R, X, Y, doit) \
+ do { \
+ _FP_FRAC_DECL_8(_z); _FP_FRAC_DECL_2(_b); _FP_FRAC_DECL_2(_c); \
+ _FP_FRAC_DECL_2(_d); _FP_FRAC_DECL_2(_e); _FP_FRAC_DECL_2(_f); \
+ \
+ doit(_FP_FRAC_WORD_8(_z,1), _FP_FRAC_WORD_8(_z,0), X##_f[0], Y##_f[0]); \
+ doit(_b_f1, _b_f0, X##_f[0], Y##_f[1]); \
+ doit(_c_f1, _c_f0, X##_f[1], Y##_f[0]); \
+ doit(_d_f1, _d_f0, X##_f[1], Y##_f[1]); \
+ doit(_e_f1, _e_f0, X##_f[0], Y##_f[2]); \
+ doit(_f_f1, _f_f0, X##_f[2], Y##_f[0]); \
+ __FP_FRAC_ADD_3(_FP_FRAC_WORD_8(_z,3),_FP_FRAC_WORD_8(_z,2), \
+ _FP_FRAC_WORD_8(_z,1), 0,_b_f1,_b_f0, \
+ 0,0,_FP_FRAC_WORD_8(_z,1)); \
+ __FP_FRAC_ADD_3(_FP_FRAC_WORD_8(_z,3),_FP_FRAC_WORD_8(_z,2), \
+ _FP_FRAC_WORD_8(_z,1), 0,_c_f1,_c_f0, \
+ _FP_FRAC_WORD_8(_z,3),_FP_FRAC_WORD_8(_z,2), \
+ _FP_FRAC_WORD_8(_z,1)); \
+ __FP_FRAC_ADD_3(_FP_FRAC_WORD_8(_z,4),_FP_FRAC_WORD_8(_z,3), \
+ _FP_FRAC_WORD_8(_z,2), 0,_d_f1,_d_f0, \
+ 0,_FP_FRAC_WORD_8(_z,3),_FP_FRAC_WORD_8(_z,2)); \
+ __FP_FRAC_ADD_3(_FP_FRAC_WORD_8(_z,4),_FP_FRAC_WORD_8(_z,3), \
+ _FP_FRAC_WORD_8(_z,2), 0,_e_f1,_e_f0, \
+ _FP_FRAC_WORD_8(_z,4),_FP_FRAC_WORD_8(_z,3), \
+ _FP_FRAC_WORD_8(_z,2)); \
+ __FP_FRAC_ADD_3(_FP_FRAC_WORD_8(_z,4),_FP_FRAC_WORD_8(_z,3), \
+ _FP_FRAC_WORD_8(_z,2), 0,_f_f1,_f_f0, \
+ _FP_FRAC_WORD_8(_z,4),_FP_FRAC_WORD_8(_z,3), \
+ _FP_FRAC_WORD_8(_z,2)); \
+ doit(_b_f1, _b_f0, X##_f[0], Y##_f[3]); \
+ doit(_c_f1, _c_f0, X##_f[3], Y##_f[0]); \
+ doit(_d_f1, _d_f0, X##_f[1], Y##_f[2]); \
+ doit(_e_f1, _e_f0, X##_f[2], Y##_f[1]); \
+ __FP_FRAC_ADD_3(_FP_FRAC_WORD_8(_z,5),_FP_FRAC_WORD_8(_z,4), \
+ _FP_FRAC_WORD_8(_z,3), 0,_b_f1,_b_f0, \
+ 0,_FP_FRAC_WORD_8(_z,4),_FP_FRAC_WORD_8(_z,3)); \
+ __FP_FRAC_ADD_3(_FP_FRAC_WORD_8(_z,5),_FP_FRAC_WORD_8(_z,4), \
+ _FP_FRAC_WORD_8(_z,3), 0,_c_f1,_c_f0, \
+ _FP_FRAC_WORD_8(_z,5),_FP_FRAC_WORD_8(_z,4), \
+ _FP_FRAC_WORD_8(_z,3)); \
+ __FP_FRAC_ADD_3(_FP_FRAC_WORD_8(_z,5),_FP_FRAC_WORD_8(_z,4), \
+ _FP_FRAC_WORD_8(_z,3), 0,_d_f1,_d_f0, \
+ _FP_FRAC_WORD_8(_z,5),_FP_FRAC_WORD_8(_z,4), \
+ _FP_FRAC_WORD_8(_z,3)); \
+ __FP_FRAC_ADD_3(_FP_FRAC_WORD_8(_z,5),_FP_FRAC_WORD_8(_z,4), \
+ _FP_FRAC_WORD_8(_z,3), 0,_e_f1,_e_f0, \
+ _FP_FRAC_WORD_8(_z,5),_FP_FRAC_WORD_8(_z,4), \
+ _FP_FRAC_WORD_8(_z,3)); \
+ doit(_b_f1, _b_f0, X##_f[2], Y##_f[2]); \
+ doit(_c_f1, _c_f0, X##_f[1], Y##_f[3]); \
+ doit(_d_f1, _d_f0, X##_f[3], Y##_f[1]); \
+ doit(_e_f1, _e_f0, X##_f[2], Y##_f[3]); \
+ doit(_f_f1, _f_f0, X##_f[3], Y##_f[2]); \
+ __FP_FRAC_ADD_3(_FP_FRAC_WORD_8(_z,6),_FP_FRAC_WORD_8(_z,5), \
+ _FP_FRAC_WORD_8(_z,4), 0,_b_f1,_b_f0, \
+ 0,_FP_FRAC_WORD_8(_z,5),_FP_FRAC_WORD_8(_z,4)); \
+ __FP_FRAC_ADD_3(_FP_FRAC_WORD_8(_z,6),_FP_FRAC_WORD_8(_z,5), \
+ _FP_FRAC_WORD_8(_z,4), 0,_c_f1,_c_f0, \
+ _FP_FRAC_WORD_8(_z,6),_FP_FRAC_WORD_8(_z,5), \
+ _FP_FRAC_WORD_8(_z,4)); \
+ __FP_FRAC_ADD_3(_FP_FRAC_WORD_8(_z,6),_FP_FRAC_WORD_8(_z,5), \
+ _FP_FRAC_WORD_8(_z,4), 0,_d_f1,_d_f0, \
+ _FP_FRAC_WORD_8(_z,6),_FP_FRAC_WORD_8(_z,5), \
+ _FP_FRAC_WORD_8(_z,4)); \
+ __FP_FRAC_ADD_3(_FP_FRAC_WORD_8(_z,7),_FP_FRAC_WORD_8(_z,6), \
+ _FP_FRAC_WORD_8(_z,5), 0,_e_f1,_e_f0, \
+ 0,_FP_FRAC_WORD_8(_z,6),_FP_FRAC_WORD_8(_z,5)); \
+ __FP_FRAC_ADD_3(_FP_FRAC_WORD_8(_z,7),_FP_FRAC_WORD_8(_z,6), \
+ _FP_FRAC_WORD_8(_z,5), 0,_f_f1,_f_f0, \
+ _FP_FRAC_WORD_8(_z,7),_FP_FRAC_WORD_8(_z,6), \
+ _FP_FRAC_WORD_8(_z,5)); \
+ doit(_b_f1, _b_f0, X##_f[3], Y##_f[3]); \
+ __FP_FRAC_ADD_2(_FP_FRAC_WORD_8(_z,7),_FP_FRAC_WORD_8(_z,6), \
+ _b_f1,_b_f0, \
+ _FP_FRAC_WORD_8(_z,7),_FP_FRAC_WORD_8(_z,6)); \
+ \
+ /* Normalize since we know where the msb of the multiplicands \
+ were (bit B), we know that the msb of the of the product is \
+ at either 2B or 2B-1. */ \
+ _FP_FRAC_SRS_8(_z, wfracbits-1, 2*wfracbits); \
+ __FP_FRAC_SET_4(R, _FP_FRAC_WORD_8(_z,3), _FP_FRAC_WORD_8(_z,2), \
+ _FP_FRAC_WORD_8(_z,1), _FP_FRAC_WORD_8(_z,0)); \
+ } while (0)
+
+#define _FP_MUL_MEAT_4_gmp(wfracbits, R, X, Y) \
+ do { \
+ _FP_FRAC_DECL_8(_z); \
+ \
+ mpn_mul_n(_z_f, _x_f, _y_f, 4); \
+ \
+ /* Normalize since we know where the msb of the multiplicands \
+ were (bit B), we know that the msb of the of the product is \
+ at either 2B or 2B-1. */ \
+ _FP_FRAC_SRS_8(_z, wfracbits-1, 2*wfracbits); \
+ __FP_FRAC_SET_4(R, _FP_FRAC_WORD_8(_z,3), _FP_FRAC_WORD_8(_z,2), \
+ _FP_FRAC_WORD_8(_z,1), _FP_FRAC_WORD_8(_z,0)); \
+ } while (0)
+
+/*
+ * Helper utility for _FP_DIV_MEAT_4_udiv:
+ * pppp = m * nnn
+ */
+#define umul_ppppmnnn(p3,p2,p1,p0,m,n2,n1,n0) \
+ do { \
+ UWtype _t; \
+ umul_ppmm(p1,p0,m,n0); \
+ umul_ppmm(p2,_t,m,n1); \
+ __FP_FRAC_ADDI_2(p2,p1,_t); \
+ umul_ppmm(p3,_t,m,n2); \
+ __FP_FRAC_ADDI_2(p3,p2,_t); \
+ } while (0)
+
+/*
+ * Division algorithms:
+ */
+
+#define _FP_DIV_MEAT_4_udiv(fs, R, X, Y) \
+ do { \
+ int _i; \
+ _FP_FRAC_DECL_4(_n); _FP_FRAC_DECL_4(_m); \
+ _FP_FRAC_SET_4(_n, _FP_ZEROFRAC_4); \
+ if (_FP_FRAC_GT_4(X, Y)) \
+ { \
+ _n_f[3] = X##_f[0] << (_FP_W_TYPE_SIZE - 1); \
+ _FP_FRAC_SRL_4(X, 1); \
+ } \
+ else \
+ R##_e--; \
+ \
+ /* Normalize, i.e. make the most significant bit of the \
+ denominator set. */ \
+ _FP_FRAC_SLL_4(Y, _FP_WFRACXBITS_##fs); \
+ \
+ for (_i = 3; ; _i--) \
+ { \
+ if (X##_f[3] == Y##_f[3]) \
+ { \
+ /* This is a special case, not an optimization \
+ (X##_f[3]/Y##_f[3] would not fit into UWtype). \
+ As X## is guaranteed to be < Y, R##_f[_i] can be either \
+ (UWtype)-1 or (UWtype)-2. */ \
+ R##_f[_i] = -1; \
+ if (!_i) \
+ break; \
+ __FP_FRAC_SUB_4(X##_f[3], X##_f[2], X##_f[1], X##_f[0], \
+ Y##_f[2], Y##_f[1], Y##_f[0], 0, \
+ X##_f[2], X##_f[1], X##_f[0], _n_f[_i]); \
+ _FP_FRAC_SUB_4(X, Y, X); \
+ if (X##_f[3] > Y##_f[3]) \
+ { \
+ R##_f[_i] = -2; \
+ _FP_FRAC_ADD_4(X, Y, X); \
+ } \
+ } \
+ else \
+ { \
+ udiv_qrnnd(R##_f[_i], X##_f[3], X##_f[3], X##_f[2], Y##_f[3]); \
+ umul_ppppmnnn(_m_f[3], _m_f[2], _m_f[1], _m_f[0], \
+ R##_f[_i], Y##_f[2], Y##_f[1], Y##_f[0]); \
+ X##_f[2] = X##_f[1]; \
+ X##_f[1] = X##_f[0]; \
+ X##_f[0] = _n_f[_i]; \
+ if (_FP_FRAC_GT_4(_m, X)) \
+ { \
+ R##_f[_i]--; \
+ _FP_FRAC_ADD_4(X, Y, X); \
+ if (_FP_FRAC_GE_4(X, Y) && _FP_FRAC_GT_4(_m, X)) \
+ { \
+ R##_f[_i]--; \
+ _FP_FRAC_ADD_4(X, Y, X); \
+ } \
+ } \
+ _FP_FRAC_DEC_4(X, _m); \
+ if (!_i) \
+ { \
+ if (!_FP_FRAC_EQ_4(X, _m)) \
+ R##_f[0] |= _FP_WORK_STICKY; \
+ break; \
+ } \
+ } \
+ } \
+ } while (0)
+
+
+/*
+ * Square root algorithms:
+ * We have just one right now, maybe Newton approximation
+ * should be added for those machines where division is fast.
+ */
+
+#define _FP_SQRT_MEAT_4(R, S, T, X, q) \
+ do { \
+ while (q) \
+ { \
+ T##_f[3] = S##_f[3] + q; \
+ if (T##_f[3] <= X##_f[3]) \
+ { \
+ S##_f[3] = T##_f[3] + q; \
+ X##_f[3] -= T##_f[3]; \
+ R##_f[3] += q; \
+ } \
+ _FP_FRAC_SLL_4(X, 1); \
+ q >>= 1; \
+ } \
+ q = (_FP_W_TYPE)1 << (_FP_W_TYPE_SIZE - 1); \
+ while (q) \
+ { \
+ T##_f[2] = S##_f[2] + q; \
+ T##_f[3] = S##_f[3]; \
+ if (T##_f[3] < X##_f[3] || \
+ (T##_f[3] == X##_f[3] && T##_f[2] <= X##_f[2])) \
+ { \
+ S##_f[2] = T##_f[2] + q; \
+ S##_f[3] += (T##_f[2] > S##_f[2]); \
+ __FP_FRAC_DEC_2(X##_f[3], X##_f[2], \
+ T##_f[3], T##_f[2]); \
+ R##_f[2] += q; \
+ } \
+ _FP_FRAC_SLL_4(X, 1); \
+ q >>= 1; \
+ } \
+ q = (_FP_W_TYPE)1 << (_FP_W_TYPE_SIZE - 1); \
+ while (q) \
+ { \
+ T##_f[1] = S##_f[1] + q; \
+ T##_f[2] = S##_f[2]; \
+ T##_f[3] = S##_f[3]; \
+ if (T##_f[3] < X##_f[3] || \
+ (T##_f[3] == X##_f[3] && (T##_f[2] < X##_f[2] || \
+ (T##_f[2] == X##_f[2] && T##_f[1] <= X##_f[1])))) \
+ { \
+ S##_f[1] = T##_f[1] + q; \
+ S##_f[2] += (T##_f[1] > S##_f[1]); \
+ S##_f[3] += (T##_f[2] > S##_f[2]); \
+ __FP_FRAC_DEC_3(X##_f[3], X##_f[2], X##_f[1], \
+ T##_f[3], T##_f[2], T##_f[1]); \
+ R##_f[1] += q; \
+ } \
+ _FP_FRAC_SLL_4(X, 1); \
+ q >>= 1; \
+ } \
+ q = (_FP_W_TYPE)1 << (_FP_W_TYPE_SIZE - 1); \
+ while (q != _FP_WORK_ROUND) \
+ { \
+ T##_f[0] = S##_f[0] + q; \
+ T##_f[1] = S##_f[1]; \
+ T##_f[2] = S##_f[2]; \
+ T##_f[3] = S##_f[3]; \
+ if (_FP_FRAC_GE_4(X,T)) \
+ { \
+ S##_f[0] = T##_f[0] + q; \
+ S##_f[1] += (T##_f[0] > S##_f[0]); \
+ S##_f[2] += (T##_f[1] > S##_f[1]); \
+ S##_f[3] += (T##_f[2] > S##_f[2]); \
+ _FP_FRAC_DEC_4(X, T); \
+ R##_f[0] += q; \
+ } \
+ _FP_FRAC_SLL_4(X, 1); \
+ q >>= 1; \
+ } \
+ if (!_FP_FRAC_ZEROP_4(X)) \
+ { \
+ if (_FP_FRAC_GT_4(X,S)) \
+ R##_f[0] |= _FP_WORK_ROUND; \
+ R##_f[0] |= _FP_WORK_STICKY; \
+ } \
+ } while (0)
+
+
+/*
+ * Internals
+ */
+
+#define __FP_FRAC_SET_4(X,I3,I2,I1,I0) \
+ (X##_f[3] = I3, X##_f[2] = I2, X##_f[1] = I1, X##_f[0] = I0)
+
+#ifndef __FP_FRAC_ADD_3
+#define __FP_FRAC_ADD_3(r2,r1,r0,x2,x1,x0,y2,y1,y0) \
+ do { \
+ _FP_W_TYPE _c1, _c2; \
+ r0 = x0 + y0; \
+ _c1 = r0 < x0; \
+ r1 = x1 + y1; \
+ _c2 = r1 < x1; \
+ r1 += _c1; \
+ _c2 |= r1 < _c1; \
+ r2 = x2 + y2 + _c2; \
+ } while (0)
+#endif
+
+#ifndef __FP_FRAC_ADD_4
+#define __FP_FRAC_ADD_4(r3,r2,r1,r0,x3,x2,x1,x0,y3,y2,y1,y0) \
+ do { \
+ _FP_W_TYPE _c1, _c2, _c3; \
+ r0 = x0 + y0; \
+ _c1 = r0 < x0; \
+ r1 = x1 + y1; \
+ _c2 = r1 < x1; \
+ r1 += _c1; \
+ _c2 |= r1 < _c1; \
+ r2 = x2 + y2; \
+ _c3 = r2 < x2; \
+ r2 += _c2; \
+ _c3 |= r2 < _c2; \
+ r3 = x3 + y3 + _c3; \
+ } while (0)
+#endif
+
+#ifndef __FP_FRAC_SUB_3
+#define __FP_FRAC_SUB_3(r2,r1,r0,x2,x1,x0,y2,y1,y0) \
+ do { \
+ _FP_W_TYPE _c1, _c2; \
+ r0 = x0 - y0; \
+ _c1 = r0 > x0; \
+ r1 = x1 - y1; \
+ _c2 = r1 > x1; \
+ r1 -= _c1; \
+ _c2 |= _c1 && (y1 == x1); \
+ r2 = x2 - y2 - _c2; \
+ } while (0)
+#endif
+
+#ifndef __FP_FRAC_SUB_4
+#define __FP_FRAC_SUB_4(r3,r2,r1,r0,x3,x2,x1,x0,y3,y2,y1,y0) \
+ do { \
+ _FP_W_TYPE _c1, _c2, _c3; \
+ r0 = x0 - y0; \
+ _c1 = r0 > x0; \
+ r1 = x1 - y1; \
+ _c2 = r1 > x1; \
+ r1 -= _c1; \
+ _c2 |= _c1 && (y1 == x1); \
+ r2 = x2 - y2; \
+ _c3 = r2 > x2; \
+ r2 -= _c2; \
+ _c3 |= _c2 && (y2 == x2); \
+ r3 = x3 - y3 - _c3; \
+ } while (0)
+#endif
+
+#ifndef __FP_FRAC_DEC_3
+#define __FP_FRAC_DEC_3(x2,x1,x0,y2,y1,y0) \
+ do { \
+ UWtype _t0, _t1, _t2; \
+ _t0 = x0, _t1 = x1, _t2 = x2; \
+ __FP_FRAC_SUB_3 (x2, x1, x0, _t2, _t1, _t0, y2, y1, y0); \
+ } while (0)
+#endif
+
+#ifndef __FP_FRAC_DEC_4
+#define __FP_FRAC_DEC_4(x3,x2,x1,x0,y3,y2,y1,y0) \
+ do { \
+ UWtype _t0, _t1, _t2, _t3; \
+ _t0 = x0, _t1 = x1, _t2 = x2, _t3 = x3; \
+ __FP_FRAC_SUB_4 (x3,x2,x1,x0,_t3,_t2,_t1,_t0, y3,y2,y1,y0); \
+ } while (0)
+#endif
+
+#ifndef __FP_FRAC_ADDI_4
+#define __FP_FRAC_ADDI_4(x3,x2,x1,x0,i) \
+ do { \
+ UWtype _t; \
+ _t = ((x0 += i) < i); \
+ x1 += _t; _t = (x1 < _t); \
+ x2 += _t; _t = (x2 < _t); \
+ x3 += _t; \
+ } while (0)
+#endif
+
+/* Convert FP values between word sizes. This appears to be more
+ * complicated than I'd have expected it to be, so these might be
+ * wrong... These macros are in any case somewhat bogus because they
+ * use information about what various FRAC_n variables look like
+ * internally [eg, that 2 word vars are X_f0 and x_f1]. But so do
+ * the ones in op-2.h and op-1.h.
+ */
+#define _FP_FRAC_COPY_1_4(D, S) (D##_f = S##_f[0])
+
+#define _FP_FRAC_COPY_2_4(D, S) \
+do { \
+ D##_f0 = S##_f[0]; \
+ D##_f1 = S##_f[1]; \
+} while (0)
+
+/* Assembly/disassembly for converting to/from integral types.
+ * No shifting or overflow handled here.
+ */
+/* Put the FP value X into r, which is an integer of size rsize. */
+#define _FP_FRAC_ASSEMBLE_4(r, X, rsize) \
+ do { \
+ if (rsize <= _FP_W_TYPE_SIZE) \
+ r = X##_f[0]; \
+ else if (rsize <= 2*_FP_W_TYPE_SIZE) \
+ { \
+ r = X##_f[1]; \
+ r <<= _FP_W_TYPE_SIZE; \
+ r += X##_f[0]; \
+ } \
+ else \
+ { \
+ /* I'm feeling lazy so we deal with int == 3words (implausible)*/ \
+ /* and int == 4words as a single case. */ \
+ r = X##_f[3]; \
+ r <<= _FP_W_TYPE_SIZE; \
+ r += X##_f[2]; \
+ r <<= _FP_W_TYPE_SIZE; \
+ r += X##_f[1]; \
+ r <<= _FP_W_TYPE_SIZE; \
+ r += X##_f[0]; \
+ } \
+ } while (0)
+
+/* "No disassemble Number Five!" */
+/* move an integer of size rsize into X's fractional part. We rely on
+ * the _f[] array consisting of words of size _FP_W_TYPE_SIZE to avoid
+ * having to mask the values we store into it.
+ */
+#define _FP_FRAC_DISASSEMBLE_4(X, r, rsize) \
+ do { \
+ X##_f[0] = r; \
+ X##_f[1] = (rsize <= _FP_W_TYPE_SIZE ? 0 : r >> _FP_W_TYPE_SIZE); \
+ X##_f[2] = (rsize <= 2*_FP_W_TYPE_SIZE ? 0 : r >> 2*_FP_W_TYPE_SIZE); \
+ X##_f[3] = (rsize <= 3*_FP_W_TYPE_SIZE ? 0 : r >> 3*_FP_W_TYPE_SIZE); \
+ } while (0);
+
+#define _FP_FRAC_COPY_4_1(D, S) \
+do { \
+ D##_f[0] = S##_f; \
+ D##_f[1] = D##_f[2] = D##_f[3] = 0; \
+} while (0)
+
+#define _FP_FRAC_COPY_4_2(D, S) \
+do { \
+ D##_f[0] = S##_f0; \
+ D##_f[1] = S##_f1; \
+ D##_f[2] = D##_f[3] = 0; \
+} while (0)
+
+#define _FP_FRAC_COPY_4_4(D,S) _FP_FRAC_COPY_4(D,S)
diff --git a/libc/sysdeps/linux/sparc/soft-fp/op-8.h b/libc/sysdeps/linux/sparc/soft-fp/op-8.h
new file mode 100644
index 000000000..be3e90d96
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/op-8.h
@@ -0,0 +1,110 @@
+/* Software floating-point emulation.
+ Basic eight-word fraction declaration and manipulation.
+ Copyright (C) 1997,1998,1999,2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com),
+ Jakub Jelinek (jj@ultra.linux.cz) and
+ Peter Maydell (pmaydell@chiark.greenend.org.uk).
+
+ 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 into
+ combinations with other programs, and to distribute those
+ combinations without any restriction coming from the use of this
+ file. (The Lesser General Public License restrictions do apply in
+ other respects; for example, they cover modification of the file,
+ and distribution when not linked into a combine executable.)
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+/* We need just a few things from here for op-4, if we ever need some
+ other macros, they can be added. */
+#define _FP_FRAC_DECL_8(X) _FP_W_TYPE X##_f[8]
+#define _FP_FRAC_HIGH_8(X) (X##_f[7])
+#define _FP_FRAC_LOW_8(X) (X##_f[0])
+#define _FP_FRAC_WORD_8(X,w) (X##_f[w])
+
+#define _FP_FRAC_SLL_8(X,N) \
+ do { \
+ _FP_I_TYPE _up, _down, _skip, _i; \
+ _skip = (N) / _FP_W_TYPE_SIZE; \
+ _up = (N) % _FP_W_TYPE_SIZE; \
+ _down = _FP_W_TYPE_SIZE - _up; \
+ if (!_up) \
+ for (_i = 7; _i >= _skip; --_i) \
+ X##_f[_i] = X##_f[_i-_skip]; \
+ else \
+ { \
+ for (_i = 7; _i > _skip; --_i) \
+ X##_f[_i] = X##_f[_i-_skip] << _up \
+ | X##_f[_i-_skip-1] >> _down; \
+ X##_f[_i--] = X##_f[0] << _up; \
+ } \
+ for (; _i >= 0; --_i) \
+ X##_f[_i] = 0; \
+ } while (0)
+
+#define _FP_FRAC_SRL_8(X,N) \
+ do { \
+ _FP_I_TYPE _up, _down, _skip, _i; \
+ _skip = (N) / _FP_W_TYPE_SIZE; \
+ _down = (N) % _FP_W_TYPE_SIZE; \
+ _up = _FP_W_TYPE_SIZE - _down; \
+ if (!_down) \
+ for (_i = 0; _i <= 7-_skip; ++_i) \
+ X##_f[_i] = X##_f[_i+_skip]; \
+ else \
+ { \
+ for (_i = 0; _i < 7-_skip; ++_i) \
+ X##_f[_i] = X##_f[_i+_skip] >> _down \
+ | X##_f[_i+_skip+1] << _up; \
+ X##_f[_i++] = X##_f[7] >> _down; \
+ } \
+ for (; _i < 8; ++_i) \
+ X##_f[_i] = 0; \
+ } while (0)
+
+
+/* Right shift with sticky-lsb.
+ * What this actually means is that we do a standard right-shift,
+ * but that if any of the bits that fall off the right hand side
+ * were one then we always set the LSbit.
+ */
+#define _FP_FRAC_SRS_8(X,N,size) \
+ do { \
+ _FP_I_TYPE _up, _down, _skip, _i; \
+ _FP_W_TYPE _s; \
+ _skip = (N) / _FP_W_TYPE_SIZE; \
+ _down = (N) % _FP_W_TYPE_SIZE; \
+ _up = _FP_W_TYPE_SIZE - _down; \
+ for (_s = _i = 0; _i < _skip; ++_i) \
+ _s |= X##_f[_i]; \
+ if (!_down) \
+ for (_i = 0; _i <= 7-_skip; ++_i) \
+ X##_f[_i] = X##_f[_i+_skip]; \
+ else \
+ { \
+ _s |= X##_f[_i] << _up; \
+ for (_i = 0; _i < 7-_skip; ++_i) \
+ X##_f[_i] = X##_f[_i+_skip] >> _down \
+ | X##_f[_i+_skip+1] << _up; \
+ X##_f[_i++] = X##_f[7] >> _down; \
+ } \
+ for (; _i < 8; ++_i) \
+ X##_f[_i] = 0; \
+ /* don't fix the LSB until the very end when we're sure f[0] is stable */ \
+ X##_f[0] |= (_s != 0); \
+ } while (0)
+
diff --git a/libc/sysdeps/linux/sparc/soft-fp/op-common.h b/libc/sysdeps/linux/sparc/soft-fp/op-common.h
new file mode 100644
index 000000000..b70026f90
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/op-common.h
@@ -0,0 +1,1358 @@
+/* Software floating-point emulation. Common operations.
+ Copyright (C) 1997,1998,1999,2006,2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com),
+ Jakub Jelinek (jj@ultra.linux.cz),
+ David S. Miller (davem@redhat.com) and
+ Peter Maydell (pmaydell@chiark.greenend.org.uk).
+
+ 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 into
+ combinations with other programs, and to distribute those
+ combinations without any restriction coming from the use of this
+ file. (The Lesser General Public License restrictions do apply in
+ other respects; for example, they cover modification of the file,
+ and distribution when not linked into a combine executable.)
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#define _FP_DECL(wc, X) \
+ _FP_I_TYPE X##_c __attribute__((unused)), X##_s, X##_e; \
+ _FP_FRAC_DECL_##wc(X)
+
+/*
+ * Finish truely unpacking a native fp value by classifying the kind
+ * of fp value and normalizing both the exponent and the fraction.
+ */
+
+#define _FP_UNPACK_CANONICAL(fs, wc, X) \
+do { \
+ switch (X##_e) \
+ { \
+ default: \
+ _FP_FRAC_HIGH_RAW_##fs(X) |= _FP_IMPLBIT_##fs; \
+ _FP_FRAC_SLL_##wc(X, _FP_WORKBITS); \
+ X##_e -= _FP_EXPBIAS_##fs; \
+ X##_c = FP_CLS_NORMAL; \
+ break; \
+ \
+ case 0: \
+ if (_FP_FRAC_ZEROP_##wc(X)) \
+ X##_c = FP_CLS_ZERO; \
+ else \
+ { \
+ /* a denormalized number */ \
+ _FP_I_TYPE _shift; \
+ _FP_FRAC_CLZ_##wc(_shift, X); \
+ _shift -= _FP_FRACXBITS_##fs; \
+ _FP_FRAC_SLL_##wc(X, (_shift+_FP_WORKBITS)); \
+ X##_e -= _FP_EXPBIAS_##fs - 1 + _shift; \
+ X##_c = FP_CLS_NORMAL; \
+ FP_SET_EXCEPTION(FP_EX_DENORM); \
+ } \
+ break; \
+ \
+ case _FP_EXPMAX_##fs: \
+ if (_FP_FRAC_ZEROP_##wc(X)) \
+ X##_c = FP_CLS_INF; \
+ else \
+ { \
+ X##_c = FP_CLS_NAN; \
+ /* Check for signaling NaN */ \
+ if (!(_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs)) \
+ FP_SET_EXCEPTION(FP_EX_INVALID); \
+ } \
+ break; \
+ } \
+} while (0)
+
+/* Finish unpacking an fp value in semi-raw mode: the mantissa is
+ shifted by _FP_WORKBITS but the implicit MSB is not inserted and
+ other classification is not done. */
+#define _FP_UNPACK_SEMIRAW(fs, wc, X) _FP_FRAC_SLL_##wc(X, _FP_WORKBITS)
+
+/* A semi-raw value has overflowed to infinity. Adjust the mantissa
+ and exponent appropriately. */
+#define _FP_OVERFLOW_SEMIRAW(fs, wc, X) \
+do { \
+ if (FP_ROUNDMODE == FP_RND_NEAREST \
+ || (FP_ROUNDMODE == FP_RND_PINF && !X##_s) \
+ || (FP_ROUNDMODE == FP_RND_MINF && X##_s)) \
+ { \
+ X##_e = _FP_EXPMAX_##fs; \
+ _FP_FRAC_SET_##wc(X, _FP_ZEROFRAC_##wc); \
+ } \
+ else \
+ { \
+ X##_e = _FP_EXPMAX_##fs - 1; \
+ _FP_FRAC_SET_##wc(X, _FP_MAXFRAC_##wc); \
+ } \
+ FP_SET_EXCEPTION(FP_EX_INEXACT); \
+ FP_SET_EXCEPTION(FP_EX_OVERFLOW); \
+} while (0)
+
+/* Check for a semi-raw value being a signaling NaN and raise the
+ invalid exception if so. */
+#define _FP_CHECK_SIGNAN_SEMIRAW(fs, wc, X) \
+do { \
+ if (X##_e == _FP_EXPMAX_##fs \
+ && !_FP_FRAC_ZEROP_##wc(X) \
+ && !(_FP_FRAC_HIGH_##fs(X) & _FP_QNANBIT_SH_##fs)) \
+ FP_SET_EXCEPTION(FP_EX_INVALID); \
+} while (0)
+
+/* Choose a NaN result from an operation on two semi-raw NaN
+ values. */
+#define _FP_CHOOSENAN_SEMIRAW(fs, wc, R, X, Y, OP) \
+do { \
+ /* _FP_CHOOSENAN expects raw values, so shift as required. */ \
+ _FP_FRAC_SRL_##wc(X, _FP_WORKBITS); \
+ _FP_FRAC_SRL_##wc(Y, _FP_WORKBITS); \
+ _FP_CHOOSENAN(fs, wc, R, X, Y, OP); \
+ _FP_FRAC_SLL_##wc(R, _FP_WORKBITS); \
+} while (0)
+
+/* Test whether a biased exponent is normal (not zero or maximum). */
+#define _FP_EXP_NORMAL(fs, wc, X) (((X##_e + 1) & _FP_EXPMAX_##fs) > 1)
+
+/* Prepare to pack an fp value in semi-raw mode: the mantissa is
+ rounded and shifted right, with the rounding possibly increasing
+ the exponent (including changing a finite value to infinity). */
+#define _FP_PACK_SEMIRAW(fs, wc, X) \
+do { \
+ _FP_ROUND(wc, X); \
+ if (_FP_FRAC_HIGH_##fs(X) \
+ & (_FP_OVERFLOW_##fs >> 1)) \
+ { \
+ _FP_FRAC_HIGH_##fs(X) &= ~(_FP_OVERFLOW_##fs >> 1); \
+ X##_e++; \
+ if (X##_e == _FP_EXPMAX_##fs) \
+ _FP_OVERFLOW_SEMIRAW(fs, wc, X); \
+ } \
+ _FP_FRAC_SRL_##wc(X, _FP_WORKBITS); \
+ if (!_FP_EXP_NORMAL(fs, wc, X) && !_FP_FRAC_ZEROP_##wc(X)) \
+ { \
+ if (X##_e == 0) \
+ FP_SET_EXCEPTION(FP_EX_UNDERFLOW); \
+ else \
+ { \
+ if (!_FP_KEEPNANFRACP) \
+ { \
+ _FP_FRAC_SET_##wc(X, _FP_NANFRAC_##fs); \
+ X##_s = _FP_NANSIGN_##fs; \
+ } \
+ else \
+ _FP_FRAC_HIGH_RAW_##fs(X) |= _FP_QNANBIT_##fs; \
+ } \
+ } \
+} while (0)
+
+/*
+ * Before packing the bits back into the native fp result, take care
+ * of such mundane things as rounding and overflow. Also, for some
+ * kinds of fp values, the original parts may not have been fully
+ * extracted -- but that is ok, we can regenerate them now.
+ */
+
+#define _FP_PACK_CANONICAL(fs, wc, X) \
+do { \
+ switch (X##_c) \
+ { \
+ case FP_CLS_NORMAL: \
+ X##_e += _FP_EXPBIAS_##fs; \
+ if (X##_e > 0) \
+ { \
+ _FP_ROUND(wc, X); \
+ if (_FP_FRAC_OVERP_##wc(fs, X)) \
+ { \
+ _FP_FRAC_CLEAR_OVERP_##wc(fs, X); \
+ X##_e++; \
+ } \
+ _FP_FRAC_SRL_##wc(X, _FP_WORKBITS); \
+ if (X##_e >= _FP_EXPMAX_##fs) \
+ { \
+ /* overflow */ \
+ switch (FP_ROUNDMODE) \
+ { \
+ case FP_RND_NEAREST: \
+ X##_c = FP_CLS_INF; \
+ break; \
+ case FP_RND_PINF: \
+ if (!X##_s) X##_c = FP_CLS_INF; \
+ break; \
+ case FP_RND_MINF: \
+ if (X##_s) X##_c = FP_CLS_INF; \
+ break; \
+ } \
+ if (X##_c == FP_CLS_INF) \
+ { \
+ /* Overflow to infinity */ \
+ X##_e = _FP_EXPMAX_##fs; \
+ _FP_FRAC_SET_##wc(X, _FP_ZEROFRAC_##wc); \
+ } \
+ else \
+ { \
+ /* Overflow to maximum normal */ \
+ X##_e = _FP_EXPMAX_##fs - 1; \
+ _FP_FRAC_SET_##wc(X, _FP_MAXFRAC_##wc); \
+ } \
+ FP_SET_EXCEPTION(FP_EX_OVERFLOW); \
+ FP_SET_EXCEPTION(FP_EX_INEXACT); \
+ } \
+ } \
+ else \
+ { \
+ /* we've got a denormalized number */ \
+ X##_e = -X##_e + 1; \
+ if (X##_e <= _FP_WFRACBITS_##fs) \
+ { \
+ _FP_FRAC_SRS_##wc(X, X##_e, _FP_WFRACBITS_##fs); \
+ _FP_ROUND(wc, X); \
+ if (_FP_FRAC_HIGH_##fs(X) \
+ & (_FP_OVERFLOW_##fs >> 1)) \
+ { \
+ X##_e = 1; \
+ _FP_FRAC_SET_##wc(X, _FP_ZEROFRAC_##wc); \
+ } \
+ else \
+ { \
+ X##_e = 0; \
+ _FP_FRAC_SRL_##wc(X, _FP_WORKBITS); \
+ FP_SET_EXCEPTION(FP_EX_UNDERFLOW); \
+ } \
+ } \
+ else \
+ { \
+ /* underflow to zero */ \
+ X##_e = 0; \
+ if (!_FP_FRAC_ZEROP_##wc(X)) \
+ { \
+ _FP_FRAC_SET_##wc(X, _FP_MINFRAC_##wc); \
+ _FP_ROUND(wc, X); \
+ _FP_FRAC_LOW_##wc(X) >>= (_FP_WORKBITS); \
+ } \
+ FP_SET_EXCEPTION(FP_EX_UNDERFLOW); \
+ } \
+ } \
+ break; \
+ \
+ case FP_CLS_ZERO: \
+ X##_e = 0; \
+ _FP_FRAC_SET_##wc(X, _FP_ZEROFRAC_##wc); \
+ break; \
+ \
+ case FP_CLS_INF: \
+ X##_e = _FP_EXPMAX_##fs; \
+ _FP_FRAC_SET_##wc(X, _FP_ZEROFRAC_##wc); \
+ break; \
+ \
+ case FP_CLS_NAN: \
+ X##_e = _FP_EXPMAX_##fs; \
+ if (!_FP_KEEPNANFRACP) \
+ { \
+ _FP_FRAC_SET_##wc(X, _FP_NANFRAC_##fs); \
+ X##_s = _FP_NANSIGN_##fs; \
+ } \
+ else \
+ _FP_FRAC_HIGH_RAW_##fs(X) |= _FP_QNANBIT_##fs; \
+ break; \
+ } \
+} while (0)
+
+/* This one accepts raw argument and not cooked, returns
+ * 1 if X is a signaling NaN.
+ */
+#define _FP_ISSIGNAN(fs, wc, X) \
+({ \
+ int __ret = 0; \
+ if (X##_e == _FP_EXPMAX_##fs) \
+ { \
+ if (!_FP_FRAC_ZEROP_##wc(X) \
+ && !(_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs)) \
+ __ret = 1; \
+ } \
+ __ret; \
+})
+
+
+
+
+
+/* Addition on semi-raw values. */
+#define _FP_ADD_INTERNAL(fs, wc, R, X, Y, OP) \
+do { \
+ if (X##_s == Y##_s) \
+ { \
+ /* Addition. */ \
+ R##_s = X##_s; \
+ int ediff = X##_e - Y##_e; \
+ if (ediff > 0) \
+ { \
+ R##_e = X##_e; \
+ if (Y##_e == 0) \
+ { \
+ /* Y is zero or denormalized. */ \
+ if (_FP_FRAC_ZEROP_##wc(Y)) \
+ { \
+ _FP_CHECK_SIGNAN_SEMIRAW(fs, wc, X); \
+ _FP_FRAC_COPY_##wc(R, X); \
+ goto add_done; \
+ } \
+ else \
+ { \
+ FP_SET_EXCEPTION(FP_EX_DENORM); \
+ ediff--; \
+ if (ediff == 0) \
+ { \
+ _FP_FRAC_ADD_##wc(R, X, Y); \
+ goto add3; \
+ } \
+ if (X##_e == _FP_EXPMAX_##fs) \
+ { \
+ _FP_CHECK_SIGNAN_SEMIRAW(fs, wc, X); \
+ _FP_FRAC_COPY_##wc(R, X); \
+ goto add_done; \
+ } \
+ goto add1; \
+ } \
+ } \
+ else if (X##_e == _FP_EXPMAX_##fs) \
+ { \
+ /* X is NaN or Inf, Y is normal. */ \
+ _FP_CHECK_SIGNAN_SEMIRAW(fs, wc, X); \
+ _FP_FRAC_COPY_##wc(R, X); \
+ goto add_done; \
+ } \
+ \
+ /* Insert implicit MSB of Y. */ \
+ _FP_FRAC_HIGH_##fs(Y) |= _FP_IMPLBIT_SH_##fs; \
+ \
+ add1: \
+ /* Shift the mantissa of Y to the right EDIFF steps; \
+ remember to account later for the implicit MSB of X. */ \
+ if (ediff <= _FP_WFRACBITS_##fs) \
+ _FP_FRAC_SRS_##wc(Y, ediff, _FP_WFRACBITS_##fs); \
+ else if (!_FP_FRAC_ZEROP_##wc(Y)) \
+ _FP_FRAC_SET_##wc(Y, _FP_MINFRAC_##wc); \
+ _FP_FRAC_ADD_##wc(R, X, Y); \
+ } \
+ else if (ediff < 0) \
+ { \
+ ediff = -ediff; \
+ R##_e = Y##_e; \
+ if (X##_e == 0) \
+ { \
+ /* X is zero or denormalized. */ \
+ if (_FP_FRAC_ZEROP_##wc(X)) \
+ { \
+ _FP_CHECK_SIGNAN_SEMIRAW(fs, wc, Y); \
+ _FP_FRAC_COPY_##wc(R, Y); \
+ goto add_done; \
+ } \
+ else \
+ { \
+ FP_SET_EXCEPTION(FP_EX_DENORM); \
+ ediff--; \
+ if (ediff == 0) \
+ { \
+ _FP_FRAC_ADD_##wc(R, Y, X); \
+ goto add3; \
+ } \
+ if (Y##_e == _FP_EXPMAX_##fs) \
+ { \
+ _FP_CHECK_SIGNAN_SEMIRAW(fs, wc, Y); \
+ _FP_FRAC_COPY_##wc(R, Y); \
+ goto add_done; \
+ } \
+ goto add2; \
+ } \
+ } \
+ else if (Y##_e == _FP_EXPMAX_##fs) \
+ { \
+ /* Y is NaN or Inf, X is normal. */ \
+ _FP_CHECK_SIGNAN_SEMIRAW(fs, wc, Y); \
+ _FP_FRAC_COPY_##wc(R, Y); \
+ goto add_done; \
+ } \
+ \
+ /* Insert implicit MSB of X. */ \
+ _FP_FRAC_HIGH_##fs(X) |= _FP_IMPLBIT_SH_##fs; \
+ \
+ add2: \
+ /* Shift the mantissa of X to the right EDIFF steps; \
+ remember to account later for the implicit MSB of Y. */ \
+ if (ediff <= _FP_WFRACBITS_##fs) \
+ _FP_FRAC_SRS_##wc(X, ediff, _FP_WFRACBITS_##fs); \
+ else if (!_FP_FRAC_ZEROP_##wc(X)) \
+ _FP_FRAC_SET_##wc(X, _FP_MINFRAC_##wc); \
+ _FP_FRAC_ADD_##wc(R, Y, X); \
+ } \
+ else \
+ { \
+ /* ediff == 0. */ \
+ if (!_FP_EXP_NORMAL(fs, wc, X)) \
+ { \
+ if (X##_e == 0) \
+ { \
+ /* X and Y are zero or denormalized. */ \
+ R##_e = 0; \
+ if (_FP_FRAC_ZEROP_##wc(X)) \
+ { \
+ if (!_FP_FRAC_ZEROP_##wc(Y)) \
+ FP_SET_EXCEPTION(FP_EX_DENORM); \
+ _FP_FRAC_COPY_##wc(R, Y); \
+ goto add_done; \
+ } \
+ else if (_FP_FRAC_ZEROP_##wc(Y)) \
+ { \
+ FP_SET_EXCEPTION(FP_EX_DENORM); \
+ _FP_FRAC_COPY_##wc(R, X); \
+ goto add_done; \
+ } \
+ else \
+ { \
+ FP_SET_EXCEPTION(FP_EX_DENORM); \
+ _FP_FRAC_ADD_##wc(R, X, Y); \
+ if (_FP_FRAC_HIGH_##fs(R) & _FP_IMPLBIT_SH_##fs) \
+ { \
+ /* Normalized result. */ \
+ _FP_FRAC_HIGH_##fs(R) \
+ &= ~(_FP_W_TYPE)_FP_IMPLBIT_SH_##fs; \
+ R##_e = 1; \
+ } \
+ goto add_done; \
+ } \
+ } \
+ else \
+ { \
+ /* X and Y are NaN or Inf. */ \
+ _FP_CHECK_SIGNAN_SEMIRAW(fs, wc, X); \
+ _FP_CHECK_SIGNAN_SEMIRAW(fs, wc, Y); \
+ R##_e = _FP_EXPMAX_##fs; \
+ if (_FP_FRAC_ZEROP_##wc(X)) \
+ _FP_FRAC_COPY_##wc(R, Y); \
+ else if (_FP_FRAC_ZEROP_##wc(Y)) \
+ _FP_FRAC_COPY_##wc(R, X); \
+ else \
+ _FP_CHOOSENAN_SEMIRAW(fs, wc, R, X, Y, OP); \
+ goto add_done; \
+ } \
+ } \
+ /* The exponents of X and Y, both normal, are equal. The \
+ implicit MSBs will always add to increase the \
+ exponent. */ \
+ _FP_FRAC_ADD_##wc(R, X, Y); \
+ R##_e = X##_e + 1; \
+ _FP_FRAC_SRS_##wc(R, 1, _FP_WFRACBITS_##fs); \
+ if (R##_e == _FP_EXPMAX_##fs) \
+ /* Overflow to infinity (depending on rounding mode). */ \
+ _FP_OVERFLOW_SEMIRAW(fs, wc, R); \
+ goto add_done; \
+ } \
+ add3: \
+ if (_FP_FRAC_HIGH_##fs(R) & _FP_IMPLBIT_SH_##fs) \
+ { \
+ /* Overflow. */ \
+ _FP_FRAC_HIGH_##fs(R) &= ~(_FP_W_TYPE)_FP_IMPLBIT_SH_##fs; \
+ R##_e++; \
+ _FP_FRAC_SRS_##wc(R, 1, _FP_WFRACBITS_##fs); \
+ if (R##_e == _FP_EXPMAX_##fs) \
+ /* Overflow to infinity (depending on rounding mode). */ \
+ _FP_OVERFLOW_SEMIRAW(fs, wc, R); \
+ } \
+ add_done: ; \
+ } \
+ else \
+ { \
+ /* Subtraction. */ \
+ int ediff = X##_e - Y##_e; \
+ if (ediff > 0) \
+ { \
+ R##_e = X##_e; \
+ R##_s = X##_s; \
+ if (Y##_e == 0) \
+ { \
+ /* Y is zero or denormalized. */ \
+ if (_FP_FRAC_ZEROP_##wc(Y)) \
+ { \
+ _FP_CHECK_SIGNAN_SEMIRAW(fs, wc, X); \
+ _FP_FRAC_COPY_##wc(R, X); \
+ goto sub_done; \
+ } \
+ else \
+ { \
+ FP_SET_EXCEPTION(FP_EX_DENORM); \
+ ediff--; \
+ if (ediff == 0) \
+ { \
+ _FP_FRAC_SUB_##wc(R, X, Y); \
+ goto sub3; \
+ } \
+ if (X##_e == _FP_EXPMAX_##fs) \
+ { \
+ _FP_CHECK_SIGNAN_SEMIRAW(fs, wc, X); \
+ _FP_FRAC_COPY_##wc(R, X); \
+ goto sub_done; \
+ } \
+ goto sub1; \
+ } \
+ } \
+ else if (X##_e == _FP_EXPMAX_##fs) \
+ { \
+ /* X is NaN or Inf, Y is normal. */ \
+ _FP_CHECK_SIGNAN_SEMIRAW(fs, wc, X); \
+ _FP_FRAC_COPY_##wc(R, X); \
+ goto sub_done; \
+ } \
+ \
+ /* Insert implicit MSB of Y. */ \
+ _FP_FRAC_HIGH_##fs(Y) |= _FP_IMPLBIT_SH_##fs; \
+ \
+ sub1: \
+ /* Shift the mantissa of Y to the right EDIFF steps; \
+ remember to account later for the implicit MSB of X. */ \
+ if (ediff <= _FP_WFRACBITS_##fs) \
+ _FP_FRAC_SRS_##wc(Y, ediff, _FP_WFRACBITS_##fs); \
+ else if (!_FP_FRAC_ZEROP_##wc(Y)) \
+ _FP_FRAC_SET_##wc(Y, _FP_MINFRAC_##wc); \
+ _FP_FRAC_SUB_##wc(R, X, Y); \
+ } \
+ else if (ediff < 0) \
+ { \
+ ediff = -ediff; \
+ R##_e = Y##_e; \
+ R##_s = Y##_s; \
+ if (X##_e == 0) \
+ { \
+ /* X is zero or denormalized. */ \
+ if (_FP_FRAC_ZEROP_##wc(X)) \
+ { \
+ _FP_CHECK_SIGNAN_SEMIRAW(fs, wc, Y); \
+ _FP_FRAC_COPY_##wc(R, Y); \
+ goto sub_done; \
+ } \
+ else \
+ { \
+ FP_SET_EXCEPTION(FP_EX_DENORM); \
+ ediff--; \
+ if (ediff == 0) \
+ { \
+ _FP_FRAC_SUB_##wc(R, Y, X); \
+ goto sub3; \
+ } \
+ if (Y##_e == _FP_EXPMAX_##fs) \
+ { \
+ _FP_CHECK_SIGNAN_SEMIRAW(fs, wc, Y); \
+ _FP_FRAC_COPY_##wc(R, Y); \
+ goto sub_done; \
+ } \
+ goto sub2; \
+ } \
+ } \
+ else if (Y##_e == _FP_EXPMAX_##fs) \
+ { \
+ /* Y is NaN or Inf, X is normal. */ \
+ _FP_CHECK_SIGNAN_SEMIRAW(fs, wc, Y); \
+ _FP_FRAC_COPY_##wc(R, Y); \
+ goto sub_done; \
+ } \
+ \
+ /* Insert implicit MSB of X. */ \
+ _FP_FRAC_HIGH_##fs(X) |= _FP_IMPLBIT_SH_##fs; \
+ \
+ sub2: \
+ /* Shift the mantissa of X to the right EDIFF steps; \
+ remember to account later for the implicit MSB of Y. */ \
+ if (ediff <= _FP_WFRACBITS_##fs) \
+ _FP_FRAC_SRS_##wc(X, ediff, _FP_WFRACBITS_##fs); \
+ else if (!_FP_FRAC_ZEROP_##wc(X)) \
+ _FP_FRAC_SET_##wc(X, _FP_MINFRAC_##wc); \
+ _FP_FRAC_SUB_##wc(R, Y, X); \
+ } \
+ else \
+ { \
+ /* ediff == 0. */ \
+ if (!_FP_EXP_NORMAL(fs, wc, X)) \
+ { \
+ if (X##_e == 0) \
+ { \
+ /* X and Y are zero or denormalized. */ \
+ R##_e = 0; \
+ if (_FP_FRAC_ZEROP_##wc(X)) \
+ { \
+ _FP_FRAC_COPY_##wc(R, Y); \
+ if (_FP_FRAC_ZEROP_##wc(Y)) \
+ R##_s = (FP_ROUNDMODE == FP_RND_MINF); \
+ else \
+ { \
+ FP_SET_EXCEPTION(FP_EX_DENORM); \
+ R##_s = Y##_s; \
+ } \
+ goto sub_done; \
+ } \
+ else if (_FP_FRAC_ZEROP_##wc(Y)) \
+ { \
+ FP_SET_EXCEPTION(FP_EX_DENORM); \
+ _FP_FRAC_COPY_##wc(R, X); \
+ R##_s = X##_s; \
+ goto sub_done; \
+ } \
+ else \
+ { \
+ FP_SET_EXCEPTION(FP_EX_DENORM); \
+ _FP_FRAC_SUB_##wc(R, X, Y); \
+ R##_s = X##_s; \
+ if (_FP_FRAC_HIGH_##fs(R) & _FP_IMPLBIT_SH_##fs) \
+ { \
+ /* |X| < |Y|, negate result. */ \
+ _FP_FRAC_SUB_##wc(R, Y, X); \
+ R##_s = Y##_s; \
+ } \
+ else if (_FP_FRAC_ZEROP_##wc(R)) \
+ R##_s = (FP_ROUNDMODE == FP_RND_MINF); \
+ goto sub_done; \
+ } \
+ } \
+ else \
+ { \
+ /* X and Y are NaN or Inf, of opposite signs. */ \
+ _FP_CHECK_SIGNAN_SEMIRAW(fs, wc, X); \
+ _FP_CHECK_SIGNAN_SEMIRAW(fs, wc, Y); \
+ R##_e = _FP_EXPMAX_##fs; \
+ if (_FP_FRAC_ZEROP_##wc(X)) \
+ { \
+ if (_FP_FRAC_ZEROP_##wc(Y)) \
+ { \
+ /* Inf - Inf. */ \
+ R##_s = _FP_NANSIGN_##fs; \
+ _FP_FRAC_SET_##wc(R, _FP_NANFRAC_##fs); \
+ _FP_FRAC_SLL_##wc(R, _FP_WORKBITS); \
+ FP_SET_EXCEPTION(FP_EX_INVALID); \
+ } \
+ else \
+ { \
+ /* Inf - NaN. */ \
+ R##_s = Y##_s; \
+ _FP_FRAC_COPY_##wc(R, Y); \
+ } \
+ } \
+ else \
+ { \
+ if (_FP_FRAC_ZEROP_##wc(Y)) \
+ { \
+ /* NaN - Inf. */ \
+ R##_s = X##_s; \
+ _FP_FRAC_COPY_##wc(R, X); \
+ } \
+ else \
+ { \
+ /* NaN - NaN. */ \
+ _FP_CHOOSENAN_SEMIRAW(fs, wc, R, X, Y, OP); \
+ } \
+ } \
+ goto sub_done; \
+ } \
+ } \
+ /* The exponents of X and Y, both normal, are equal. The \
+ implicit MSBs cancel. */ \
+ R##_e = X##_e; \
+ _FP_FRAC_SUB_##wc(R, X, Y); \
+ R##_s = X##_s; \
+ if (_FP_FRAC_HIGH_##fs(R) & _FP_IMPLBIT_SH_##fs) \
+ { \
+ /* |X| < |Y|, negate result. */ \
+ _FP_FRAC_SUB_##wc(R, Y, X); \
+ R##_s = Y##_s; \
+ } \
+ else if (_FP_FRAC_ZEROP_##wc(R)) \
+ { \
+ R##_e = 0; \
+ R##_s = (FP_ROUNDMODE == FP_RND_MINF); \
+ goto sub_done; \
+ } \
+ goto norm; \
+ } \
+ sub3: \
+ if (_FP_FRAC_HIGH_##fs(R) & _FP_IMPLBIT_SH_##fs) \
+ { \
+ int diff; \
+ /* Carry into most significant bit of larger one of X and Y, \
+ canceling it; renormalize. */ \
+ _FP_FRAC_HIGH_##fs(R) &= _FP_IMPLBIT_SH_##fs - 1; \
+ norm: \
+ _FP_FRAC_CLZ_##wc(diff, R); \
+ diff -= _FP_WFRACXBITS_##fs; \
+ _FP_FRAC_SLL_##wc(R, diff); \
+ if (R##_e <= diff) \
+ { \
+ /* R is denormalized. */ \
+ diff = diff - R##_e + 1; \
+ _FP_FRAC_SRS_##wc(R, diff, _FP_WFRACBITS_##fs); \
+ R##_e = 0; \
+ } \
+ else \
+ { \
+ R##_e -= diff; \
+ _FP_FRAC_HIGH_##fs(R) &= ~(_FP_W_TYPE)_FP_IMPLBIT_SH_##fs; \
+ } \
+ } \
+ sub_done: ; \
+ } \
+} while (0)
+
+#define _FP_ADD(fs, wc, R, X, Y) _FP_ADD_INTERNAL(fs, wc, R, X, Y, '+')
+#define _FP_SUB(fs, wc, R, X, Y) \
+ do { \
+ if (!(Y##_e == _FP_EXPMAX_##fs && !_FP_FRAC_ZEROP_##wc(Y))) Y##_s ^= 1; \
+ _FP_ADD_INTERNAL(fs, wc, R, X, Y, '-'); \
+ } while (0)
+
+
+/*
+ * Main negation routine. FIXME -- when we care about setting exception
+ * bits reliably, this will not do. We should examine all of the fp classes.
+ */
+
+#define _FP_NEG(fs, wc, R, X) \
+ do { \
+ _FP_FRAC_COPY_##wc(R, X); \
+ R##_c = X##_c; \
+ R##_e = X##_e; \
+ R##_s = 1 ^ X##_s; \
+ } while (0)
+
+
+/*
+ * Main multiplication routine. The input values should be cooked.
+ */
+
+#define _FP_MUL(fs, wc, R, X, Y) \
+do { \
+ R##_s = X##_s ^ Y##_s; \
+ switch (_FP_CLS_COMBINE(X##_c, Y##_c)) \
+ { \
+ case _FP_CLS_COMBINE(FP_CLS_NORMAL,FP_CLS_NORMAL): \
+ R##_c = FP_CLS_NORMAL; \
+ R##_e = X##_e + Y##_e + 1; \
+ \
+ _FP_MUL_MEAT_##fs(R,X,Y); \
+ \
+ if (_FP_FRAC_OVERP_##wc(fs, R)) \
+ _FP_FRAC_SRS_##wc(R, 1, _FP_WFRACBITS_##fs); \
+ else \
+ R##_e--; \
+ break; \
+ \
+ case _FP_CLS_COMBINE(FP_CLS_NAN,FP_CLS_NAN): \
+ _FP_CHOOSENAN(fs, wc, R, X, Y, '*'); \
+ break; \
+ \
+ case _FP_CLS_COMBINE(FP_CLS_NAN,FP_CLS_NORMAL): \
+ case _FP_CLS_COMBINE(FP_CLS_NAN,FP_CLS_INF): \
+ case _FP_CLS_COMBINE(FP_CLS_NAN,FP_CLS_ZERO): \
+ R##_s = X##_s; \
+ \
+ case _FP_CLS_COMBINE(FP_CLS_INF,FP_CLS_INF): \
+ case _FP_CLS_COMBINE(FP_CLS_INF,FP_CLS_NORMAL): \
+ case _FP_CLS_COMBINE(FP_CLS_ZERO,FP_CLS_NORMAL): \
+ case _FP_CLS_COMBINE(FP_CLS_ZERO,FP_CLS_ZERO): \
+ _FP_FRAC_COPY_##wc(R, X); \
+ R##_c = X##_c; \
+ break; \
+ \
+ case _FP_CLS_COMBINE(FP_CLS_NORMAL,FP_CLS_NAN): \
+ case _FP_CLS_COMBINE(FP_CLS_INF,FP_CLS_NAN): \
+ case _FP_CLS_COMBINE(FP_CLS_ZERO,FP_CLS_NAN): \
+ R##_s = Y##_s; \
+ \
+ case _FP_CLS_COMBINE(FP_CLS_NORMAL,FP_CLS_INF): \
+ case _FP_CLS_COMBINE(FP_CLS_NORMAL,FP_CLS_ZERO): \
+ _FP_FRAC_COPY_##wc(R, Y); \
+ R##_c = Y##_c; \
+ break; \
+ \
+ case _FP_CLS_COMBINE(FP_CLS_INF,FP_CLS_ZERO): \
+ case _FP_CLS_COMBINE(FP_CLS_ZERO,FP_CLS_INF): \
+ R##_s = _FP_NANSIGN_##fs; \
+ R##_c = FP_CLS_NAN; \
+ _FP_FRAC_SET_##wc(R, _FP_NANFRAC_##fs); \
+ FP_SET_EXCEPTION(FP_EX_INVALID); \
+ break; \
+ \
+ default: \
+ abort(); \
+ } \
+} while (0)
+
+
+/*
+ * Main division routine. The input values should be cooked.
+ */
+
+#define _FP_DIV(fs, wc, R, X, Y) \
+do { \
+ R##_s = X##_s ^ Y##_s; \
+ switch (_FP_CLS_COMBINE(X##_c, Y##_c)) \
+ { \
+ case _FP_CLS_COMBINE(FP_CLS_NORMAL,FP_CLS_NORMAL): \
+ R##_c = FP_CLS_NORMAL; \
+ R##_e = X##_e - Y##_e; \
+ \
+ _FP_DIV_MEAT_##fs(R,X,Y); \
+ break; \
+ \
+ case _FP_CLS_COMBINE(FP_CLS_NAN,FP_CLS_NAN): \
+ _FP_CHOOSENAN(fs, wc, R, X, Y, '/'); \
+ break; \
+ \
+ case _FP_CLS_COMBINE(FP_CLS_NAN,FP_CLS_NORMAL): \
+ case _FP_CLS_COMBINE(FP_CLS_NAN,FP_CLS_INF): \
+ case _FP_CLS_COMBINE(FP_CLS_NAN,FP_CLS_ZERO): \
+ R##_s = X##_s; \
+ _FP_FRAC_COPY_##wc(R, X); \
+ R##_c = X##_c; \
+ break; \
+ \
+ case _FP_CLS_COMBINE(FP_CLS_NORMAL,FP_CLS_NAN): \
+ case _FP_CLS_COMBINE(FP_CLS_INF,FP_CLS_NAN): \
+ case _FP_CLS_COMBINE(FP_CLS_ZERO,FP_CLS_NAN): \
+ R##_s = Y##_s; \
+ _FP_FRAC_COPY_##wc(R, Y); \
+ R##_c = Y##_c; \
+ break; \
+ \
+ case _FP_CLS_COMBINE(FP_CLS_NORMAL,FP_CLS_INF): \
+ case _FP_CLS_COMBINE(FP_CLS_ZERO,FP_CLS_INF): \
+ case _FP_CLS_COMBINE(FP_CLS_ZERO,FP_CLS_NORMAL): \
+ R##_c = FP_CLS_ZERO; \
+ break; \
+ \
+ case _FP_CLS_COMBINE(FP_CLS_NORMAL,FP_CLS_ZERO): \
+ FP_SET_EXCEPTION(FP_EX_DIVZERO); \
+ case _FP_CLS_COMBINE(FP_CLS_INF,FP_CLS_ZERO): \
+ case _FP_CLS_COMBINE(FP_CLS_INF,FP_CLS_NORMAL): \
+ R##_c = FP_CLS_INF; \
+ break; \
+ \
+ case _FP_CLS_COMBINE(FP_CLS_INF,FP_CLS_INF): \
+ case _FP_CLS_COMBINE(FP_CLS_ZERO,FP_CLS_ZERO): \
+ R##_s = _FP_NANSIGN_##fs; \
+ R##_c = FP_CLS_NAN; \
+ _FP_FRAC_SET_##wc(R, _FP_NANFRAC_##fs); \
+ FP_SET_EXCEPTION(FP_EX_INVALID); \
+ break; \
+ \
+ default: \
+ abort(); \
+ } \
+} while (0)
+
+
+/*
+ * Main differential comparison routine. The inputs should be raw not
+ * cooked. The return is -1,0,1 for normal values, 2 otherwise.
+ */
+
+#define _FP_CMP(fs, wc, ret, X, Y, un) \
+ do { \
+ /* NANs are unordered */ \
+ if ((X##_e == _FP_EXPMAX_##fs && !_FP_FRAC_ZEROP_##wc(X)) \
+ || (Y##_e == _FP_EXPMAX_##fs && !_FP_FRAC_ZEROP_##wc(Y))) \
+ { \
+ ret = un; \
+ } \
+ else \
+ { \
+ int __is_zero_x; \
+ int __is_zero_y; \
+ \
+ __is_zero_x = (!X##_e && _FP_FRAC_ZEROP_##wc(X)) ? 1 : 0; \
+ __is_zero_y = (!Y##_e && _FP_FRAC_ZEROP_##wc(Y)) ? 1 : 0; \
+ \
+ if (__is_zero_x && __is_zero_y) \
+ ret = 0; \
+ else if (__is_zero_x) \
+ ret = Y##_s ? 1 : -1; \
+ else if (__is_zero_y) \
+ ret = X##_s ? -1 : 1; \
+ else if (X##_s != Y##_s) \
+ ret = X##_s ? -1 : 1; \
+ else if (X##_e > Y##_e) \
+ ret = X##_s ? -1 : 1; \
+ else if (X##_e < Y##_e) \
+ ret = X##_s ? 1 : -1; \
+ else if (_FP_FRAC_GT_##wc(X, Y)) \
+ ret = X##_s ? -1 : 1; \
+ else if (_FP_FRAC_GT_##wc(Y, X)) \
+ ret = X##_s ? 1 : -1; \
+ else \
+ ret = 0; \
+ } \
+ } while (0)
+
+
+/* Simplification for strict equality. */
+
+#define _FP_CMP_EQ(fs, wc, ret, X, Y) \
+ do { \
+ /* NANs are unordered */ \
+ if ((X##_e == _FP_EXPMAX_##fs && !_FP_FRAC_ZEROP_##wc(X)) \
+ || (Y##_e == _FP_EXPMAX_##fs && !_FP_FRAC_ZEROP_##wc(Y))) \
+ { \
+ ret = 1; \
+ } \
+ else \
+ { \
+ ret = !(X##_e == Y##_e \
+ && _FP_FRAC_EQ_##wc(X, Y) \
+ && (X##_s == Y##_s || (!X##_e && _FP_FRAC_ZEROP_##wc(X)))); \
+ } \
+ } while (0)
+
+/* Version to test unordered. */
+
+#define _FP_CMP_UNORD(fs, wc, ret, X, Y) \
+ do { \
+ ret = ((X##_e == _FP_EXPMAX_##fs && !_FP_FRAC_ZEROP_##wc(X)) \
+ || (Y##_e == _FP_EXPMAX_##fs && !_FP_FRAC_ZEROP_##wc(Y))); \
+ } while (0)
+
+/*
+ * Main square root routine. The input value should be cooked.
+ */
+
+#define _FP_SQRT(fs, wc, R, X) \
+do { \
+ _FP_FRAC_DECL_##wc(T); _FP_FRAC_DECL_##wc(S); \
+ _FP_W_TYPE q; \
+ switch (X##_c) \
+ { \
+ case FP_CLS_NAN: \
+ _FP_FRAC_COPY_##wc(R, X); \
+ R##_s = X##_s; \
+ R##_c = FP_CLS_NAN; \
+ break; \
+ case FP_CLS_INF: \
+ if (X##_s) \
+ { \
+ R##_s = _FP_NANSIGN_##fs; \
+ R##_c = FP_CLS_NAN; /* NAN */ \
+ _FP_FRAC_SET_##wc(R, _FP_NANFRAC_##fs); \
+ FP_SET_EXCEPTION(FP_EX_INVALID); \
+ } \
+ else \
+ { \
+ R##_s = 0; \
+ R##_c = FP_CLS_INF; /* sqrt(+inf) = +inf */ \
+ } \
+ break; \
+ case FP_CLS_ZERO: \
+ R##_s = X##_s; \
+ R##_c = FP_CLS_ZERO; /* sqrt(+-0) = +-0 */ \
+ break; \
+ case FP_CLS_NORMAL: \
+ R##_s = 0; \
+ if (X##_s) \
+ { \
+ R##_c = FP_CLS_NAN; /* sNAN */ \
+ R##_s = _FP_NANSIGN_##fs; \
+ _FP_FRAC_SET_##wc(R, _FP_NANFRAC_##fs); \
+ FP_SET_EXCEPTION(FP_EX_INVALID); \
+ break; \
+ } \
+ R##_c = FP_CLS_NORMAL; \
+ if (X##_e & 1) \
+ _FP_FRAC_SLL_##wc(X, 1); \
+ R##_e = X##_e >> 1; \
+ _FP_FRAC_SET_##wc(S, _FP_ZEROFRAC_##wc); \
+ _FP_FRAC_SET_##wc(R, _FP_ZEROFRAC_##wc); \
+ q = _FP_OVERFLOW_##fs >> 1; \
+ _FP_SQRT_MEAT_##wc(R, S, T, X, q); \
+ } \
+ } while (0)
+
+/*
+ * Convert from FP to integer. Input is raw.
+ */
+
+/* RSIGNED can have following values:
+ * 0: the number is required to be 0..(2^rsize)-1, if not, NV is set plus
+ * the result is either 0 or (2^rsize)-1 depending on the sign in such
+ * case.
+ * 1: the number is required to be -(2^(rsize-1))..(2^(rsize-1))-1, if not,
+ * NV is set plus the result is either -(2^(rsize-1)) or (2^(rsize-1))-1
+ * depending on the sign in such case.
+ * -1: the number is required to be -(2^(rsize-1))..(2^rsize)-1, if not, NV is
+ * set plus the result is either -(2^(rsize-1)) or (2^(rsize-1))-1
+ * depending on the sign in such case.
+ */
+#define _FP_TO_INT(fs, wc, r, X, rsize, rsigned) \
+do { \
+ if (X##_e < _FP_EXPBIAS_##fs) \
+ { \
+ r = 0; \
+ if (X##_e == 0) \
+ { \
+ if (!_FP_FRAC_ZEROP_##wc(X)) \
+ { \
+ FP_SET_EXCEPTION(FP_EX_INEXACT); \
+ FP_SET_EXCEPTION(FP_EX_DENORM); \
+ } \
+ } \
+ else \
+ FP_SET_EXCEPTION(FP_EX_INEXACT); \
+ } \
+ else if (X##_e >= _FP_EXPBIAS_##fs + rsize - (rsigned > 0 || X##_s) \
+ || (!rsigned && X##_s)) \
+ { \
+ /* Overflow or converting to the most negative integer. */ \
+ if (rsigned) \
+ { \
+ r = 1; \
+ r <<= rsize - 1; \
+ r -= 1 - X##_s; \
+ } else { \
+ r = 0; \
+ if (X##_s) \
+ r = ~r; \
+ } \
+ \
+ if (rsigned && X##_s && X##_e == _FP_EXPBIAS_##fs + rsize - 1) \
+ { \
+ /* Possibly converting to most negative integer; check the \
+ mantissa. */ \
+ int inexact = 0; \
+ (void)((_FP_FRACBITS_##fs > rsize) \
+ ? ({ _FP_FRAC_SRST_##wc(X, inexact, \
+ _FP_FRACBITS_##fs - rsize, \
+ _FP_FRACBITS_##fs); 0; }) \
+ : 0); \
+ if (!_FP_FRAC_ZEROP_##wc(X)) \
+ FP_SET_EXCEPTION(FP_EX_INVALID); \
+ else if (inexact) \
+ FP_SET_EXCEPTION(FP_EX_INEXACT); \
+ } \
+ else \
+ FP_SET_EXCEPTION(FP_EX_INVALID); \
+ } \
+ else \
+ { \
+ _FP_FRAC_HIGH_RAW_##fs(X) |= _FP_IMPLBIT_##fs; \
+ if (X##_e >= _FP_EXPBIAS_##fs + _FP_FRACBITS_##fs - 1) \
+ { \
+ _FP_FRAC_ASSEMBLE_##wc(r, X, rsize); \
+ r <<= X##_e - _FP_EXPBIAS_##fs - _FP_FRACBITS_##fs + 1; \
+ } \
+ else \
+ { \
+ int inexact; \
+ _FP_FRAC_SRST_##wc(X, inexact, \
+ (_FP_FRACBITS_##fs + _FP_EXPBIAS_##fs - 1 \
+ - X##_e), \
+ _FP_FRACBITS_##fs); \
+ if (inexact) \
+ FP_SET_EXCEPTION(FP_EX_INEXACT); \
+ _FP_FRAC_ASSEMBLE_##wc(r, X, rsize); \
+ } \
+ if (rsigned && X##_s) \
+ r = -r; \
+ } \
+} while (0)
+
+/* Convert integer to fp. Output is raw. RTYPE is unsigned even if
+ input is signed. */
+#define _FP_FROM_INT(fs, wc, X, r, rsize, rtype) \
+ do { \
+ if (r) \
+ { \
+ rtype ur_; \
+ \
+ if ((X##_s = (r < 0))) \
+ r = -(rtype)r; \
+ \
+ ur_ = (rtype) r; \
+ (void)((rsize <= _FP_W_TYPE_SIZE) \
+ ? ({ \
+ int lz_; \
+ __FP_CLZ(lz_, (_FP_W_TYPE)ur_); \
+ X##_e = _FP_EXPBIAS_##fs + _FP_W_TYPE_SIZE - 1 - lz_; \
+ }) \
+ : ((rsize <= 2 * _FP_W_TYPE_SIZE) \
+ ? ({ \
+ int lz_; \
+ __FP_CLZ_2(lz_, (_FP_W_TYPE)(ur_ >> _FP_W_TYPE_SIZE), \
+ (_FP_W_TYPE)ur_); \
+ X##_e = (_FP_EXPBIAS_##fs + 2 * _FP_W_TYPE_SIZE - 1 \
+ - lz_); \
+ }) \
+ : (abort(), 0))); \
+ \
+ if (rsize - 1 + _FP_EXPBIAS_##fs >= _FP_EXPMAX_##fs \
+ && X##_e >= _FP_EXPMAX_##fs) \
+ { \
+ /* Exponent too big; overflow to infinity. (May also \
+ happen after rounding below.) */ \
+ _FP_OVERFLOW_SEMIRAW(fs, wc, X); \
+ goto pack_semiraw; \
+ } \
+ \
+ if (rsize <= _FP_FRACBITS_##fs \
+ || X##_e < _FP_EXPBIAS_##fs + _FP_FRACBITS_##fs) \
+ { \
+ /* Exactly representable; shift left. */ \
+ _FP_FRAC_DISASSEMBLE_##wc(X, ur_, rsize); \
+ _FP_FRAC_SLL_##wc(X, (_FP_EXPBIAS_##fs \
+ + _FP_FRACBITS_##fs - 1 - X##_e)); \
+ } \
+ else \
+ { \
+ /* More bits in integer than in floating type; need to \
+ round. */ \
+ if (_FP_EXPBIAS_##fs + _FP_WFRACBITS_##fs - 1 < X##_e) \
+ ur_ = ((ur_ >> (X##_e - _FP_EXPBIAS_##fs \
+ - _FP_WFRACBITS_##fs + 1)) \
+ | ((ur_ << (rsize - (X##_e - _FP_EXPBIAS_##fs \
+ - _FP_WFRACBITS_##fs + 1))) \
+ != 0)); \
+ _FP_FRAC_DISASSEMBLE_##wc(X, ur_, rsize); \
+ if ((_FP_EXPBIAS_##fs + _FP_WFRACBITS_##fs - 1 - X##_e) > 0) \
+ _FP_FRAC_SLL_##wc(X, (_FP_EXPBIAS_##fs \
+ + _FP_WFRACBITS_##fs - 1 - X##_e)); \
+ _FP_FRAC_HIGH_##fs(X) &= ~(_FP_W_TYPE)_FP_IMPLBIT_SH_##fs; \
+ pack_semiraw: \
+ _FP_PACK_SEMIRAW(fs, wc, X); \
+ } \
+ } \
+ else \
+ { \
+ X##_s = 0; \
+ X##_e = 0; \
+ _FP_FRAC_SET_##wc(X, _FP_ZEROFRAC_##wc); \
+ } \
+ } while (0)
+
+
+/* Extend from a narrower floating-point format to a wider one. Input
+ and output are raw. */
+#define FP_EXTEND(dfs,sfs,dwc,swc,D,S) \
+do { \
+ if (_FP_FRACBITS_##dfs < _FP_FRACBITS_##sfs \
+ || (_FP_EXPMAX_##dfs - _FP_EXPBIAS_##dfs \
+ < _FP_EXPMAX_##sfs - _FP_EXPBIAS_##sfs) \
+ || (_FP_EXPBIAS_##dfs < _FP_EXPBIAS_##sfs + _FP_FRACBITS_##sfs - 1 \
+ && _FP_EXPBIAS_##dfs != _FP_EXPBIAS_##sfs)) \
+ abort(); \
+ D##_s = S##_s; \
+ _FP_FRAC_COPY_##dwc##_##swc(D, S); \
+ if (_FP_EXP_NORMAL(sfs, swc, S)) \
+ { \
+ D##_e = S##_e + _FP_EXPBIAS_##dfs - _FP_EXPBIAS_##sfs; \
+ _FP_FRAC_SLL_##dwc(D, (_FP_FRACBITS_##dfs - _FP_FRACBITS_##sfs)); \
+ } \
+ else \
+ { \
+ if (S##_e == 0) \
+ { \
+ if (_FP_FRAC_ZEROP_##swc(S)) \
+ D##_e = 0; \
+ else if (_FP_EXPBIAS_##dfs \
+ < _FP_EXPBIAS_##sfs + _FP_FRACBITS_##sfs - 1) \
+ { \
+ FP_SET_EXCEPTION(FP_EX_DENORM); \
+ _FP_FRAC_SLL_##dwc(D, (_FP_FRACBITS_##dfs \
+ - _FP_FRACBITS_##sfs)); \
+ D##_e = 0; \
+ } \
+ else \
+ { \
+ int _lz; \
+ FP_SET_EXCEPTION(FP_EX_DENORM); \
+ _FP_FRAC_CLZ_##swc(_lz, S); \
+ _FP_FRAC_SLL_##dwc(D, \
+ _lz + _FP_FRACBITS_##dfs \
+ - _FP_FRACTBITS_##sfs); \
+ D##_e = (_FP_EXPBIAS_##dfs - _FP_EXPBIAS_##sfs + 1 \
+ + _FP_FRACXBITS_##sfs - _lz); \
+ } \
+ } \
+ else \
+ { \
+ D##_e = _FP_EXPMAX_##dfs; \
+ if (!_FP_FRAC_ZEROP_##swc(S)) \
+ { \
+ if (!(_FP_FRAC_HIGH_RAW_##sfs(S) & _FP_QNANBIT_##sfs)) \
+ FP_SET_EXCEPTION(FP_EX_INVALID); \
+ _FP_FRAC_SLL_##dwc(D, (_FP_FRACBITS_##dfs \
+ - _FP_FRACBITS_##sfs)); \
+ } \
+ } \
+ } \
+} while (0)
+
+/* Truncate from a wider floating-point format to a narrower one.
+ Input and output are semi-raw. */
+#define FP_TRUNC(dfs,sfs,dwc,swc,D,S) \
+do { \
+ if (_FP_FRACBITS_##sfs < _FP_FRACBITS_##dfs \
+ || (_FP_EXPBIAS_##sfs < _FP_EXPBIAS_##dfs + _FP_FRACBITS_##dfs - 1 \
+ && _FP_EXPBIAS_##sfs != _FP_EXPBIAS_##dfs)) \
+ abort(); \
+ D##_s = S##_s; \
+ if (_FP_EXP_NORMAL(sfs, swc, S)) \
+ { \
+ D##_e = S##_e + _FP_EXPBIAS_##dfs - _FP_EXPBIAS_##sfs; \
+ if (D##_e >= _FP_EXPMAX_##dfs) \
+ _FP_OVERFLOW_SEMIRAW(dfs, dwc, D); \
+ else \
+ { \
+ if (D##_e <= 0) \
+ { \
+ if (D##_e < 1 - _FP_FRACBITS_##dfs) \
+ { \
+ _FP_FRAC_SET_##swc(S, _FP_ZEROFRAC_##swc); \
+ _FP_FRAC_LOW_##swc(S) |= 1; \
+ } \
+ else \
+ { \
+ _FP_FRAC_HIGH_##sfs(S) |= _FP_IMPLBIT_SH_##sfs; \
+ _FP_FRAC_SRS_##swc(S, (_FP_WFRACBITS_##sfs \
+ - _FP_WFRACBITS_##dfs + 1 - D##_e), \
+ _FP_WFRACBITS_##sfs); \
+ } \
+ D##_e = 0; \
+ } \
+ else \
+ _FP_FRAC_SRS_##swc(S, (_FP_WFRACBITS_##sfs \
+ - _FP_WFRACBITS_##dfs), \
+ _FP_WFRACBITS_##sfs); \
+ _FP_FRAC_COPY_##dwc##_##swc(D, S); \
+ } \
+ } \
+ else \
+ { \
+ if (S##_e == 0) \
+ { \
+ D##_e = 0; \
+ if (_FP_FRAC_ZEROP_##swc(S)) \
+ _FP_FRAC_SET_##dwc(D, _FP_ZEROFRAC_##dwc); \
+ else \
+ { \
+ FP_SET_EXCEPTION(FP_EX_DENORM); \
+ if (_FP_EXPBIAS_##sfs \
+ < _FP_EXPBIAS_##dfs + _FP_FRACBITS_##dfs - 1) \
+ { \
+ _FP_FRAC_SRS_##swc(S, (_FP_WFRACBITS_##sfs \
+ - _FP_WFRACBITS_##dfs), \
+ _FP_WFRACBITS_##sfs); \
+ _FP_FRAC_COPY_##dwc##_##swc(D, S); \
+ } \
+ else \
+ { \
+ _FP_FRAC_SET_##dwc(D, _FP_ZEROFRAC_##dwc); \
+ _FP_FRAC_LOW_##dwc(D) |= 1; \
+ } \
+ } \
+ } \
+ else \
+ { \
+ D##_e = _FP_EXPMAX_##dfs; \
+ if (_FP_FRAC_ZEROP_##swc(S)) \
+ _FP_FRAC_SET_##dwc(D, _FP_ZEROFRAC_##dwc); \
+ else \
+ { \
+ _FP_CHECK_SIGNAN_SEMIRAW(sfs, swc, S); \
+ _FP_FRAC_SRL_##swc(S, (_FP_WFRACBITS_##sfs \
+ - _FP_WFRACBITS_##dfs)); \
+ _FP_FRAC_COPY_##dwc##_##swc(D, S); \
+ /* Semi-raw NaN must have all workbits cleared. */ \
+ _FP_FRAC_LOW_##dwc(D) \
+ &= ~(_FP_W_TYPE) ((1 << _FP_WORKBITS) - 1); \
+ _FP_FRAC_HIGH_##dfs(D) |= _FP_QNANBIT_SH_##dfs; \
+ } \
+ } \
+ } \
+} while (0)
+
+/*
+ * Helper primitives.
+ */
+
+/* Count leading zeros in a word. */
+
+#ifndef __FP_CLZ
+/* GCC 3.4 and later provide the builtins for us. */
+#define __FP_CLZ(r, x) \
+ do { \
+ if (sizeof (_FP_W_TYPE) == sizeof (unsigned int)) \
+ r = __builtin_clz (x); \
+ else if (sizeof (_FP_W_TYPE) == sizeof (unsigned long)) \
+ r = __builtin_clzl (x); \
+ else if (sizeof (_FP_W_TYPE) == sizeof (unsigned long long)) \
+ r = __builtin_clzll (x); \
+ else \
+ abort (); \
+ } while (0)
+#endif /* ndef __FP_CLZ */
+
+#define _FP_DIV_HELP_imm(q, r, n, d) \
+ do { \
+ q = n / d, r = n % d; \
+ } while (0)
+
+
+/* A restoring bit-by-bit division primitive. */
+
+#define _FP_DIV_MEAT_N_loop(fs, wc, R, X, Y) \
+ do { \
+ int count = _FP_WFRACBITS_##fs; \
+ _FP_FRAC_DECL_##wc (u); \
+ _FP_FRAC_DECL_##wc (v); \
+ _FP_FRAC_COPY_##wc (u, X); \
+ _FP_FRAC_COPY_##wc (v, Y); \
+ _FP_FRAC_SET_##wc (R, _FP_ZEROFRAC_##wc); \
+ /* Normalize U and V. */ \
+ _FP_FRAC_SLL_##wc (u, _FP_WFRACXBITS_##fs); \
+ _FP_FRAC_SLL_##wc (v, _FP_WFRACXBITS_##fs); \
+ /* First round. Since the operands are normalized, either the \
+ first or second bit will be set in the fraction. Produce a \
+ normalized result by checking which and adjusting the loop \
+ count and exponent accordingly. */ \
+ if (_FP_FRAC_GE_1 (u, v)) \
+ { \
+ _FP_FRAC_SUB_##wc (u, u, v); \
+ _FP_FRAC_LOW_##wc (R) |= 1; \
+ count--; \
+ } \
+ else \
+ R##_e--; \
+ /* Subsequent rounds. */ \
+ do { \
+ int msb = (_FP_WS_TYPE) _FP_FRAC_HIGH_##wc (u) < 0; \
+ _FP_FRAC_SLL_##wc (u, 1); \
+ _FP_FRAC_SLL_##wc (R, 1); \
+ if (msb || _FP_FRAC_GE_1 (u, v)) \
+ { \
+ _FP_FRAC_SUB_##wc (u, u, v); \
+ _FP_FRAC_LOW_##wc (R) |= 1; \
+ } \
+ } while (--count > 0); \
+ /* If there's anything left in U, the result is inexact. */ \
+ _FP_FRAC_LOW_##wc (R) |= !_FP_FRAC_ZEROP_##wc (u); \
+ } while (0)
+
+#define _FP_DIV_MEAT_1_loop(fs, R, X, Y) _FP_DIV_MEAT_N_loop (fs, 1, R, X, Y)
+#define _FP_DIV_MEAT_2_loop(fs, R, X, Y) _FP_DIV_MEAT_N_loop (fs, 2, R, X, Y)
+#define _FP_DIV_MEAT_4_loop(fs, R, X, Y) _FP_DIV_MEAT_N_loop (fs, 4, R, X, Y)
diff --git a/libc/sysdeps/linux/sparc/soft-fp/q_add.c b/libc/sysdeps/linux/sparc/soft-fp/q_add.c
new file mode 100644
index 000000000..67e07c285
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/q_add.c
@@ -0,0 +1,38 @@
+/* Software floating-point emulation.
+ Return a + b
+ Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "soft-fp.h"
+#include "quad.h"
+
+long double _Q_add(const long double a, const long double b)
+{
+ FP_DECL_EX;
+ FP_DECL_Q(A); FP_DECL_Q(B); FP_DECL_Q(C);
+ long double c;
+
+ FP_INIT_ROUNDMODE;
+ FP_UNPACK_SEMIRAW_Q(A, a);
+ FP_UNPACK_SEMIRAW_Q(B, b);
+ FP_ADD_Q(C, A, B);
+ FP_PACK_SEMIRAW_Q(c, C);
+ FP_HANDLE_EXCEPTIONS;
+ return c;
+}
diff --git a/libc/sysdeps/linux/sparc/soft-fp/q_cmp.c b/libc/sysdeps/linux/sparc/soft-fp/q_cmp.c
new file mode 100644
index 000000000..8c7f005e0
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/q_cmp.c
@@ -0,0 +1,40 @@
+/* Software floating-point emulation.
+ Compare a and b, return float condition code.
+ Copyright (C) 1997,1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "soft-fp.h"
+#include "quad.h"
+
+int _Q_cmp(const long double a, const long double b)
+{
+ FP_DECL_EX;
+ FP_DECL_Q(A); FP_DECL_Q(B);
+ int r;
+
+ FP_UNPACK_RAW_Q(A, a);
+ FP_UNPACK_RAW_Q(B, b);
+ FP_CMP_Q(r, B, A, 3);
+ if (r == -1) r = 2;
+ if (r == 3 && (FP_ISSIGNAN_Q(A) || FP_ISSIGNAN_Q(B)))
+ FP_SET_EXCEPTION(FP_EX_INVALID);
+ FP_HANDLE_EXCEPTIONS;
+
+ return r;
+}
diff --git a/libc/sysdeps/linux/sparc/soft-fp/q_cmpe.c b/libc/sysdeps/linux/sparc/soft-fp/q_cmpe.c
new file mode 100644
index 000000000..60d6c3628
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/q_cmpe.c
@@ -0,0 +1,41 @@
+/* Software floating-point emulation.
+ Compare a and b, return float condition code.
+ Signal exception (unless masked) if unordered.
+ Copyright (C) 1997,1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "soft-fp.h"
+#include "quad.h"
+
+int _Q_cmpe(const long double a, const long double b)
+{
+ FP_DECL_EX;
+ FP_DECL_Q(A); FP_DECL_Q(B);
+ int r;
+
+ FP_UNPACK_RAW_Q(A, a);
+ FP_UNPACK_RAW_Q(B, b);
+ FP_CMP_Q(r, B, A, 3);
+ if (r == -1) r = 2;
+ if (r == 3)
+ FP_SET_EXCEPTION(FP_EX_INVALID);
+ FP_HANDLE_EXCEPTIONS;
+
+ return r;
+}
diff --git a/libc/sysdeps/linux/sparc/soft-fp/q_div.c b/libc/sysdeps/linux/sparc/soft-fp/q_div.c
new file mode 100644
index 000000000..14249f427
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/q_div.c
@@ -0,0 +1,38 @@
+/* Software floating-point emulation.
+ Return a / b
+ Copyright (C) 1997, 1999, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "soft-fp.h"
+#include "quad.h"
+
+long double _Q_div(const long double a, const long double b)
+{
+ FP_DECL_EX;
+ FP_DECL_Q(A); FP_DECL_Q(B); FP_DECL_Q(C);
+ long double c;
+
+ FP_INIT_ROUNDMODE;
+ FP_UNPACK_Q(A, a);
+ FP_UNPACK_Q(B, b);
+ FP_DIV_Q(C, A, B);
+ FP_PACK_Q(c, C);
+ FP_HANDLE_EXCEPTIONS;
+ return c;
+}
diff --git a/libc/sysdeps/linux/sparc/soft-fp/q_dtoq.c b/libc/sysdeps/linux/sparc/soft-fp/q_dtoq.c
new file mode 100644
index 000000000..05b1643ee
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/q_dtoq.c
@@ -0,0 +1,43 @@
+/* Software floating-point emulation.
+ Return (long double)(a)
+ Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "soft-fp.h"
+#include "double.h"
+#include "quad.h"
+
+long double _Q_dtoq(const double a)
+{
+ FP_DECL_EX;
+ FP_DECL_D(A);
+ FP_DECL_Q(C);
+ long double c;
+
+ FP_INIT_ROUNDMODE;
+ FP_UNPACK_RAW_D(A, a);
+#if (2 * _FP_W_TYPE_SIZE) < _FP_FRACBITS_Q
+ FP_EXTEND(Q,D,4,2,C,A);
+#else
+ FP_EXTEND(Q,D,2,1,C,A);
+#endif
+ FP_PACK_RAW_Q(c, C);
+ FP_HANDLE_EXCEPTIONS;
+ return c;
+}
diff --git a/libc/sysdeps/linux/sparc/soft-fp/q_feq.c b/libc/sysdeps/linux/sparc/soft-fp/q_feq.c
new file mode 100644
index 000000000..cee667c10
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/q_feq.c
@@ -0,0 +1,39 @@
+/* Software floating-point emulation.
+ Return 1 if a == b
+ Copyright (C) 1997,1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "soft-fp.h"
+#include "quad.h"
+
+int _Q_feq(const long double a, const long double b)
+{
+ FP_DECL_EX;
+ FP_DECL_Q(A); FP_DECL_Q(B);
+ int r;
+
+ FP_UNPACK_RAW_Q(A, a);
+ FP_UNPACK_RAW_Q(B, b);
+ FP_CMP_EQ_Q(r, A, B);
+ if (r && (FP_ISSIGNAN_Q(A) || FP_ISSIGNAN_Q(B)))
+ FP_SET_EXCEPTION(FP_EX_INVALID);
+ FP_HANDLE_EXCEPTIONS;
+
+ return !r;
+}
diff --git a/libc/sysdeps/linux/sparc/soft-fp/q_fge.c b/libc/sysdeps/linux/sparc/soft-fp/q_fge.c
new file mode 100644
index 000000000..997990e7a
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/q_fge.c
@@ -0,0 +1,39 @@
+/* Software floating-point emulation.
+ Return 1 if a >= b
+ Copyright (C) 1997,1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "soft-fp.h"
+#include "quad.h"
+
+int _Q_fge(const long double a, const long double b)
+{
+ FP_DECL_EX;
+ FP_DECL_Q(A); FP_DECL_Q(B);
+ int r;
+
+ FP_UNPACK_RAW_Q(A, a);
+ FP_UNPACK_RAW_Q(B, b);
+ FP_CMP_Q(r, B, A, 3);
+ if (r == 3)
+ FP_SET_EXCEPTION(FP_EX_INVALID);
+ FP_HANDLE_EXCEPTIONS;
+
+ return (r <= 0);
+}
diff --git a/libc/sysdeps/linux/sparc/soft-fp/q_fgt.c b/libc/sysdeps/linux/sparc/soft-fp/q_fgt.c
new file mode 100644
index 000000000..5f95f82cd
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/q_fgt.c
@@ -0,0 +1,39 @@
+/* Software floating-point emulation.
+ Return 1 if a > b
+ Copyright (C) 1997,1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "soft-fp.h"
+#include "quad.h"
+
+int _Q_fgt(const long double a, const long double b)
+{
+ FP_DECL_EX;
+ FP_DECL_Q(A); FP_DECL_Q(B);
+ int r;
+
+ FP_UNPACK_RAW_Q(A, a);
+ FP_UNPACK_RAW_Q(B, b);
+ FP_CMP_Q(r, B, A, 3);
+ if (r == 3)
+ FP_SET_EXCEPTION(FP_EX_INVALID);
+ FP_HANDLE_EXCEPTIONS;
+
+ return (r == -1);
+}
diff --git a/libc/sysdeps/linux/sparc/soft-fp/q_fle.c b/libc/sysdeps/linux/sparc/soft-fp/q_fle.c
new file mode 100644
index 000000000..1a7587021
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/q_fle.c
@@ -0,0 +1,39 @@
+/* Software floating-point emulation.
+ Return 1 if a <= b
+ Copyright (C) 1997,1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "soft-fp.h"
+#include "quad.h"
+
+int _Q_fle(const long double a, const long double b)
+{
+ FP_DECL_EX;
+ FP_DECL_Q(A); FP_DECL_Q(B);
+ int r;
+
+ FP_UNPACK_RAW_Q(A, a);
+ FP_UNPACK_RAW_Q(B, b);
+ FP_CMP_Q(r, B, A, -2);
+ if (r == -2)
+ FP_SET_EXCEPTION(FP_EX_INVALID);
+ FP_HANDLE_EXCEPTIONS;
+
+ return (r >= 0);
+}
diff --git a/libc/sysdeps/linux/sparc/soft-fp/q_flt.c b/libc/sysdeps/linux/sparc/soft-fp/q_flt.c
new file mode 100644
index 000000000..c76a0c7bf
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/q_flt.c
@@ -0,0 +1,39 @@
+/* Software floating-point emulation.
+ Return 1 if a < b
+ Copyright (C) 1997,1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "soft-fp.h"
+#include "quad.h"
+
+int _Q_flt(const long double a, const long double b)
+{
+ FP_DECL_EX;
+ FP_DECL_Q(A); FP_DECL_Q(B);
+ int r;
+
+ FP_UNPACK_RAW_Q(A, a);
+ FP_UNPACK_RAW_Q(B, b);
+ FP_CMP_Q(r, B, A, 3);
+ if (r == 3)
+ FP_SET_EXCEPTION(FP_EX_INVALID);
+ FP_HANDLE_EXCEPTIONS;
+
+ return (r == 1);
+}
diff --git a/libc/sysdeps/linux/sparc/soft-fp/q_fne.c b/libc/sysdeps/linux/sparc/soft-fp/q_fne.c
new file mode 100644
index 000000000..1df561eac
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/q_fne.c
@@ -0,0 +1,39 @@
+/* Software floating-point emulation.
+ Return 1 if a != b
+ Copyright (C) 1997,1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "soft-fp.h"
+#include "quad.h"
+
+int _Q_fne(const long double a, const long double b)
+{
+ FP_DECL_EX;
+ FP_DECL_Q(A); FP_DECL_Q(B);
+ int r;
+
+ FP_UNPACK_RAW_Q(A, a);
+ FP_UNPACK_RAW_Q(B, b);
+ FP_CMP_EQ_Q(r, A, B);
+ if (r && (FP_ISSIGNAN_Q(A) || FP_ISSIGNAN_Q(B)))
+ FP_SET_EXCEPTION(FP_EX_INVALID);
+ FP_HANDLE_EXCEPTIONS;
+
+ return r;
+}
diff --git a/libc/sysdeps/linux/sparc/soft-fp/q_itoq.c b/libc/sysdeps/linux/sparc/soft-fp/q_itoq.c
new file mode 100644
index 000000000..8de7cd155
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/q_itoq.c
@@ -0,0 +1,37 @@
+/* Software floating-point emulation.
+ Return (long double)(a)
+ Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "soft-fp.h"
+#include "quad.h"
+
+long double _Q_itoq(const int a)
+{
+ FP_DECL_EX;
+ FP_DECL_Q(C);
+ int b = a;
+ long double c;
+
+ FP_FROM_INT_Q(C, b, 32, unsigned int);
+ FP_PACK_RAW_Q(c, C);
+ FP_CLEAR_EXCEPTIONS;
+ FP_HANDLE_EXCEPTIONS;
+ return c;
+}
diff --git a/libc/sysdeps/linux/sparc/soft-fp/q_lltoq.c b/libc/sysdeps/linux/sparc/soft-fp/q_lltoq.c
new file mode 100644
index 000000000..b718b35d6
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/q_lltoq.c
@@ -0,0 +1,37 @@
+/* Software floating-point emulation.
+ Return (long double)a
+ Copyright (C) 1997, 1999, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "soft-fp.h"
+#include "quad.h"
+
+long double _Q_lltoq(const long long a)
+{
+ FP_DECL_EX;
+ FP_DECL_Q(C);
+ long double c;
+ long long b = a;
+
+ FP_FROM_INT_Q(C, b, 64, unsigned long long);
+ FP_PACK_RAW_Q(c, C);
+ FP_CLEAR_EXCEPTIONS;
+ FP_HANDLE_EXCEPTIONS;
+ return c;
+}
diff --git a/libc/sysdeps/linux/sparc/soft-fp/q_mul.c b/libc/sysdeps/linux/sparc/soft-fp/q_mul.c
new file mode 100644
index 000000000..d45b3890a
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/q_mul.c
@@ -0,0 +1,38 @@
+/* Software floating-point emulation.
+ Return a * b
+ Copyright (C) 1997,1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "soft-fp.h"
+#include "quad.h"
+
+long double _Q_mul(const long double a, const long double b)
+{
+ FP_DECL_EX;
+ FP_DECL_Q(A); FP_DECL_Q(B); FP_DECL_Q(C);
+ long double c;
+
+ FP_INIT_ROUNDMODE;
+ FP_UNPACK_Q(A, a);
+ FP_UNPACK_Q(B, b);
+ FP_MUL_Q(C, A, B);
+ FP_PACK_Q(c, C);
+ FP_HANDLE_EXCEPTIONS;
+ return c;
+}
diff --git a/libc/sysdeps/linux/sparc/soft-fp/q_neg.c b/libc/sysdeps/linux/sparc/soft-fp/q_neg.c
new file mode 100644
index 000000000..0e6162651
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/q_neg.c
@@ -0,0 +1,46 @@
+/* Software floating-point emulation.
+ Return !a
+ Copyright (C) 1997,1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "soft-fp.h"
+#include "quad.h"
+
+long double _Q_neg(const long double a)
+{
+ FP_DECL_EX;
+ long double c = a;
+
+#if (__BYTE_ORDER == __BIG_ENDIAN)
+ ((UWtype *)&c)[0] ^= (((UWtype)1) << (W_TYPE_SIZE - 1));
+#elif (__BYTE_ORDER == __LITTLE_ENDIAN) && (W_TYPE_SIZE == 64)
+ ((UWtype *)&c)[1] ^= (((UWtype)1) << (W_TYPE_SIZE - 1));
+#elif (__BYTE_ORDER == __LITTLE_ENDIAN) && (W_TYPE_SIZE == 32)
+ ((UWtype *)&c)[3] ^= (((UWtype)1) << (W_TYPE_SIZE - 1));
+#else
+ FP_DECL_Q(A); FP_DECL_Q(C);
+
+ FP_UNPACK_Q(A, a);
+ FP_NEG_Q(C, A);
+ FP_PACK_Q(c, C);
+#endif
+ FP_CLEAR_EXCEPTIONS;
+ FP_HANDLE_EXCEPTIONS;
+ return c;
+}
diff --git a/libc/sysdeps/linux/sparc/soft-fp/q_qtod.c b/libc/sysdeps/linux/sparc/soft-fp/q_qtod.c
new file mode 100644
index 000000000..91ec6945d
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/q_qtod.c
@@ -0,0 +1,44 @@
+/* Software floating-point emulation.
+ Return (double)a
+ Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "soft-fp.h"
+#include "double.h"
+#include "quad.h"
+
+double _Q_qtod(const long double a)
+{
+ FP_DECL_EX;
+ FP_DECL_Q(A);
+ FP_DECL_D(R);
+ double r;
+
+ FP_INIT_ROUNDMODE;
+ FP_UNPACK_SEMIRAW_Q(A, a);
+#if (2 * _FP_W_TYPE_SIZE) < _FP_FRACBITS_Q
+ FP_TRUNC(D,Q,2,4,R,A);
+#else
+ FP_TRUNC(D,Q,1,2,R,A);
+#endif
+ FP_PACK_SEMIRAW_D(r, R);
+ FP_HANDLE_EXCEPTIONS;
+
+ return r;
+}
diff --git a/libc/sysdeps/linux/sparc/soft-fp/q_qtoi.c b/libc/sysdeps/linux/sparc/soft-fp/q_qtoi.c
new file mode 100644
index 000000000..19484f3e1
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/q_qtoi.c
@@ -0,0 +1,37 @@
+/* Software floating-point emulation.
+ Return (int)a
+ Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#define FP_ROUNDMODE FP_RND_ZERO
+#include "soft-fp.h"
+#include "quad.h"
+
+int _Q_qtoi(const long double a)
+{
+ FP_DECL_EX;
+ FP_DECL_Q(A);
+ unsigned int r;
+
+ FP_UNPACK_RAW_Q(A, a);
+ FP_TO_INT_Q(r, A, 32, 1);
+ FP_HANDLE_EXCEPTIONS;
+
+ return r;
+}
diff --git a/libc/sysdeps/linux/sparc/soft-fp/q_qtoll.c b/libc/sysdeps/linux/sparc/soft-fp/q_qtoll.c
new file mode 100644
index 000000000..ba053d936
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/q_qtoll.c
@@ -0,0 +1,37 @@
+/* Software floating-point emulation.
+ Return (long long)a
+ Copyright (C) 1997, 1999, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#define FP_ROUNDMODE FP_RND_ZERO
+#include "soft-fp.h"
+#include "quad.h"
+
+long long _Q_qtoll(const long double a)
+{
+ FP_DECL_EX;
+ FP_DECL_Q(A);
+ unsigned long long r;
+
+ FP_UNPACK_RAW_Q(A, a);
+ FP_TO_INT_Q(r, A, 64, 1);
+ FP_HANDLE_EXCEPTIONS;
+
+ return r;
+}
diff --git a/libc/sysdeps/linux/sparc/soft-fp/q_qtos.c b/libc/sysdeps/linux/sparc/soft-fp/q_qtos.c
new file mode 100644
index 000000000..030d5b9a5
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/q_qtos.c
@@ -0,0 +1,44 @@
+/* Software floating-point emulation.
+ Return (float)a
+ Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "soft-fp.h"
+#include "single.h"
+#include "quad.h"
+
+float _Q_qtos(const long double a)
+{
+ FP_DECL_EX;
+ FP_DECL_Q(A);
+ FP_DECL_S(R);
+ float r;
+
+ FP_INIT_ROUNDMODE;
+ FP_UNPACK_SEMIRAW_Q(A, a);
+#if (2 * _FP_W_TYPE_SIZE) < _FP_FRACBITS_Q
+ FP_TRUNC(S,Q,1,4,R,A);
+#else
+ FP_TRUNC(S,Q,1,2,R,A);
+#endif
+ FP_PACK_SEMIRAW_S(r, R);
+ FP_HANDLE_EXCEPTIONS;
+
+ return r;
+}
diff --git a/libc/sysdeps/linux/sparc/soft-fp/q_qtou.c b/libc/sysdeps/linux/sparc/soft-fp/q_qtou.c
new file mode 100644
index 000000000..6b199c954
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/q_qtou.c
@@ -0,0 +1,37 @@
+/* Software floating-point emulation.
+ Return (unsigned int)a
+ Copyright (C) 1997, 1999, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#define FP_ROUNDMODE FP_RND_ZERO
+#include "soft-fp.h"
+#include "quad.h"
+
+unsigned int _Q_qtou(const long double a)
+{
+ FP_DECL_EX;
+ FP_DECL_Q(A);
+ unsigned int r;
+
+ FP_UNPACK_RAW_Q(A, a);
+ FP_TO_INT_Q(r, A, 32, -1);
+ FP_HANDLE_EXCEPTIONS;
+
+ return r;
+}
diff --git a/libc/sysdeps/linux/sparc/soft-fp/q_qtoull.c b/libc/sysdeps/linux/sparc/soft-fp/q_qtoull.c
new file mode 100644
index 000000000..cdd2b617d
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/q_qtoull.c
@@ -0,0 +1,37 @@
+/* Software floating-point emulation.
+ Return (unsigned long long)a
+ Copyright (C) 1997, 1999, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#define FP_ROUNDMODE FP_RND_ZERO
+#include "soft-fp.h"
+#include "quad.h"
+
+unsigned long long _Q_qtoull(const long double a)
+{
+ FP_DECL_EX;
+ FP_DECL_Q(A);
+ unsigned long long r;
+
+ FP_UNPACK_RAW_Q(A, a);
+ FP_TO_INT_Q(r, A, 64, -1);
+ FP_HANDLE_EXCEPTIONS;
+
+ return r;
+}
diff --git a/libc/sysdeps/linux/sparc/soft-fp/q_sqrt.c b/libc/sysdeps/linux/sparc/soft-fp/q_sqrt.c
new file mode 100644
index 000000000..4a83fa57f
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/q_sqrt.c
@@ -0,0 +1,38 @@
+/* Software floating-point emulation.
+ Return sqrtl(a)
+ Copyright (C) 1997, 1999, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "soft-fp.h"
+#include "quad.h"
+
+long double _Q_sqrt(const long double a)
+{
+ FP_DECL_EX;
+ FP_DECL_Q(A); FP_DECL_Q(C);
+ long double c;
+
+ FP_INIT_ROUNDMODE;
+ FP_UNPACK_Q(A, a);
+ FP_SQRT_Q(C, A);
+ FP_PACK_Q(c, C);
+ FP_HANDLE_EXCEPTIONS;
+ return c;
+}
+strong_alias (_Q_sqrt, __ieee754_sqrtl);
diff --git a/libc/sysdeps/linux/sparc/soft-fp/q_stoq.c b/libc/sysdeps/linux/sparc/soft-fp/q_stoq.c
new file mode 100644
index 000000000..c5d175535
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/q_stoq.c
@@ -0,0 +1,42 @@
+/* Software floating-point emulation.
+ c = (long double)(a)
+ Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "soft-fp.h"
+#include "single.h"
+#include "quad.h"
+
+long double _Q_stoq(const float a)
+{
+ FP_DECL_EX;
+ FP_DECL_S(A);
+ FP_DECL_Q(C);
+ long double c;
+
+ FP_UNPACK_RAW_S(A, a);
+#if (2 * _FP_W_TYPE_SIZE) < _FP_FRACBITS_Q
+ FP_EXTEND(Q,S,4,1,C,A);
+#else
+ FP_EXTEND(Q,S,2,1,C,A);
+#endif
+ FP_PACK_RAW_Q(c, C);
+ FP_HANDLE_EXCEPTIONS;
+ return c;
+}
diff --git a/libc/sysdeps/linux/sparc/soft-fp/q_sub.c b/libc/sysdeps/linux/sparc/soft-fp/q_sub.c
new file mode 100644
index 000000000..7d319d066
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/q_sub.c
@@ -0,0 +1,38 @@
+/* Software floating-point emulation.
+ c = a - b
+ Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "soft-fp.h"
+#include "quad.h"
+
+long double _Q_sub(const long double a, const long double b)
+{
+ FP_DECL_EX;
+ FP_DECL_Q(A); FP_DECL_Q(B); FP_DECL_Q(C);
+ long double c;
+
+ FP_INIT_ROUNDMODE;
+ FP_UNPACK_SEMIRAW_Q(A, a);
+ FP_UNPACK_SEMIRAW_Q(B, b);
+ FP_SUB_Q(C, A, B);
+ FP_PACK_SEMIRAW_Q(c, C);
+ FP_HANDLE_EXCEPTIONS;
+ return c;
+}
diff --git a/libc/sysdeps/linux/sparc/soft-fp/q_ulltoq.c b/libc/sysdeps/linux/sparc/soft-fp/q_ulltoq.c
new file mode 100644
index 000000000..930d296da
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/q_ulltoq.c
@@ -0,0 +1,37 @@
+/* Software floating-point emulation.
+ Return (long double)(a)
+ Copyright (C) 1997, 1999, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "soft-fp.h"
+#include "quad.h"
+
+long double _Q_ulltoq(const unsigned long long a)
+{
+ FP_DECL_EX;
+ FP_DECL_Q(C);
+ long double c;
+ unsigned long long b = a;
+
+ FP_FROM_INT_Q(C, b, 64, unsigned long long);
+ FP_PACK_RAW_Q(c, C);
+ FP_CLEAR_EXCEPTIONS;
+ FP_HANDLE_EXCEPTIONS;
+ return c;
+}
diff --git a/libc/sysdeps/linux/sparc/soft-fp/q_util.c b/libc/sysdeps/linux/sparc/soft-fp/q_util.c
new file mode 100644
index 000000000..22f70ba46
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/q_util.c
@@ -0,0 +1,56 @@
+/* Software floating-point emulation.
+ Helper routine for _Q_* routines.
+ Simulate exceptions using double arithmetics.
+ Copyright (C) 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "soft-fp.h"
+
+unsigned long long ___Q_numbers [] = {
+0x0000000000000000ULL, /* Zero */
+0x0010100000000000ULL, /* Very tiny number */
+0x0010000000000000ULL, /* Minimum normalized number */
+0x7fef000000000000ULL, /* A huge double number */
+};
+
+double ___Q_simulate_exceptions(int exceptions)
+{
+ double d, *p = (double *)___Q_numbers;
+ if (exceptions & FP_EX_INVALID)
+ d = p[0]/p[0];
+ if (exceptions & FP_EX_OVERFLOW)
+ {
+ d = p[3] + p[3];
+ exceptions &= ~FP_EX_INEXACT;
+ }
+ if (exceptions & FP_EX_UNDERFLOW)
+ {
+ if (exceptions & FP_EX_INEXACT)
+ {
+ d = p[2] * p[2];
+ exceptions &= ~FP_EX_INEXACT;
+ }
+ else
+ d = p[1] - p[2];
+ }
+ if (exceptions & FP_EX_DIVZERO)
+ d = 1.0/p[0];
+ if (exceptions & FP_EX_INEXACT)
+ d = p[3] - p[2];
+ return d;
+}
diff --git a/libc/sysdeps/linux/sparc/soft-fp/q_utoq.c b/libc/sysdeps/linux/sparc/soft-fp/q_utoq.c
new file mode 100644
index 000000000..6b9cb6059
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/q_utoq.c
@@ -0,0 +1,37 @@
+/* Software floating-point emulation.
+ c = (long double)(a)
+ Copyright (C) 1997, 1999, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "soft-fp.h"
+#include "quad.h"
+
+long double _Q_utoq(const unsigned int a)
+{
+ FP_DECL_EX;
+ FP_DECL_Q(C);
+ long double c;
+ unsigned int b = a;
+
+ FP_FROM_INT_Q(C, b, 32, unsigned int);
+ FP_PACK_RAW_Q(c, C);
+ FP_CLEAR_EXCEPTIONS;
+ FP_HANDLE_EXCEPTIONS;
+ return c;
+}
diff --git a/libc/sysdeps/linux/sparc/soft-fp/quad.h b/libc/sysdeps/linux/sparc/soft-fp/quad.h
new file mode 100644
index 000000000..ea7013879
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/quad.h
@@ -0,0 +1,270 @@
+/* Software floating-point emulation.
+ Definitions for IEEE Quad Precision.
+ Copyright (C) 1997,1998,1999,2006,2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com),
+ Jakub Jelinek (jj@ultra.linux.cz),
+ David S. Miller (davem@redhat.com) and
+ Peter Maydell (pmaydell@chiark.greenend.org.uk).
+
+ 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 into
+ combinations with other programs, and to distribute those
+ combinations without any restriction coming from the use of this
+ file. (The Lesser General Public License restrictions do apply in
+ other respects; for example, they cover modification of the file,
+ and distribution when not linked into a combine executable.)
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#if _FP_W_TYPE_SIZE < 32
+#error "Here's a nickel, kid. Go buy yourself a real computer."
+#endif
+
+#if _FP_W_TYPE_SIZE < 64
+#define _FP_FRACTBITS_Q (4*_FP_W_TYPE_SIZE)
+#else
+#define _FP_FRACTBITS_Q (2*_FP_W_TYPE_SIZE)
+#endif
+
+#define _FP_FRACBITS_Q 113
+#define _FP_FRACXBITS_Q (_FP_FRACTBITS_Q - _FP_FRACBITS_Q)
+#define _FP_WFRACBITS_Q (_FP_WORKBITS + _FP_FRACBITS_Q)
+#define _FP_WFRACXBITS_Q (_FP_FRACTBITS_Q - _FP_WFRACBITS_Q)
+#define _FP_EXPBITS_Q 15
+#define _FP_EXPBIAS_Q 16383
+#define _FP_EXPMAX_Q 32767
+
+#define _FP_QNANBIT_Q \
+ ((_FP_W_TYPE)1 << (_FP_FRACBITS_Q-2) % _FP_W_TYPE_SIZE)
+#define _FP_QNANBIT_SH_Q \
+ ((_FP_W_TYPE)1 << (_FP_FRACBITS_Q-2+_FP_WORKBITS) % _FP_W_TYPE_SIZE)
+#define _FP_IMPLBIT_Q \
+ ((_FP_W_TYPE)1 << (_FP_FRACBITS_Q-1) % _FP_W_TYPE_SIZE)
+#define _FP_IMPLBIT_SH_Q \
+ ((_FP_W_TYPE)1 << (_FP_FRACBITS_Q-1+_FP_WORKBITS) % _FP_W_TYPE_SIZE)
+#define _FP_OVERFLOW_Q \
+ ((_FP_W_TYPE)1 << (_FP_WFRACBITS_Q % _FP_W_TYPE_SIZE))
+
+typedef float TFtype __attribute__((mode(TF)));
+
+#if _FP_W_TYPE_SIZE < 64
+
+union _FP_UNION_Q
+{
+ TFtype flt;
+ struct
+ {
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned sign : 1;
+ unsigned exp : _FP_EXPBITS_Q;
+ unsigned long frac3 : _FP_FRACBITS_Q - (_FP_IMPLBIT_Q != 0)-(_FP_W_TYPE_SIZE * 3);
+ unsigned long frac2 : _FP_W_TYPE_SIZE;
+ unsigned long frac1 : _FP_W_TYPE_SIZE;
+ unsigned long frac0 : _FP_W_TYPE_SIZE;
+#else
+ unsigned long frac0 : _FP_W_TYPE_SIZE;
+ unsigned long frac1 : _FP_W_TYPE_SIZE;
+ unsigned long frac2 : _FP_W_TYPE_SIZE;
+ unsigned long frac3 : _FP_FRACBITS_Q - (_FP_IMPLBIT_Q != 0)-(_FP_W_TYPE_SIZE * 3);
+ unsigned exp : _FP_EXPBITS_Q;
+ unsigned sign : 1;
+#endif /* not bigendian */
+ } bits __attribute__((packed));
+};
+
+
+#define FP_DECL_Q(X) _FP_DECL(4,X)
+#define FP_UNPACK_RAW_Q(X,val) _FP_UNPACK_RAW_4(Q,X,val)
+#define FP_UNPACK_RAW_QP(X,val) _FP_UNPACK_RAW_4_P(Q,X,val)
+#define FP_PACK_RAW_Q(val,X) _FP_PACK_RAW_4(Q,val,X)
+#define FP_PACK_RAW_QP(val,X) \
+ do { \
+ if (!FP_INHIBIT_RESULTS) \
+ _FP_PACK_RAW_4_P(Q,val,X); \
+ } while (0)
+
+#define FP_UNPACK_Q(X,val) \
+ do { \
+ _FP_UNPACK_RAW_4(Q,X,val); \
+ _FP_UNPACK_CANONICAL(Q,4,X); \
+ } while (0)
+
+#define FP_UNPACK_QP(X,val) \
+ do { \
+ _FP_UNPACK_RAW_4_P(Q,X,val); \
+ _FP_UNPACK_CANONICAL(Q,4,X); \
+ } while (0)
+
+#define FP_UNPACK_SEMIRAW_Q(X,val) \
+ do { \
+ _FP_UNPACK_RAW_4(Q,X,val); \
+ _FP_UNPACK_SEMIRAW(Q,4,X); \
+ } while (0)
+
+#define FP_UNPACK_SEMIRAW_QP(X,val) \
+ do { \
+ _FP_UNPACK_RAW_4_P(Q,X,val); \
+ _FP_UNPACK_SEMIRAW(Q,4,X); \
+ } while (0)
+
+#define FP_PACK_Q(val,X) \
+ do { \
+ _FP_PACK_CANONICAL(Q,4,X); \
+ _FP_PACK_RAW_4(Q,val,X); \
+ } while (0)
+
+#define FP_PACK_QP(val,X) \
+ do { \
+ _FP_PACK_CANONICAL(Q,4,X); \
+ if (!FP_INHIBIT_RESULTS) \
+ _FP_PACK_RAW_4_P(Q,val,X); \
+ } while (0)
+
+#define FP_PACK_SEMIRAW_Q(val,X) \
+ do { \
+ _FP_PACK_SEMIRAW(Q,4,X); \
+ _FP_PACK_RAW_4(Q,val,X); \
+ } while (0)
+
+#define FP_PACK_SEMIRAW_QP(val,X) \
+ do { \
+ _FP_PACK_SEMIRAW(Q,4,X); \
+ if (!FP_INHIBIT_RESULTS) \
+ _FP_PACK_RAW_4_P(Q,val,X); \
+ } while (0)
+
+#define FP_ISSIGNAN_Q(X) _FP_ISSIGNAN(Q,4,X)
+#define FP_NEG_Q(R,X) _FP_NEG(Q,4,R,X)
+#define FP_ADD_Q(R,X,Y) _FP_ADD(Q,4,R,X,Y)
+#define FP_SUB_Q(R,X,Y) _FP_SUB(Q,4,R,X,Y)
+#define FP_MUL_Q(R,X,Y) _FP_MUL(Q,4,R,X,Y)
+#define FP_DIV_Q(R,X,Y) _FP_DIV(Q,4,R,X,Y)
+#define FP_SQRT_Q(R,X) _FP_SQRT(Q,4,R,X)
+#define _FP_SQRT_MEAT_Q(R,S,T,X,Q) _FP_SQRT_MEAT_4(R,S,T,X,Q)
+
+#define FP_CMP_Q(r,X,Y,un) _FP_CMP(Q,4,r,X,Y,un)
+#define FP_CMP_EQ_Q(r,X,Y) _FP_CMP_EQ(Q,4,r,X,Y)
+#define FP_CMP_UNORD_Q(r,X,Y) _FP_CMP_UNORD(Q,4,r,X,Y)
+
+#define FP_TO_INT_Q(r,X,rsz,rsg) _FP_TO_INT(Q,4,r,X,rsz,rsg)
+#define FP_FROM_INT_Q(X,r,rs,rt) _FP_FROM_INT(Q,4,X,r,rs,rt)
+
+#define _FP_FRAC_HIGH_Q(X) _FP_FRAC_HIGH_4(X)
+#define _FP_FRAC_HIGH_RAW_Q(X) _FP_FRAC_HIGH_4(X)
+
+#else /* not _FP_W_TYPE_SIZE < 64 */
+union _FP_UNION_Q
+{
+ TFtype flt /* __attribute__((mode(TF))) */ ;
+ struct {
+ _FP_W_TYPE a, b;
+ } longs;
+ struct {
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned sign : 1;
+ unsigned exp : _FP_EXPBITS_Q;
+ _FP_W_TYPE frac1 : _FP_FRACBITS_Q - (_FP_IMPLBIT_Q != 0) - _FP_W_TYPE_SIZE;
+ _FP_W_TYPE frac0 : _FP_W_TYPE_SIZE;
+#else
+ _FP_W_TYPE frac0 : _FP_W_TYPE_SIZE;
+ _FP_W_TYPE frac1 : _FP_FRACBITS_Q - (_FP_IMPLBIT_Q != 0) - _FP_W_TYPE_SIZE;
+ unsigned exp : _FP_EXPBITS_Q;
+ unsigned sign : 1;
+#endif
+ } bits;
+};
+
+#define FP_DECL_Q(X) _FP_DECL(2,X)
+#define FP_UNPACK_RAW_Q(X,val) _FP_UNPACK_RAW_2(Q,X,val)
+#define FP_UNPACK_RAW_QP(X,val) _FP_UNPACK_RAW_2_P(Q,X,val)
+#define FP_PACK_RAW_Q(val,X) _FP_PACK_RAW_2(Q,val,X)
+#define FP_PACK_RAW_QP(val,X) \
+ do { \
+ if (!FP_INHIBIT_RESULTS) \
+ _FP_PACK_RAW_2_P(Q,val,X); \
+ } while (0)
+
+#define FP_UNPACK_Q(X,val) \
+ do { \
+ _FP_UNPACK_RAW_2(Q,X,val); \
+ _FP_UNPACK_CANONICAL(Q,2,X); \
+ } while (0)
+
+#define FP_UNPACK_QP(X,val) \
+ do { \
+ _FP_UNPACK_RAW_2_P(Q,X,val); \
+ _FP_UNPACK_CANONICAL(Q,2,X); \
+ } while (0)
+
+#define FP_UNPACK_SEMIRAW_Q(X,val) \
+ do { \
+ _FP_UNPACK_RAW_2(Q,X,val); \
+ _FP_UNPACK_SEMIRAW(Q,2,X); \
+ } while (0)
+
+#define FP_UNPACK_SEMIRAW_QP(X,val) \
+ do { \
+ _FP_UNPACK_RAW_2_P(Q,X,val); \
+ _FP_UNPACK_SEMIRAW(Q,2,X); \
+ } while (0)
+
+#define FP_PACK_Q(val,X) \
+ do { \
+ _FP_PACK_CANONICAL(Q,2,X); \
+ _FP_PACK_RAW_2(Q,val,X); \
+ } while (0)
+
+#define FP_PACK_QP(val,X) \
+ do { \
+ _FP_PACK_CANONICAL(Q,2,X); \
+ if (!FP_INHIBIT_RESULTS) \
+ _FP_PACK_RAW_2_P(Q,val,X); \
+ } while (0)
+
+#define FP_PACK_SEMIRAW_Q(val,X) \
+ do { \
+ _FP_PACK_SEMIRAW(Q,2,X); \
+ _FP_PACK_RAW_2(Q,val,X); \
+ } while (0)
+
+#define FP_PACK_SEMIRAW_QP(val,X) \
+ do { \
+ _FP_PACK_SEMIRAW(Q,2,X); \
+ if (!FP_INHIBIT_RESULTS) \
+ _FP_PACK_RAW_2_P(Q,val,X); \
+ } while (0)
+
+#define FP_ISSIGNAN_Q(X) _FP_ISSIGNAN(Q,2,X)
+#define FP_NEG_Q(R,X) _FP_NEG(Q,2,R,X)
+#define FP_ADD_Q(R,X,Y) _FP_ADD(Q,2,R,X,Y)
+#define FP_SUB_Q(R,X,Y) _FP_SUB(Q,2,R,X,Y)
+#define FP_MUL_Q(R,X,Y) _FP_MUL(Q,2,R,X,Y)
+#define FP_DIV_Q(R,X,Y) _FP_DIV(Q,2,R,X,Y)
+#define FP_SQRT_Q(R,X) _FP_SQRT(Q,2,R,X)
+#define _FP_SQRT_MEAT_Q(R,S,T,X,Q) _FP_SQRT_MEAT_2(R,S,T,X,Q)
+
+#define FP_CMP_Q(r,X,Y,un) _FP_CMP(Q,2,r,X,Y,un)
+#define FP_CMP_EQ_Q(r,X,Y) _FP_CMP_EQ(Q,2,r,X,Y)
+#define FP_CMP_UNORD_Q(r,X,Y) _FP_CMP_UNORD(Q,2,r,X,Y)
+
+#define FP_TO_INT_Q(r,X,rsz,rsg) _FP_TO_INT(Q,2,r,X,rsz,rsg)
+#define FP_FROM_INT_Q(X,r,rs,rt) _FP_FROM_INT(Q,2,X,r,rs,rt)
+
+#define _FP_FRAC_HIGH_Q(X) _FP_FRAC_HIGH_2(X)
+#define _FP_FRAC_HIGH_RAW_Q(X) _FP_FRAC_HIGH_2(X)
+
+#endif /* not _FP_W_TYPE_SIZE < 64 */
diff --git a/libc/sysdeps/linux/sparc/soft-fp/sfp-machine.h b/libc/sysdeps/linux/sparc/soft-fp/sfp-machine.h
new file mode 100644
index 000000000..c86dbcddd
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/sfp-machine.h
@@ -0,0 +1,214 @@
+/* Machine-dependent software floating-point definitions.
+ Sparc userland (_Q_*) version.
+ Copyright (C) 1997,1998,1999, 2002, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com),
+ Jakub Jelinek (jj@ultra.linux.cz) and
+ David S. Miller (davem@redhat.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; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <fpu_control.h>
+#include <stdlib.h>
+
+#define _FP_W_TYPE_SIZE 32
+#define _FP_W_TYPE unsigned long
+#define _FP_WS_TYPE signed long
+#define _FP_I_TYPE long
+
+#define _FP_MUL_MEAT_S(R,X,Y) \
+ _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
+#define _FP_MUL_MEAT_D(R,X,Y) \
+ _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
+#define _FP_MUL_MEAT_Q(R,X,Y) \
+ _FP_MUL_MEAT_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
+
+#define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_udiv(S,R,X,Y)
+#define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_2_udiv(D,R,X,Y)
+#define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_4_udiv(Q,R,X,Y)
+
+#define _FP_NANFRAC_S ((_FP_QNANBIT_S << 1) - 1)
+#define _FP_NANFRAC_D ((_FP_QNANBIT_D << 1) - 1), -1
+#define _FP_NANFRAC_Q ((_FP_QNANBIT_Q << 1) - 1), -1, -1, -1
+#define _FP_NANSIGN_S 0
+#define _FP_NANSIGN_D 0
+#define _FP_NANSIGN_Q 0
+
+#define _FP_KEEPNANFRACP 1
+
+/* If one NaN is signaling and the other is not,
+ * we choose that one, otherwise we choose X.
+ */
+/* For _Qp_* and _Q_*, this should prefer X, for
+ * CPU instruction emulation this should prefer Y.
+ * (see SPAMv9 B.2.2 section).
+ */
+#define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \
+ do { \
+ if ((_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs) \
+ && !(_FP_FRAC_HIGH_RAW_##fs(Y) & _FP_QNANBIT_##fs)) \
+ { \
+ R##_s = Y##_s; \
+ _FP_FRAC_COPY_##wc(R,Y); \
+ } \
+ else \
+ { \
+ R##_s = X##_s; \
+ _FP_FRAC_COPY_##wc(R,X); \
+ } \
+ R##_c = FP_CLS_NAN; \
+ } while (0)
+
+/* Some assembly to speed things up. */
+#define __FP_FRAC_ADD_3(r2,r1,r0,x2,x1,x0,y2,y1,y0) \
+ __asm__ ("addcc %r7,%8,%2\n\
+ addxcc %r5,%6,%1\n\
+ addx %r3,%4,%0" \
+ : "=r" ((USItype)(r2)), \
+ "=&r" ((USItype)(r1)), \
+ "=&r" ((USItype)(r0)) \
+ : "%rJ" ((USItype)(x2)), \
+ "rI" ((USItype)(y2)), \
+ "%rJ" ((USItype)(x1)), \
+ "rI" ((USItype)(y1)), \
+ "%rJ" ((USItype)(x0)), \
+ "rI" ((USItype)(y0)) \
+ : "cc")
+
+#define __FP_FRAC_SUB_3(r2,r1,r0,x2,x1,x0,y2,y1,y0) \
+ __asm__ ("subcc %r7,%8,%2\n\
+ subxcc %r5,%6,%1\n\
+ subx %r3,%4,%0" \
+ : "=r" ((USItype)(r2)), \
+ "=&r" ((USItype)(r1)), \
+ "=&r" ((USItype)(r0)) \
+ : "%rJ" ((USItype)(x2)), \
+ "rI" ((USItype)(y2)), \
+ "%rJ" ((USItype)(x1)), \
+ "rI" ((USItype)(y1)), \
+ "%rJ" ((USItype)(x0)), \
+ "rI" ((USItype)(y0)) \
+ : "cc")
+
+#define __FP_FRAC_ADD_4(r3,r2,r1,r0,x3,x2,x1,x0,y3,y2,y1,y0) \
+ do { \
+ /* We need to fool gcc, as we need to pass more than 10 \
+ input/outputs. */ \
+ register USItype _t1 __asm__ ("g1"), _t2 __asm__ ("g2"); \
+ __asm__ __volatile__ ("\
+ addcc %r8,%9,%1\n\
+ addxcc %r6,%7,%0\n\
+ addxcc %r4,%5,%%g2\n\
+ addx %r2,%3,%%g1" \
+ : "=&r" ((USItype)(r1)), \
+ "=&r" ((USItype)(r0)) \
+ : "%rJ" ((USItype)(x3)), \
+ "rI" ((USItype)(y3)), \
+ "%rJ" ((USItype)(x2)), \
+ "rI" ((USItype)(y2)), \
+ "%rJ" ((USItype)(x1)), \
+ "rI" ((USItype)(y1)), \
+ "%rJ" ((USItype)(x0)), \
+ "rI" ((USItype)(y0)) \
+ : "cc", "g1", "g2"); \
+ __asm__ __volatile__ ("" : "=r" (_t1), "=r" (_t2)); \
+ r3 = _t1; r2 = _t2; \
+ } while (0)
+
+#define __FP_FRAC_SUB_4(r3,r2,r1,r0,x3,x2,x1,x0,y3,y2,y1,y0) \
+ do { \
+ /* We need to fool gcc, as we need to pass more than 10 \
+ input/outputs. */ \
+ register USItype _t1 __asm__ ("g1"), _t2 __asm__ ("g2"); \
+ __asm__ __volatile__ ("\
+ subcc %r8,%9,%1\n\
+ subxcc %r6,%7,%0\n\
+ subxcc %r4,%5,%%g2\n\
+ subx %r2,%3,%%g1" \
+ : "=&r" ((USItype)(r1)), \
+ "=&r" ((USItype)(r0)) \
+ : "%rJ" ((USItype)(x3)), \
+ "rI" ((USItype)(y3)), \
+ "%rJ" ((USItype)(x2)), \
+ "rI" ((USItype)(y2)), \
+ "%rJ" ((USItype)(x1)), \
+ "rI" ((USItype)(y1)), \
+ "%rJ" ((USItype)(x0)), \
+ "rI" ((USItype)(y0)) \
+ : "cc", "g1", "g2"); \
+ __asm__ __volatile__ ("" : "=r" (_t1), "=r" (_t2)); \
+ r3 = _t1; r2 = _t2; \
+ } while (0)
+
+#define __FP_FRAC_DEC_3(x2,x1,x0,y2,y1,y0) __FP_FRAC_SUB_3(x2,x1,x0,x2,x1,x0,y2,y1,y0)
+
+#define __FP_FRAC_DEC_4(x3,x2,x1,x0,y3,y2,y1,y0) __FP_FRAC_SUB_4(x3,x2,x1,x0,x3,x2,x1,x0,y3,y2,y1,y0)
+
+#define __FP_FRAC_ADDI_4(x3,x2,x1,x0,i) \
+ __asm__ ("addcc %3,%4,%3\n\
+ addxcc %2,%%g0,%2\n\
+ addxcc %1,%%g0,%1\n\
+ addx %0,%%g0,%0" \
+ : "=&r" ((USItype)(x3)), \
+ "=&r" ((USItype)(x2)), \
+ "=&r" ((USItype)(x1)), \
+ "=&r" ((USItype)(x0)) \
+ : "rI" ((USItype)(i)), \
+ "0" ((USItype)(x3)), \
+ "1" ((USItype)(x2)), \
+ "2" ((USItype)(x1)), \
+ "3" ((USItype)(x0)) \
+ : "cc")
+
+/* Obtain the current rounding mode. */
+#ifndef FP_ROUNDMODE
+#define FP_ROUNDMODE ((_fcw >> 30) & 0x3)
+#endif
+
+/* Exception flags. */
+#define FP_EX_INVALID (1 << 4)
+#define FP_EX_OVERFLOW (1 << 3)
+#define FP_EX_UNDERFLOW (1 << 2)
+#define FP_EX_DIVZERO (1 << 1)
+#define FP_EX_INEXACT (1 << 0)
+
+#define _FP_DECL_EX fpu_control_t _fcw
+
+#ifdef __UCLIBC_HAS_FPU__
+#define FP_INIT_ROUNDMODE \
+do { \
+ _FPU_GETCW(_fcw); \
+} while (0)
+
+/* Simulate exceptions using double arithmetics. */
+extern double ___Q_simulate_exceptions(int exc);
+
+#define FP_HANDLE_EXCEPTIONS \
+do { \
+ if (!_fex) \
+ { \
+ /* This is the common case, so we do it inline. \
+ * We need to clear cexc bits if any. \
+ */ \
+ extern unsigned long long ___Q_numbers[]; \
+ __asm__ __volatile__("\
+ ldd [%0], %%f30\n\
+ faddd %%f30, %%f30, %%f30\
+ " : : "r" (___Q_numbers) : "f30"); \
+ } \
+ else \
+ ___Q_simulate_exceptions (_fex); \
+} while (0)
+#endif
diff --git a/libc/sysdeps/linux/sparc/soft-fp/single.h b/libc/sysdeps/linux/sparc/soft-fp/single.h
new file mode 100644
index 000000000..c10d25a4a
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/single.h
@@ -0,0 +1,150 @@
+/* Software floating-point emulation.
+ Definitions for IEEE Single Precision.
+ Copyright (C) 1997,1998,1999,2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com),
+ Jakub Jelinek (jj@ultra.linux.cz),
+ David S. Miller (davem@redhat.com) and
+ Peter Maydell (pmaydell@chiark.greenend.org.uk).
+
+ 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 into
+ combinations with other programs, and to distribute those
+ combinations without any restriction coming from the use of this
+ file. (The Lesser General Public License restrictions do apply in
+ other respects; for example, they cover modification of the file,
+ and distribution when not linked into a combine executable.)
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#if _FP_W_TYPE_SIZE < 32
+#error "Here's a nickel kid. Go buy yourself a real computer."
+#endif
+
+#define _FP_FRACTBITS_S _FP_W_TYPE_SIZE
+
+#define _FP_FRACBITS_S 24
+#define _FP_FRACXBITS_S (_FP_FRACTBITS_S - _FP_FRACBITS_S)
+#define _FP_WFRACBITS_S (_FP_WORKBITS + _FP_FRACBITS_S)
+#define _FP_WFRACXBITS_S (_FP_FRACTBITS_S - _FP_WFRACBITS_S)
+#define _FP_EXPBITS_S 8
+#define _FP_EXPBIAS_S 127
+#define _FP_EXPMAX_S 255
+#define _FP_QNANBIT_S ((_FP_W_TYPE)1 << (_FP_FRACBITS_S-2))
+#define _FP_QNANBIT_SH_S ((_FP_W_TYPE)1 << (_FP_FRACBITS_S-2+_FP_WORKBITS))
+#define _FP_IMPLBIT_S ((_FP_W_TYPE)1 << (_FP_FRACBITS_S-1))
+#define _FP_IMPLBIT_SH_S ((_FP_W_TYPE)1 << (_FP_FRACBITS_S-1+_FP_WORKBITS))
+#define _FP_OVERFLOW_S ((_FP_W_TYPE)1 << (_FP_WFRACBITS_S))
+
+/* The implementation of _FP_MUL_MEAT_S and _FP_DIV_MEAT_S should be
+ chosen by the target machine. */
+
+typedef float SFtype __attribute__((mode(SF)));
+
+union _FP_UNION_S
+{
+ SFtype flt;
+ struct {
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned sign : 1;
+ unsigned exp : _FP_EXPBITS_S;
+ unsigned frac : _FP_FRACBITS_S - (_FP_IMPLBIT_S != 0);
+#else
+ unsigned frac : _FP_FRACBITS_S - (_FP_IMPLBIT_S != 0);
+ unsigned exp : _FP_EXPBITS_S;
+ unsigned sign : 1;
+#endif
+ } bits __attribute__((packed));
+};
+
+#define FP_DECL_S(X) _FP_DECL(1,X)
+#define FP_UNPACK_RAW_S(X,val) _FP_UNPACK_RAW_1(S,X,val)
+#define FP_UNPACK_RAW_SP(X,val) _FP_UNPACK_RAW_1_P(S,X,val)
+#define FP_PACK_RAW_S(val,X) _FP_PACK_RAW_1(S,val,X)
+#define FP_PACK_RAW_SP(val,X) \
+ do { \
+ if (!FP_INHIBIT_RESULTS) \
+ _FP_PACK_RAW_1_P(S,val,X); \
+ } while (0)
+
+#define FP_UNPACK_S(X,val) \
+ do { \
+ _FP_UNPACK_RAW_1(S,X,val); \
+ _FP_UNPACK_CANONICAL(S,1,X); \
+ } while (0)
+
+#define FP_UNPACK_SP(X,val) \
+ do { \
+ _FP_UNPACK_RAW_1_P(S,X,val); \
+ _FP_UNPACK_CANONICAL(S,1,X); \
+ } while (0)
+
+#define FP_UNPACK_SEMIRAW_S(X,val) \
+ do { \
+ _FP_UNPACK_RAW_1(S,X,val); \
+ _FP_UNPACK_SEMIRAW(S,1,X); \
+ } while (0)
+
+#define FP_UNPACK_SEMIRAW_SP(X,val) \
+ do { \
+ _FP_UNPACK_RAW_1_P(S,X,val); \
+ _FP_UNPACK_SEMIRAW(S,1,X); \
+ } while (0)
+
+#define FP_PACK_S(val,X) \
+ do { \
+ _FP_PACK_CANONICAL(S,1,X); \
+ _FP_PACK_RAW_1(S,val,X); \
+ } while (0)
+
+#define FP_PACK_SP(val,X) \
+ do { \
+ _FP_PACK_CANONICAL(S,1,X); \
+ if (!FP_INHIBIT_RESULTS) \
+ _FP_PACK_RAW_1_P(S,val,X); \
+ } while (0)
+
+#define FP_PACK_SEMIRAW_S(val,X) \
+ do { \
+ _FP_PACK_SEMIRAW(S,1,X); \
+ _FP_PACK_RAW_1(S,val,X); \
+ } while (0)
+
+#define FP_PACK_SEMIRAW_SP(val,X) \
+ do { \
+ _FP_PACK_SEMIRAW(S,1,X); \
+ if (!FP_INHIBIT_RESULTS) \
+ _FP_PACK_RAW_1_P(S,val,X); \
+ } while (0)
+
+#define FP_ISSIGNAN_S(X) _FP_ISSIGNAN(S,1,X)
+#define FP_NEG_S(R,X) _FP_NEG(S,1,R,X)
+#define FP_ADD_S(R,X,Y) _FP_ADD(S,1,R,X,Y)
+#define FP_SUB_S(R,X,Y) _FP_SUB(S,1,R,X,Y)
+#define FP_MUL_S(R,X,Y) _FP_MUL(S,1,R,X,Y)
+#define FP_DIV_S(R,X,Y) _FP_DIV(S,1,R,X,Y)
+#define FP_SQRT_S(R,X) _FP_SQRT(S,1,R,X)
+#define _FP_SQRT_MEAT_S(R,S,T,X,Q) _FP_SQRT_MEAT_1(R,S,T,X,Q)
+
+#define FP_CMP_S(r,X,Y,un) _FP_CMP(S,1,r,X,Y,un)
+#define FP_CMP_EQ_S(r,X,Y) _FP_CMP_EQ(S,1,r,X,Y)
+#define FP_CMP_UNORD_S(r,X,Y) _FP_CMP_UNORD(S,1,r,X,Y)
+
+#define FP_TO_INT_S(r,X,rsz,rsg) _FP_TO_INT(S,1,r,X,rsz,rsg)
+#define FP_FROM_INT_S(X,r,rs,rt) _FP_FROM_INT(S,1,X,r,rs,rt)
+
+#define _FP_FRAC_HIGH_S(X) _FP_FRAC_HIGH_1(X)
+#define _FP_FRAC_HIGH_RAW_S(X) _FP_FRAC_HIGH_1(X)
diff --git a/libc/sysdeps/linux/sparc/soft-fp/soft-fp.h b/libc/sysdeps/linux/sparc/soft-fp/soft-fp.h
new file mode 100644
index 000000000..522fba143
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/soft-fp/soft-fp.h
@@ -0,0 +1,204 @@
+/* Software floating-point emulation.
+ Copyright (C) 1997,1998,1999,2000,2002,2003,2005,2006,2007
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com),
+ Jakub Jelinek (jj@ultra.linux.cz),
+ David S. Miller (davem@redhat.com) and
+ Peter Maydell (pmaydell@chiark.greenend.org.uk).
+
+ 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 into
+ combinations with other programs, and to distribute those
+ combinations without any restriction coming from the use of this
+ file. (The Lesser General Public License restrictions do apply in
+ other respects; for example, they cover modification of the file,
+ and distribution when not linked into a combine executable.)
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef SOFT_FP_H
+#define SOFT_FP_H
+
+#include "sfp-machine.h"
+
+/* Allow sfp-machine to have its own byte order definitions. */
+#ifndef __BYTE_ORDER
+#ifdef _LIBC
+#include <endian.h>
+#else
+#error "endianness not defined by sfp-machine.h"
+#endif
+#endif
+
+#define _FP_WORKBITS 3
+#define _FP_WORK_LSB ((_FP_W_TYPE)1 << 3)
+#define _FP_WORK_ROUND ((_FP_W_TYPE)1 << 2)
+#define _FP_WORK_GUARD ((_FP_W_TYPE)1 << 1)
+#define _FP_WORK_STICKY ((_FP_W_TYPE)1 << 0)
+
+#ifndef FP_RND_NEAREST
+# define FP_RND_NEAREST 0
+# define FP_RND_ZERO 1
+# define FP_RND_PINF 2
+# define FP_RND_MINF 3
+#endif
+#ifndef FP_ROUNDMODE
+# define FP_ROUNDMODE FP_RND_NEAREST
+#endif
+
+/* By default don't care about exceptions. */
+#ifndef FP_EX_INVALID
+#define FP_EX_INVALID 0
+#endif
+#ifndef FP_EX_OVERFLOW
+#define FP_EX_OVERFLOW 0
+#endif
+#ifndef FP_EX_UNDERFLOW
+#define FP_EX_UNDERFLOW 0
+#endif
+#ifndef FP_EX_DIVZERO
+#define FP_EX_DIVZERO 0
+#endif
+#ifndef FP_EX_INEXACT
+#define FP_EX_INEXACT 0
+#endif
+#ifndef FP_EX_DENORM
+#define FP_EX_DENORM 0
+#endif
+
+#ifdef _FP_DECL_EX
+#define FP_DECL_EX \
+ int _fex = 0; \
+ _FP_DECL_EX
+#else
+#define FP_DECL_EX int _fex = 0
+#endif
+
+#ifndef FP_INIT_ROUNDMODE
+#define FP_INIT_ROUNDMODE do {} while (0)
+#endif
+
+#ifndef FP_HANDLE_EXCEPTIONS
+#define FP_HANDLE_EXCEPTIONS do {} while (0)
+#endif
+
+#ifndef FP_INHIBIT_RESULTS
+/* By default we write the results always.
+ * sfp-machine may override this and e.g.
+ * check if some exceptions are unmasked
+ * and inhibit it in such a case.
+ */
+#define FP_INHIBIT_RESULTS 0
+#endif
+
+#define FP_SET_EXCEPTION(ex) \
+ _fex |= (ex)
+
+#define FP_UNSET_EXCEPTION(ex) \
+ _fex &= ~(ex)
+
+#define FP_CLEAR_EXCEPTIONS \
+ _fex = 0
+
+#define _FP_ROUND_NEAREST(wc, X) \
+do { \
+ if ((_FP_FRAC_LOW_##wc(X) & 15) != _FP_WORK_ROUND) \
+ _FP_FRAC_ADDI_##wc(X, _FP_WORK_ROUND); \
+} while (0)
+
+#define _FP_ROUND_ZERO(wc, X) (void)0
+
+#define _FP_ROUND_PINF(wc, X) \
+do { \
+ if (!X##_s && (_FP_FRAC_LOW_##wc(X) & 7)) \
+ _FP_FRAC_ADDI_##wc(X, _FP_WORK_LSB); \
+} while (0)
+
+#define _FP_ROUND_MINF(wc, X) \
+do { \
+ if (X##_s && (_FP_FRAC_LOW_##wc(X) & 7)) \
+ _FP_FRAC_ADDI_##wc(X, _FP_WORK_LSB); \
+} while (0)
+
+#define _FP_ROUND(wc, X) \
+do { \
+ if (_FP_FRAC_LOW_##wc(X) & 7) \
+ FP_SET_EXCEPTION(FP_EX_INEXACT); \
+ switch (FP_ROUNDMODE) \
+ { \
+ case FP_RND_NEAREST: \
+ _FP_ROUND_NEAREST(wc,X); \
+ break; \
+ case FP_RND_ZERO: \
+ _FP_ROUND_ZERO(wc,X); \
+ break; \
+ case FP_RND_PINF: \
+ _FP_ROUND_PINF(wc,X); \
+ break; \
+ case FP_RND_MINF: \
+ _FP_ROUND_MINF(wc,X); \
+ break; \
+ } \
+} while (0)
+
+#define FP_CLS_NORMAL 0
+#define FP_CLS_ZERO 1
+#define FP_CLS_INF 2
+#define FP_CLS_NAN 3
+
+#define _FP_CLS_COMBINE(x,y) (((x) << 2) | (y))
+
+#include "op-1.h"
+#include "op-2.h"
+#include "op-4.h"
+#include "op-8.h"
+#include "op-common.h"
+
+/* Sigh. Silly things longlong.h needs. */
+#define UWtype _FP_W_TYPE
+#define W_TYPE_SIZE _FP_W_TYPE_SIZE
+
+typedef int QItype __attribute__((mode(QI)));
+typedef int SItype __attribute__((mode(SI)));
+typedef int DItype __attribute__((mode(DI)));
+typedef unsigned int UQItype __attribute__((mode(QI)));
+typedef unsigned int USItype __attribute__((mode(SI)));
+typedef unsigned int UDItype __attribute__((mode(DI)));
+#if _FP_W_TYPE_SIZE == 32
+typedef unsigned int UHWtype __attribute__((mode(HI)));
+#elif _FP_W_TYPE_SIZE == 64
+typedef USItype UHWtype;
+#endif
+
+#ifndef CMPtype
+#define CMPtype int
+#endif
+
+#define SI_BITS (__CHAR_BIT__ * (int)sizeof(SItype))
+#define DI_BITS (__CHAR_BIT__ * (int)sizeof(DItype))
+
+#ifndef umul_ppmm
+#include "longlong.h"
+#endif
+
+#ifdef _LIBC
+#include <stdlib.h>
+#else
+extern void abort (void);
+#endif
+
+#endif
diff --git a/libc/sysdeps/linux/sparc/sparcv9/rem.S b/libc/sysdeps/linux/sparc/sparcv9/rem.S
deleted file mode 100644
index 1474e32ae..000000000
--- a/libc/sysdeps/linux/sparc/sparcv9/rem.S
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Sparc v9 has divide.
- * As divx takes 68 cycles and sdivcc only 36,
- * we use sdivcc eventhough it is deprecated.
- */
-
- .text
- .align 32
-ENTRY(.rem)
-
- sra %o0, 31, %o2
- wr %o2, 0, %y
- sdivcc %o0, %o1, %o2
- xnor %o2, %g0, %o3
- movvs %icc, %o3, %o2
- smul %o2, %o1, %o2
- retl
- sub %o0, %o2, %o0
-
-END(.rem)
diff --git a/libc/sysdeps/linux/sparc/sparcv9/sdiv.S b/libc/sysdeps/linux/sparc/sparcv9/sdiv.S
deleted file mode 100644
index 45535bb68..000000000
--- a/libc/sysdeps/linux/sparc/sparcv9/sdiv.S
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Sparc v9 has divide.
- * As divx takes 68 cycles and sdivcc only 36,
- * we use sdivcc eventhough it is deprecated.
- */
-
- .text
- .align 32
-ENTRY(.div)
-
- sra %o0, 31, %o2
- wr %o2, 0, %y
- sdivcc %o0, %o1, %o0
- xnor %o0, %g0, %o2
- retl
- movvs %icc, %o2, %o0
-
-END(.div)
diff --git a/libc/sysdeps/linux/sparc/sparcv9/udiv.S b/libc/sysdeps/linux/sparc/sparcv9/udiv.S
deleted file mode 100644
index 303f29bdf..000000000
--- a/libc/sysdeps/linux/sparc/sparcv9/udiv.S
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * Sparc v9 has divide.
- * As divx takes 68 cycles and udiv only 37,
- * we use udiv eventhough it is deprecated.
- */
-
- .text
- .align 32
-ENTRY(.udiv)
-
- wr %g0, 0, %y
- retl
- udiv %o0, %o1, %o0
-
-END(.udiv)
diff --git a/libc/sysdeps/linux/sparc/sparcv9/umul.S b/libc/sysdeps/linux/sparc/sparcv9/umul.S
deleted file mode 100644
index e65e4b95f..000000000
--- a/libc/sysdeps/linux/sparc/sparcv9/umul.S
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * Sparc v9 has multiply.
- */
-
- .text
- .align 32
-ENTRY(.umul)
-
- srl %o0, 0, %o0
- srl %o1, 0, %o1
- mulx %o0, %o1, %o0
- retl
- srlx %o0, 32, %o1
-
-END(.umul)
diff --git a/libc/sysdeps/linux/sparc/sparcv9/urem.S b/libc/sysdeps/linux/sparc/sparcv9/urem.S
deleted file mode 100644
index 93542698d..000000000
--- a/libc/sysdeps/linux/sparc/sparcv9/urem.S
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Sparc v9 has divide.
- * As divx takes 68 cycles and udiv only 37,
- * we use udiv eventhough it is deprecated.
- */
-
- .text
- .align 32
-ENTRY(.urem)
-
- wr %g0, 0, %y
- udiv %o0, %o1, %o2
- umul %o2, %o1, %o2
- retl
- sub %o0, %o2, %o0
-
-END(.urem)
diff --git a/libc/sysdeps/linux/sparc/sys/procfs.h b/libc/sysdeps/linux/sparc/sys/procfs.h
index 2827b1ec3..edbd5a5ba 100644
--- a/libc/sysdeps/linux/sparc/sys/procfs.h
+++ b/libc/sysdeps/linux/sparc/sys/procfs.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_PROCFS_H
#define _SYS_PROCFS_H 1
@@ -33,20 +32,6 @@
__BEGIN_DECLS
-#if __WORDSIZE == 64
-
-#define ELF_NGREG 36
-
-typedef struct
- {
- unsigned long pr_regs[32];
- unsigned long pr_fsr;
- unsigned long pr_gsr;
- unsigned long pr_fprs;
- } elf_fpregset_t;
-
-#else /* sparc32 */
-
#define ELF_NGREG 38
typedef struct
@@ -64,8 +49,6 @@ typedef struct
unsigned int pr_q[64];
} elf_fpregset_t;
-#endif /* sparc32 */
-
typedef unsigned long elf_greg_t;
typedef elf_greg_t elf_gregset_t[ELF_NGREG];
@@ -111,13 +94,8 @@ struct elf_prpsinfo
char pr_zomb; /* Zombie. */
char pr_nice; /* Nice val. */
unsigned long int pr_flag; /* Flags. */
-#if __WORDSIZE == 64
- unsigned int pr_uid;
- unsigned int pr_gid;
-#else
unsigned short int pr_uid;
unsigned short int pr_gid;
-#endif
int pr_pid, pr_ppid, pr_pgrp, pr_sid;
/* Lots missing */
char pr_fname[16]; /* Filename of executable. */
@@ -139,73 +117,6 @@ typedef __pid_t lwpid_t;
typedef struct elf_prstatus prstatus_t;
typedef struct elf_prpsinfo prpsinfo_t;
-#if __WORDSIZE == 64
-
-/* Provide 32-bit variants so that BFD can read 32-bit
- core files. */
-#define ELF_NGREG32 38
-typedef struct
- {
- union
- {
- unsigned int pr_regs[32];
- double pr_dregs[16];
- } pr_fr;
- unsigned int __unused;
- unsigned int pr_fsr;
- unsigned char pr_qcnt;
- unsigned char pr_q_entrysize;
- unsigned char pr_en;
- unsigned int pr_q[64];
- } elf_fpregset_t32;
-
-typedef unsigned int elf_greg_t32;
-typedef elf_greg_t32 elf_gregset_t32[ELF_NGREG32];
-
-struct elf_prstatus32
- {
- struct elf_siginfo pr_info; /* Info associated with signal. */
- short int pr_cursig; /* Current signal. */
- unsigned int pr_sigpend; /* Set of pending signals. */
- unsigned int pr_sighold; /* Set of held signals. */
- __pid_t pr_pid;
- __pid_t pr_ppid;
- __pid_t pr_pgrp;
- __pid_t pr_sid;
- struct
- {
- int tv_sec, tv_usec;
- } pr_utime, /* User time. */
- pr_stime, /* System time. */
- pr_cutime, /* Cumulative user time. */
- pr_cstime; /* Cumulative system time. */
- elf_gregset_t32 pr_reg; /* GP registers. */
- int pr_fpvalid; /* True if math copro being used. */
- };
-
-struct elf_prpsinfo32
- {
- char pr_state; /* Numeric process state. */
- char pr_sname; /* Char for pr_state. */
- char pr_zomb; /* Zombie. */
- char pr_nice; /* Nice val. */
- unsigned 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. */
- };
-
-typedef elf_gregset_t32 prgregset32_t;
-typedef elf_fpregset_t32 prfpregset32_t;
-
-typedef struct elf_prstatus32 prstatus32_t;
-typedef struct elf_prpsinfo32 prpsinfo32_t;
-
-#endif /* sparc64 */
-
__END_DECLS
#endif /* sys/procfs.h */
diff --git a/libc/sysdeps/linux/sparc/sys/ptrace.h b/libc/sysdeps/linux/sparc/sys/ptrace.h
index d573f0e99..0f6c2ccae 100644
--- a/libc/sysdeps/linux/sparc/sys/ptrace.h
+++ b/libc/sysdeps/linux/sparc/sys/ptrace.h
@@ -1,5 +1,5 @@
/* `ptrace' debugger support interface. Linux/SPARC version.
- Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1996-2014 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
@@ -13,15 +13,14 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_PTRACE_H
#define _SYS_PTRACE_H 1
#include <features.h>
-
+#include <bits/types.h>
#include <bits/wordsize.h>
/* Linux/SPARC kernels up to 2.3.18 do not care much
@@ -148,12 +147,11 @@ enum __ptrace_request
#endif
/* Continue and stop at the next (return from) syscall. */
- PTRACE_SYSCALL = 24
+ PTRACE_SYSCALL = 24,
#define PTRACE_SYSCALL PTRACE_SYSCALL
#if __WORDSIZE == 64
- ,
/* Get all floating point registers used by a processes.
This is not supported on all machines. */
PTRACE_GETFPREGS = 25,
@@ -161,10 +159,98 @@ enum __ptrace_request
/* Set all floating point registers used by a processes.
This is not supported on all machines. */
- PTRACE_SETFPREGS = 26
+ PTRACE_SETFPREGS = 26,
#define PT_SETFPREGS PTRACE_SETFPREGS
#endif
+
+ /* 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
+
+ /* Get register content. */
+ PTRACE_GETREGSET = 0x4204,
+#define PTRACE_GETREGSET PTRACE_GETREGSET
+
+ /* Set register content. */
+ PTRACE_SETREGSET = 0x4205,
+#define PTRACE_SETREGSET PTRACE_SETREGSET
+
+ /* Like PTRACE_ATTACH, but do not force tracee to trap and do not affect
+ signal or group stop state. */
+ PTRACE_SEIZE = 0x4206,
+#define PTRACE_SEIZE PTRACE_SEIZE
+
+ /* Trap seized tracee. */
+ PTRACE_INTERRUPT = 0x4207,
+#define PTRACE_INTERRUPT PTRACE_INTERRUPT
+
+ /* Wait for next group event. */
+ PTRACE_LISTEN = 0x4208,
+#define PTRACE_LISTEN PTRACE_LISTEN
+
+ PTRACE_PEEKSIGINFO = 0x4209
+#define PTRACE_PEEKSIGINFO PTRACE_PEEKSIGINFO
+};
+
+
+/* Flag for PTRACE_LISTEN. */
+enum __ptrace_flags
+{
+ PTRACE_SEIZE_DEVEL = 0x80000000
+};
+
+/* 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_TRACESECCOMP = 0x00000080,
+ PTRACE_O_EXITKILL = 0x00100000,
+ PTRACE_O_MASK = 0x001000ff
+};
+
+/* 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,
+ PTRACE_EVENT_SECCOMP = 7
+};
+
+/* Arguments for PTRACE_PEEKSIGINFO. */
+struct __ptrace_peeksiginfo_args
+{
+ __uint64_t off; /* From which siginfo to start. */
+ __uint32_t flags; /* Flags for peeksiginfo. */
+ __int32_t nr; /* How many siginfos to take. */
+};
+
+enum __ptrace_peeksiginfo_flags
+{
+ /* Read signals from a shared (process wide) queue. */
+ PTRACE_PEEKSIGINFO_SHARED = (1 << 0)
};
/* Perform process tracing functions. REQUEST is one of the values
diff --git a/libc/sysdeps/linux/sparc/sys/ucontext.h b/libc/sysdeps/linux/sparc/sys/ucontext.h
index b1102b04c..f06f25d7b 100644
--- a/libc/sysdeps/linux/sparc/sys/ucontext.h
+++ b/libc/sysdeps/linux/sparc/sys/ucontext.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_UCONTEXT_H
#define _SYS_UCONTEXT_H 1
diff --git a/libc/sysdeps/linux/sparc/sys/user.h b/libc/sysdeps/linux/sparc/sys/user.h
index 2aad01b0f..4e3e65983 100644
--- a/libc/sysdeps/linux/sparc/sys/user.h
+++ b/libc/sysdeps/linux/sparc/sys/user.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_USER_H
#define _SYS_USER_H 1
diff --git a/libc/sysdeps/linux/sparc/syscall.S b/libc/sysdeps/linux/sparc/syscall.S
index 86055ec71..1a67dfb59 100644
--- a/libc/sysdeps/linux/sparc/syscall.S
+++ b/libc/sysdeps/linux/sparc/syscall.S
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <features.h>
#include <sys/syscall.h>
diff --git a/libc/sysdeps/linux/sparc/sysdep.h b/libc/sysdeps/linux/sparc/sysdep.h
new file mode 100644
index 000000000..cf3e3afd1
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/sysdep.h
@@ -0,0 +1,69 @@
+#ifndef _LINUX_SPARC_SYSDEP_H
+#define _LINUX_SPARC_SYSDEP_H 1
+
+#include <common/sysdep.h>
+
+#undef ENTRY
+#undef END
+
+#ifdef __ASSEMBLER__
+
+#define LOADSYSCALL(x) mov __NR_##x, %g1
+
+#define ENTRY(name) \
+ .align 4; \
+ .global C_SYMBOL_NAME(name); \
+ .type name, @function; \
+C_LABEL(name) \
+ cfi_startproc;
+
+#define END(name) \
+ cfi_endproc; \
+ .size name, . - name
+
+#define LOC(name) .L##name
+
+ /* If the offset to __syscall_error fits into a signed 22-bit
+ * immediate branch offset, the linker will relax the call into
+ * a normal branch.
+ */
+#undef PSEUDO
+#undef PSEUDO_END
+#undef PSEUDO_NOERRNO
+#undef PSEUDO_ERRVAL
+
+#define PSEUDO(name, syscall_name, args) \
+ .text; \
+ .globl __syscall_error; \
+ENTRY(name); \
+ LOADSYSCALL(syscall_name); \
+ ta 0x10; \
+ bcc 1f; \
+ mov %o7, %g1; \
+ call __syscall_error; \
+ mov %g1, %o7; \
+1:
+
+#define PSEUDO_NOERRNO(name, syscall_name, args)\
+ .text; \
+ENTRY(name); \
+ LOADSYSCALL(syscall_name); \
+ ta 0x10;
+
+#define PSEUDO_ERRVAL(name, syscall_name, args) \
+ .text; \
+ENTRY(name); \
+ LOADSYSCALL(syscall_name); \
+ ta 0x10;
+
+#define PSEUDO_END(name) \
+ END(name)
+
+
+#endif /* __ASSEMBLER__ */
+
+/* Pointer mangling is not yet supported for SPARC. */
+#define PTR_MANGLE(var) (void) (var)
+#define PTR_DEMANGLE(var) (void) (var)
+
+#endif
diff --git a/libc/sysdeps/linux/sparc/vfork.S b/libc/sysdeps/linux/sparc/vfork.S
index 35ca037d8..e5a3c303d 100644
--- a/libc/sysdeps/linux/sparc/vfork.S
+++ b/libc/sysdeps/linux/sparc/vfork.S
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* Code taken from glibc2.2.2/sysdeps/unix/sysv/linux/sparc/vfork.S */
@@ -52,4 +51,4 @@ __vfork:
.size __vfork,.-__vfork
weak_alias(__vfork,vfork)
-libc_hidden_weak(vfork)
+libc_hidden_def(vfork)
diff --git a/libc/sysdeps/linux/v850/Makefile b/libc/sysdeps/linux/v850/Makefile
deleted file mode 100644
index 60dc97c1d..000000000
--- a/libc/sysdeps/linux/v850/Makefile
+++ /dev/null
@@ -1,64 +0,0 @@
-# Makefile for uClibc
-#
-# Copyright (C) 2001,2002 NEC Corporation
-# Copyright (C) 2001,2002 Miles Bader <miles@gnu.org>
-#
-# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-
-TOPDIR=../../../../
-include $(TOPDIR)Rules.mak
-
-CFLAGS += -I..
-ASFLAGS += -I.. -D__ASSEMBLER -DASM_GLOBAL_DIRECTIVE=.globl
-
-TARGET_MACHINE_TYPE=$(shell $(CC) -dumpmachine)
-
-CRT_SRC := crt0.S
-CRT_OBJ := crt0.o crt1.o
-CTOR_TARGETS := $(TOPDIR)lib/crti.o $(TOPDIR)lib/crtn.o
-
-SSRC := setjmp.S __longjmp.S vfork.S
-SOBJ := $(patsubst %.S,%.o, $(SSRC))
-
-CSRC := mmap.c syscall.c clone.c
-COBJ := $(patsubst %.c,%.o, $(CSRC))
-
-OBJS := $(SOBJ) $(COBJ)
-
-OBJ_LIST := ../../../obj.sysdeps.$(TARGET_ARCH)
-
-all: $(OBJ_LIST) $(CTOR_TARGETS)
-
-$(OBJ_LIST): $(OBJS) $(CRT_OBJ)
- $(STRIPTOOL) -x -R .note -R .comment $^
- $(INSTALL) -d $(TOPDIR)lib/
- cp $(CRT_OBJ) $(TOPDIR)lib/
- echo $(patsubst %, sysdeps/linux/$(TARGET_ARCH)/%, $(OBJS)) > $@
-
-$(CRT_OBJ): $(CRT_SRC)
- $(CC) $(ASFLAGS) -DL_$* $< -c -o $*.o
-
-$(SOBJ): %.o : %.S
- $(CC) $(ASFLAGS) -c $< -o $@
-
-$(COBJ): %.o : %.c
- $(CC) $(CFLAGS) -c $< -o $@
-
-ifeq ($(UCLIBC_CTOR_DTOR),y)
-$(TOPDIR)lib/crti.o: crti.S
- $(INSTALL) -d $(TOPDIR)lib/
- $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c $< -o $@
-
-$(TOPDIR)lib/crtn.o: crtn.S
- $(INSTALL) -d $(TOPDIR)lib/
- $(CC) $(ASFLAGS) $(SSP_DISABLE_FLAGS) -c $< -o $@
-else
-$(CTOR_TARGETS):
- $(INSTALL) -d $(TOPDIR)lib/
- $(AR) $(ARFLAGS) $@
-endif
-
-headers:
-
-clean:
- $(RM) *.o *~ core
diff --git a/libc/sysdeps/linux/v850/__longjmp.S b/libc/sysdeps/linux/v850/__longjmp.S
deleted file mode 100644
index 2c470264f..000000000
--- a/libc/sysdeps/linux/v850/__longjmp.S
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * libc/sysdeps/linux/v850/longjmp.S -- `longjmp' for v850
- *
- * Copyright (C) 2001,02 NEC Corporation
- * Copyright (C) 2001,02 Miles Bader <miles@gnu.org>
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- *
- * Written by Miles Bader <miles@gnu.org>
- */
-
-#include <features.h>
-#define _SETJMP_H
-#define _ASM
-#include <bits/setjmp.h>
-
-#include <clinkage.h>
-
- .text
-C_ENTRY(__longjmp):
- /* Save registers */
- mov r6, ep
- sld.w 0[ep], sp
- sld.w 4[ep], lp
- sld.w 8[ep], r2
- sld.w 12[ep], r20
- sld.w 16[ep], r21
- sld.w 20[ep], r22
- sld.w 24[ep], r23
- sld.w 28[ep], r24
- sld.w 32[ep], r25
- sld.w 36[ep], r26
- sld.w 40[ep], r27
- sld.w 44[ep], r28
- sld.w 48[ep], r29
- mov 1, r10 // return val
- jmp [lp]
-C_END(__longjmp)
-libc_hidden_def(__longjmp)
diff --git a/libc/sysdeps/linux/v850/bits/byteswap.h b/libc/sysdeps/linux/v850/bits/byteswap.h
deleted file mode 100644
index 44fbee488..000000000
--- a/libc/sysdeps/linux/v850/bits/byteswap.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * libc/sysdeps/linux/v850/bits/byteswap.h -- Macros to swap the order
- * of bytes in integer values
- *
- * Copyright (C) 2001 NEC Corporation
- * Copyright (C) 2001 Miles Bader <miles@gnu.org>
- * Copyright (C) 1997,1998,2001 Free Software Foundation, Inc.
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- */
-
-#if !defined _BYTESWAP_H && !defined _NETINET_IN_H
-# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
-#endif
-
-/* Swap bytes in 16 bit value. */
-#define __bswap_constant_16(x) \
- ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))
-
-#ifdef __GNUC__
-# define __bswap_16(x) \
- (__extension__ \
- ({ unsigned long int __bswap_16_v; \
- if (__builtin_constant_p (x)) \
- __bswap_16_v = __bswap_constant_16 (x); \
- else \
- __asm__ ("bsh %1, %0" : "=r" (__bswap_16_v) : "r" (x)); \
- __bswap_16_v; }))
-#else
-# define __bswap_16(x) __bswap_constant_16 (x)
-#endif
-
-/* Swap bytes in 32 bit value. */
-#define __bswap_constant_32(x) \
- ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
- (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
-
-#ifdef __GNUC__
-# define __bswap_32(x) \
- (__extension__ \
- ({ unsigned long int __bswap_32_v; \
- if (__builtin_constant_p (x)) \
- __bswap_32_v = __bswap_constant_32 (x); \
- else \
- __asm__ ("bsw %1, %0" : "=r" (__bswap_32_v) : "r" (x)); \
- __bswap_32_v; }))
-#else
-# define __bswap_32(x) __bswap_constant_32 (x)
-#endif
-
-#if defined __GNUC__ && __GNUC__ >= 2
-/* Swap bytes in 64 bit value. */
-# define __bswap_64(x) \
- (__extension__ \
- ({ union { unsigned long long int __ll; \
- unsigned long int __l[2]; } __bswap_64_v, __bswap_64_r; \
- __bswap_64_v.__ll = (x); \
- __bswap_64_r.__l[0] = __bswap_32 (__bswap_64_v.__l[1]); \
- __bswap_64_r.__l[1] = __bswap_32 (__bswap_64_v.__l[0]); \
- __bswap_64_r.__ll; }))
-#endif
diff --git a/libc/sysdeps/linux/v850/bits/endian.h b/libc/sysdeps/linux/v850/bits/endian.h
deleted file mode 100644
index ae78da373..000000000
--- a/libc/sysdeps/linux/v850/bits/endian.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * libc/sysdeps/linux/v850/bits/endian.h -- Define processor endianess
- *
- * Copyright (C) 2001 NEC Corporation
- * Copyright (C) 2001 Miles Bader <miles@gnu.org>
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- *
- * Written by Miles Bader <miles@gnu.org>
- */
-
-#ifndef _ENDIAN_H
-# error "Never use <bits/endian.h> directly; include <endian.h> instead."
-#endif
-
-#define __BYTE_ORDER __LITTLE_ENDIAN
diff --git a/libc/sysdeps/linux/v850/bits/kernel_stat.h b/libc/sysdeps/linux/v850/bits/kernel_stat.h
deleted file mode 100644
index 02343ed48..000000000
--- a/libc/sysdeps/linux/v850/bits/kernel_stat.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* Stat structure for linux/v850 */
-
-#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;
- __kernel_ino_t st_ino;
- __kernel_mode_t st_mode;
- __kernel_nlink_t st_nlink;
- __kernel_uid_t st_uid;
- __kernel_gid_t st_gid;
- __kernel_dev_t st_rdev;
- __kernel_off_t st_size;
- unsigned long st_blksize;
- unsigned long st_blocks;
- unsigned long st_atime;
- unsigned long __unused1;
- unsigned long st_mtime;
- unsigned long __unused2;
- unsigned long st_ctime;
- unsigned long __unused3;
- unsigned long __unused4;
- unsigned long __unused5;
-};
-
-struct kernel_stat64
-{
- __kernel_dev_t st_dev;
- unsigned long __unused0;
- unsigned long __unused1;
-
- __kernel_ino64_t st_ino;
-
- __kernel_mode_t st_mode;
- __kernel_nlink_t st_nlink;
-
- __kernel_uid_t st_uid;
- __kernel_gid_t st_gid;
-
- __kernel_dev_t st_rdev;
- unsigned long __unused2;
- unsigned long __unused3;
-
- __kernel_loff_t st_size;
- unsigned long st_blksize;
-
- unsigned long __unused4; /* future possible st_blocks high bits */
- unsigned long st_blocks; /* Number 512-byte blocks allocated. */
-
- unsigned long st_atime;
- unsigned long __unused5;
-
- unsigned long st_mtime;
- unsigned long __unused6;
-
- unsigned long st_ctime;
- unsigned long __unused7; /* high 32 bits of ctime someday */
-};
-
-#endif /* _BITS_STAT_STRUCT_H */
diff --git a/libc/sysdeps/linux/v850/bits/kernel_types.h b/libc/sysdeps/linux/v850/bits/kernel_types.h
deleted file mode 100644
index 3e851ab7b..000000000
--- a/libc/sysdeps/linux/v850/bits/kernel_types.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * sysdeps/linux/v850/bits/kernel_types.h -- Kernel versions of standard types
- *
- * Copyright (C) 2001,2002 NEC Corporation
- * Copyright (C) 2001,2002 Miles Bader <miles@gnu.org>
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- *
- * Written by Miles Bader <miles@gnu.org>
- */
-
-#ifndef __V850_POSIX_TYPES_H__
-#define __V850_POSIX_TYPES_H__
-
-typedef unsigned int __kernel_dev_t;
-typedef unsigned long __kernel_ino_t;
-typedef unsigned long long __kernel_ino64_t;
-typedef unsigned int __kernel_mode_t;
-typedef unsigned int __kernel_nlink_t;
-typedef long __kernel_off_t;
-typedef long long __kernel_loff_t;
-typedef int __kernel_pid_t;
-typedef unsigned short __kernel_ipc_pid_t;
-typedef unsigned int __kernel_uid_t;
-typedef unsigned int __kernel_gid_t;
-typedef unsigned int __kernel_size_t;
-typedef int __kernel_ssize_t;
-typedef int __kernel_ptrdiff_t;
-typedef long __kernel_time_t;
-typedef long __kernel_suseconds_t;
-typedef long __kernel_clock_t;
-typedef int __kernel_daddr_t;
-typedef char * __kernel_caddr_t;
-typedef unsigned short __kernel_uid16_t;
-typedef unsigned short __kernel_gid16_t;
-typedef unsigned int __kernel_uid32_t;
-typedef unsigned int __kernel_gid32_t;
-
-typedef unsigned short __kernel_old_uid_t;
-typedef unsigned short __kernel_old_gid_t;
-typedef __kernel_dev_t __kernel_old_dev_t;
-
-typedef struct {
-#ifdef __USE_ALL
- int val[2];
-#else
- int __val[2];
-#endif
-} __kernel_fsid_t;
-
-#endif /* __V850_POSIX_TYPES_H__ */
diff --git a/libc/sysdeps/linux/v850/bits/mman.h b/libc/sysdeps/linux/v850/bits/mman.h
deleted file mode 100644
index 4393d0344..000000000
--- a/libc/sysdeps/linux/v850/bits/mman.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* Definitions for POSIX memory map interface. Linux/v850 version.
- Copyright (C) 1997, 1999, 2001, 2002 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- 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. */
-
-/* These are the bits used by 4.4 BSD and its derivatives. On systems
- (such as GNU) where these facilities are not system services but can be
- emulated in the C library, these are the definitions we emulate. */
-
-#ifndef _SYS_MMAN_H
-# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
-#endif
-
-/* The following definitions basically come from the kernel headers.
- But the kernel header is not namespace clean. */
-
-
-/* Protections are chosen from these bits, OR'd together. The
- implementation does not necessarily support PROT_EXEC or PROT_WRITE
- without PROT_READ. The only guarantees are that no writing will be
- allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
-
-#define PROT_READ 0x1 /* Page can be read. */
-#define PROT_WRITE 0x2 /* Page can be written. */
-#define PROT_EXEC 0x4 /* Page can be executed. */
-#define PROT_NONE 0x0 /* Page can not be accessed. */
-
-/* Sharing types (must choose one and only one of these). */
-#define MAP_SHARED 0x01 /* Share changes. */
-#define MAP_PRIVATE 0x02 /* Changes are private. */
-#ifdef __USE_MISC
-# define MAP_TYPE 0x0f /* Mask for type of mapping. */
-#endif
-
-/* Other flags. */
-#define MAP_FIXED 0x10 /* Interpret addr exactly. */
-#ifdef __USE_MISC
-# define MAP_FILE 0
-# define MAP_ANONYMOUS 0x20 /* Don't use a file. */
-# define MAP_ANON MAP_ANONYMOUS
-#endif
-
-/* These are Linux-specific. */
-#ifdef __USE_MISC
-# define MAP_GROWSDOWN 0x0100 /* Stack-like segment. */
-# define MAP_DENYWRITE 0x0800 /* ETXTBSY */
-# define MAP_EXECUTABLE 0x1000 /* Mark it as an executable. */
-# define MAP_LOCKED 0x2000 /* Lock the mapping. */
-# define MAP_NORESERVE 0x4000 /* Don't check for reservations. */
-#endif
-
-/* Flags to `msync'. */
-#define MS_ASYNC 1 /* Sync memory asynchronously. */
-#define MS_SYNC 4 /* Synchronous memory sync. */
-#define MS_INVALIDATE 2 /* Invalidate the caches. */
-
-/* Advice to `madvise'. */
-#ifdef __USE_BSD
-# define MADV_NORMAL 0 /* No further special treatment. */
-# define MADV_RANDOM 1 /* Expect random page references. */
-# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
-# define MADV_WILLNEED 3 /* Will need these pages. */
-# define MADV_DONTNEED 4 /* Don't need these pages. */
-#endif
-
-/* The POSIX people had to invent similar names for the same things. */
-#ifdef __USE_XOPEN2K
-# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
-# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
-# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
-# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
-# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
-#endif
-
-
-/* Flags for `mlockall' (can be OR'd together). */
-#define MCL_CURRENT 1 /* Lock all currently mapped pages. */
-#define MCL_FUTURE 2 /* Lock all additions to address
- space. */
-
-/* Flags for `mremap'. */
-#ifdef __USE_GNU
-# define MREMAP_MAYMOVE 1
-# define MREMAP_FIXED 2
-#endif
diff --git a/libc/sysdeps/linux/v850/bits/select.h b/libc/sysdeps/linux/v850/bits/select.h
deleted file mode 100644
index b6bb05452..000000000
--- a/libc/sysdeps/linux/v850/bits/select.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * include/bits/select.h -- fd_set operations
- *
- * Copyright (C) 2001 NEC Corporation
- * Copyright (C) 2001 Miles Bader <miles@gnu.org>
- * Copyright (C) 1997, 1998 Free Software Foundation, Inc.
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- */
-
-#ifndef _SYS_SELECT_H
-# error "Never use <bits/select.h> directly; include <sys/select.h> instead."
-#endif
-
-#ifdef __GNUC__
-
-/* We don't use `memset' because this would require a prototype and
- the array isn't too big. */
-#define __FD_ZERO(s) \
- do { \
- unsigned int __i; \
- fd_set *__arr = (s); \
- for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) \
- __FDS_BITS (__arr)[__i] = 0; \
- } while (0)
-
-#define __FD_SET(fd, s) \
- do { \
- int __fd = (fd); \
- void *__addr = (void *)&__FDS_BITS (s); \
- __asm__ __volatile__ ("set1 %0, [%1]" \
- : /*nothing*/ \
- : "r" (__fd & 0x7), "r" (__addr + (__fd >> 3)));\
- } while (0)
-
-#define __FD_CLR(fd, s) \
- do { \
- int __fd = (fd); \
- void *__addr = (void *)&__FDS_BITS (s); \
- __asm__ __volatile__ ("clr1 %0, [%1]" \
- : /*nothing*/ \
- : "r" (__fd & 0x7), "r" (__addr + (__fd >> 3)));\
- } while (0)
-
-#define __FD_ISSET(fd, s) \
- ({ \
- int __fd = (fd); \
- void *__addr = (void *)&__FDS_BITS (s); \
- int res; \
- __asm__ ("tst1 %1, [%2]; setf nz, %0" \
- : "=r" (res) \
- : "r" (__fd & 0x7), "r" (__addr + (__fd >> 3))); \
- res; \
- })
-
-#else /* !__GNUC__ */
-
-#define __FD_SET(d, s) (__FDS_BITS (s)[__FDELT(d)] |= __FDMASK(d))
-#define __FD_CLR(d, s) (__FDS_BITS (s)[__FDELT(d)] &= ~__FDMASK(d))
-#define __FD_ISSET(d, s) ((__FDS_BITS (s)[__FDELT(d)] & __FDMASK(d)) != 0)
-
-#endif /* __GNUC__ */
diff --git a/libc/sysdeps/linux/v850/bits/setjmp.h b/libc/sysdeps/linux/v850/bits/setjmp.h
deleted file mode 100644
index c94373787..000000000
--- a/libc/sysdeps/linux/v850/bits/setjmp.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * libc/sysdeps/linux/v850/bits/setjmp.h -- v850 version of `jmp_buf' type
- *
- * Copyright (C) 2001 NEC Corporation
- * Copyright (C) 2001 Miles Bader <miles@gnu.org>
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- *
- * Written by Miles Bader <miles@gnu.org>
- */
-
-#ifndef _BITS_SETJMP_H
-#define _BITS_SETJMP_H 1
-
-#if !defined _SETJMP_H && !defined _PTHREAD_H
-# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
-#endif
-
-#ifndef _ASM
-typedef struct
- {
- /* Stack pointer. */
- void *__sp;
-
- /* Link pointer. */
- void *__lp;
-
- /* Callee-saved registers r2 and r20-r29. */
- int __regs[11];
- } __jmp_buf[1];
-#endif
-
-#define JB_SIZE (4 * 13)
-
-/* Test if longjmp to JMPBUF would unwind the frame
- containing a local variable at ADDRESS. */
-#define _JMPBUF_UNWINDS(jmpbuf, address) \
- ((void *) (address) < (void *) (jmpbuf)[0].__sp)
-
-#endif /* bits/setjmp.h */
diff --git a/libc/sysdeps/linux/v850/bits/sigcontextinfo.h b/libc/sysdeps/linux/v850/bits/sigcontextinfo.h
deleted file mode 100644
index de450ff8a..000000000
--- a/libc/sysdeps/linux/v850/bits/sigcontextinfo.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * sysdeps/v850/sigcontextinfo.h -- v850-specific pthread signal definitions
- *
- * Copyright (C) 2002 NEC Electronics Corporation
- * Copyright (C) 2002 Miles Bader <miles@gnu.org>
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- *
- * Written by Miles Bader <miles@gnu.org>
- */
-
-#include <signal.h>
-
-#define SIGCONTEXT struct sigcontext *
-#define SIGCONTEXT_EXTRA_ARGS
diff --git a/libc/sysdeps/linux/v850/bits/stackinfo.h b/libc/sysdeps/linux/v850/bits/stackinfo.h
deleted file mode 100644
index 3ed732aac..000000000
--- a/libc/sysdeps/linux/v850/bits/stackinfo.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * bits/stackinfo.h -- v850-specific pthread definitions
- *
- * Copyright (C) 2003 NEC Electronics Corporation
- * Copyright (C) 2003 Miles Bader <miles@gnu.org>
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- *
- * Written by Miles Bader <miles@gnu.org>
- */
-
-/* This file contains a bit of information about the stack allocation
- of the processor. */
-
-#ifndef _STACKINFO_H
-#define _STACKINFO_H 1
-
-/* On v80 the stack grows down. */
-#define _STACK_GROWS_DOWN 1
-
-#endif /* stackinfo.h */
diff --git a/libc/sysdeps/linux/v850/bits/syscalls.h b/libc/sysdeps/linux/v850/bits/syscalls.h
deleted file mode 100644
index b21851333..000000000
--- a/libc/sysdeps/linux/v850/bits/syscalls.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef _BITS_SYSCALLS_H
-#define _BITS_SYSCALLS_H
-#ifndef _SYSCALL_H
-# error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
-#endif
-
-#include <features.h>
-
-/* Do something very evil for now. Until we create our own syscall
- * macros, short circuit bits/sysnum.h and use asm/unistd.h instead */
-#warning "fixme -- add arch specific syscall macros.h"
-#include <asm/unistd.h>
-
-#endif /* _BITS_SYSCALLS_H */
-
diff --git a/libc/sysdeps/linux/v850/clinkage.h b/libc/sysdeps/linux/v850/clinkage.h
deleted file mode 100644
index e85d39fb8..000000000
--- a/libc/sysdeps/linux/v850/clinkage.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * libc/sysdeps/linux/v850/clinkage.h -- Macros for C symbols in assembler
- *
- * Copyright (C) 2001 NEC Corporation
- * Copyright (C) 2001 Miles Bader <miles@gnu.org>
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- *
- * Written by Miles Bader <miles@gnu.org>
- */
-
-#include <asm/clinkage.h>
diff --git a/libc/sysdeps/linux/v850/clone.c b/libc/sysdeps/linux/v850/clone.c
deleted file mode 100644
index d2e220823..000000000
--- a/libc/sysdeps/linux/v850/clone.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * libc/sysdeps/linux/v850/clone.c -- `clone' syscall for linux/v850
- *
- * Copyright (C) 2002,03 NEC Electronics Corporation
- * Copyright (C) 2002,03 Miles Bader <miles@gnu.org>
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- *
- * Written by Miles Bader <miles@gnu.org>
- */
-
-#include <errno.h>
-#include <sys/syscall.h>
-
-int
-clone (int (*fn)(void *arg), void *child_stack, int flags, void *arg)
-{
- register unsigned long rval __asm__ (SYSCALL_RET) = -EINVAL;
-
- if (fn && child_stack)
- {
- register unsigned long syscall __asm__ (SYSCALL_NUM);
- register unsigned long arg0 __asm__ (SYSCALL_ARG0);
- register unsigned long arg1 __asm__ (SYSCALL_ARG1);
-
- /* Clone this thread. */
- arg0 = flags;
- arg1 = (unsigned long)child_stack;
- syscall = __NR_clone;
- __asm__ __volatile__ ("trap " SYSCALL_SHORT_TRAP
- : "=r" (rval), "=r" (syscall)
- : "1" (syscall), "r" (arg0), "r" (arg1)
- : SYSCALL_SHORT_CLOBBERS);
-
- if (rval == 0)
- /* In child thread, call FN and exit. */
- {
- arg0 = (*fn) (arg);
- syscall = __NR_exit;
- __asm__ __volatile__ ("trap " SYSCALL_SHORT_TRAP
- : "=r" (rval), "=r" (syscall)
- : "1" (syscall), "r" (arg0)
- : SYSCALL_SHORT_CLOBBERS);
- }
- }
-
- __syscall_return (int, rval);
-}
diff --git a/libc/sysdeps/linux/v850/crt0.S b/libc/sysdeps/linux/v850/crt0.S
deleted file mode 100644
index 11d7bb5aa..000000000
--- a/libc/sysdeps/linux/v850/crt0.S
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * libc/sysdeps/linux/v850/crt0.S -- Initial program entry point for linux/v850
- *
- * Copyright (C) 2001,02,03 NEC Electronics Corporation
- * Copyright (C) 2001,02,03 Miles Bader <miles@gnu.org>
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- *
- * Written by Miles Bader <miles@gnu.org>
- */
-
-#include <clinkage.h>
-
-/* Upon entry, the stack contains the following data:
- argc, argv[0], ..., argv[argc-1], 0, envp[0], ..., 0
-*/
-
- .text
-C_ENTRY(start):
- ld.w 0[sp], r6 // Arg 0: argc
-
- addi 4, sp, r7 // Arg 1: argv
-
- mov r7, r8 // Arg 2: envp
- mov r6, r10 // skip argc elements to get envp start
- add 1, r10 // ...plus the NULL at the end of argv
- shl 2, r10 // Convert to byte-count to skip
- add r10, r8
-
- // Load CTBP register
- mov hilo(C_SYMBOL_NAME(_ctbp)), r19
- ldsr r19, ctbp
-
- // Load GP
- mov hilo(C_SYMBOL_NAME(_gp)), gp
-
- // tail-call uclibc's startup routine
- addi -24, sp, sp // Stack space reserved for args
- jr C_SYMBOL_NAME(__uClibc_main)
-
-
-/* Stick in a dummy reference to `main', so that if an application
- is linking when the `main' function is in a static library (.a)
- we can be sure that `main' actually gets linked in. */
-L_dummy_main_reference:
- .long C_SYMBOL_NAME(main)
-
-/* Define a symbol for the first piece of initialized data. */
- .data
- .globl __data_start
-__data_start:
- .long 0
- .weak data_start
- data_start = __data_start
-
diff --git a/libc/sysdeps/linux/v850/crti.S b/libc/sysdeps/linux/v850/crti.S
deleted file mode 100644
index c1e529390..000000000
--- a/libc/sysdeps/linux/v850/crti.S
+++ /dev/null
@@ -1,27 +0,0 @@
- .file "initfini.c"
-#APP
-
- .section .init
-#NO_APP
- .align 1
- .global __init
- .type __init, @function
-__init:
- jarl __save_r31, r10
-#APP
-
- .align 1
-
-
- .section .fini
-#NO_APP
- .align 1
- .global __fini
- .type __fini, @function
-__fini:
- jarl __save_r31, r10
-#APP
- .align 1
-
-
- .ident "GCC: (GNU) 3.3.2"
diff --git a/libc/sysdeps/linux/v850/crtn.S b/libc/sysdeps/linux/v850/crtn.S
deleted file mode 100644
index aecb55737..000000000
--- a/libc/sysdeps/linux/v850/crtn.S
+++ /dev/null
@@ -1,24 +0,0 @@
- .file "initfini.c"
-#APP
-
- .section .init
-#NO_APP
- .align 1
- .global __init
- .type __init, @function
-#NO_APP
- jr __return_r31
- .size __init, .-__init
-#APP
-
- .section .fini
-#NO_APP
- .align 1
- .global __fini
- .type __fini, @function
-#NO_APP
- jr __return_r31
- .size __fini, .-__fini
-#APP
-
- .ident "GCC: (GNU) 3.3.2"
diff --git a/libc/sysdeps/linux/v850/mmap.c b/libc/sysdeps/linux/v850/mmap.c
deleted file mode 100644
index 72fb37dd2..000000000
--- a/libc/sysdeps/linux/v850/mmap.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Use new style mmap for v850 */
-/*
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-#include <unistd.h>
-#include <errno.h>
-#include <sys/mman.h>
-#include <sys/syscall.h>
-
-libc_hidden_proto(mmap)
-
-_syscall6 (__ptr_t, mmap, __ptr_t, addr, size_t, len, int, prot,
- int, flags, int, fd, __off_t, offset);
-libc_hidden_def(mmap)
diff --git a/libc/sysdeps/linux/v850/setjmp.S b/libc/sysdeps/linux/v850/setjmp.S
deleted file mode 100644
index 87a5e3833..000000000
--- a/libc/sysdeps/linux/v850/setjmp.S
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * libc/sysdeps/linux/v850/setjmp.S -- `setjmp' for v850
- *
- * Copyright (C) 2001,2002 NEC Corporation
- * Copyright (C) 2001,2002 Miles Bader <miles@gnu.org>
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- *
- * Written by Miles Bader <miles@gnu.org>
- */
-
-#define _SETJMP_H
-#define _ASM
-#include <bits/setjmp.h>
-
-#include <clinkage.h>
-
- .text
-C_ENTRY(setjmp):
- mov 1, r7 /* Save the signal mask. */
- br C_SYMBOL_NAME(__sigsetjmp)
-
- .globl C_SYMBOL_NAME(_setjmp)
-C_SYMBOL_NAME(_setjmp):
- mov 0, r7 /* Don't save the signal mask. */
-
- .globl C_SYMBOL_NAME(__sigsetjmp)
-C_SYMBOL_NAME(__sigsetjmp):
- /* Save registers */
- mov r6, ep
- sst.w sp, 0[ep]
- sst.w lp, 4[ep]
- sst.w r2, 8[ep]
- sst.w r20, 12[ep]
- sst.w r21, 16[ep]
- sst.w r22, 20[ep]
- sst.w r23, 24[ep]
- sst.w r24, 28[ep]
- sst.w r25, 32[ep]
- sst.w r26, 36[ep]
- sst.w r27, 40[ep]
- sst.w r28, 44[ep]
- sst.w r29, 48[ep]
- /* Make a tail call to __sigjmp_save; it takes the same args. */
- jr C_SYMBOL_NAME(__sigjmp_save)
-C_END(setjmp)
diff --git a/libc/sysdeps/linux/v850/sys/ptrace.h b/libc/sysdeps/linux/v850/sys/ptrace.h
deleted file mode 100644
index 48690eeee..000000000
--- a/libc/sysdeps/linux/v850/sys/ptrace.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* `ptrace' debugger support interface. Linux/v850 version.
- Copyright (C) 2001, 2002, 2003 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. */
- PTRACE_SINGLESTEP = 9,
-#define PT_STEP PTRACE_SINGLESTEP
-
- /* 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
-
- /* Continue and stop at the next (return from) syscall. */
- PTRACE_SYSCALL = 24
-#define PT_SYSCALL PTRACE_SYSCALL
-};
-
-/* 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/v850/syscall.c b/libc/sysdeps/linux/v850/syscall.c
deleted file mode 100644
index dbcc87cec..000000000
--- a/libc/sysdeps/linux/v850/syscall.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * libc/sysdeps/linux/v850/syscall.c -- generic syscall function for linux/v850
- *
- * Copyright (C) 2002 NEC Corporation
- * Copyright (C) 2002 Miles Bader <miles@gnu.org>
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- *
- * Written by Miles Bader <miles@gnu.org>
- */
-
-#include <errno.h>
-#include <sys/syscall.h>
-
-typedef unsigned long arg_t;
-
-/* Invoke `system call' NUM, passing it the remaining arguments.
- This is completely system-dependent, and not often useful. */
-long
-syscall (long num, arg_t a1, arg_t a2, arg_t a3, arg_t a4, arg_t a5, arg_t a6)
-{
- /* We don't know how many arguments are valid, so A5 and A6 are fetched
- off the stack even for (the majority of) system calls with fewer
- arguments; hopefully this won't cause any problems. A1-A4 are in
- registers, so they're OK. */
- register arg_t a __asm__ (SYSCALL_ARG0) = a1;
- register arg_t b __asm__ (SYSCALL_ARG1) = a2;
- register arg_t c __asm__ (SYSCALL_ARG2) = a3;
- register arg_t d __asm__ (SYSCALL_ARG3) = a4;
- register arg_t e __asm__ (SYSCALL_ARG4) = a5;
- register arg_t f __asm__ (SYSCALL_ARG5) = a6;
- register unsigned long syscall __asm__ (SYSCALL_NUM) = num;
- register unsigned long ret __asm__ (SYSCALL_RET);
-
- __asm__ ("trap " SYSCALL_LONG_TRAP
- : "=r" (ret)
- : "r" (syscall), "r" (a), "r" (b), "r" (c), "r" (d), "r" (e), "r" (f)
- : SYSCALL_CLOBBERS);
-
- __syscall_return (long, ret);
-}
diff --git a/libc/sysdeps/linux/v850/vfork.S b/libc/sysdeps/linux/v850/vfork.S
deleted file mode 100644
index 82d127079..000000000
--- a/libc/sysdeps/linux/v850/vfork.S
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * libc/sysdeps/linux/v850/vfork.S -- `vfork' syscall for linux/v850
- *
- * Copyright (C) 2001,2002 NEC Corporation
- * Copyright (C) 2001,2002 Miles Bader <miles@gnu.org>
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- *
- * Written by Miles Bader <miles@gnu.org>
- */
-
-#include <features.h>
-#define _ERRNO_H 1
-#include <bits/errno.h>
-#define _SYSCALL_H
-#include <bits/sysnum.h>
-
-#include <clinkage.h>
-
-/* Clone the calling process, but without copying the whole address space.
- The calling process is suspended until the new process exits or is
- replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
- and the process ID of the new process to the old process. */
-
-.global C_SYMBOL_NAME(errno)
-
-C_ENTRY (__vfork):
- addi SYS_vfork, r0, r12
- trap 0
- addi -125, r0, r11 // minimum err value
- cmp r11, r10
- bh 1f
- jmp [lp] // normal return
-1: mov hilo(C_SYMBOL_NAME(errno)), r11
- subr r0, r10
- st.w r10, 0[r11]
- jmp [lp] // error return
-C_END(__vfork)
-weak_alias(__vfork,vfork)
-libc_hidden_weak(vfork)
diff --git a/libc/sysdeps/linux/vax/Makefile.arch b/libc/sysdeps/linux/vax/Makefile.arch
deleted file mode 100644
index ea8672c7d..000000000
--- a/libc/sysdeps/linux/vax/Makefile.arch
+++ /dev/null
@@ -1,12 +0,0 @@
-# Makefile for uClibc
-#
-# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
-# Copyright (C) 2005-2006 Jan-Benedict Glaw <jbglaw@lug-owl.de>
-#
-# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-#
-
-CSRC := brk.c mmap.c
-SSRC := __longjmp.S setjmp.S _setjmp.S clone.S
-
-include $(top_srcdir)libc/sysdeps/linux/Makefile.commonarch
diff --git a/libc/sysdeps/linux/vax/__longjmp.S b/libc/sysdeps/linux/vax/__longjmp.S
deleted file mode 100644
index 61b37a3b9..000000000
--- a/libc/sysdeps/linux/vax/__longjmp.S
+++ /dev/null
@@ -1,47 +0,0 @@
-#include <features.h>
-
-/*
- * longjmp.S atp sept 2001
- * Jan-Benedict Glaw <jbglaw@lug-owl.de> 2006
- *
- * Restore regs and info and jmp back to a previous setjmp
- */
-
-.globl __longjmp
-.align 4
-__longjmp:
- .word 0x0040 /* This matches setjmp and PLT */
- movl 0x4(%ap), %r0 /* Our scratch reg */
-/* movl $0, %r0 */
-/* movl (%r0), %r0 */
- /* We are going to modify our stack frame */
- /* to the same as that of the setjmp we called earlier */
- movl (%r0), (%fp) /* cond handler */
- movl 0x4(%r0), 0x4(%fp) /* psw */
- movl 0x8(%r0), 0x8(%fp) /* ap */
- movl 0xc(%r0), 0xc(%fp) /* fp */
- movl 0x10(%r0), 0x10(%fp) /* pc */
-
- /* Restore the regs */
- movl 0x14(%r0), %r1
- movl 0x18(%r0), %r2
- movl 0x1c(%r0), %r3
- movl 0x20(%r0), %r4
- movl 0x24(%r0), %r5
- movl 0x28(%r0), %r6
- movl 0x2c(%r0), %r7
- movl 0x30(%r0), %r8
- movl 0x34(%r0), %r9
- movl 0x38(%r0), %r10
- movl 0x3c(%r0), %r11
-
- /* Check val and set to 1 if set to zero */
- movl 0x8(%ap), %r0
- tstl %r0
- bneq exit_ok
- movl $0x1, %r0
-exit_ok:
- ret
-.size __longjmp,.-__longjmp
-libc_hidden_def(__longjmp)
-
diff --git a/libc/sysdeps/linux/vax/_setjmp.S b/libc/sysdeps/linux/vax/_setjmp.S
deleted file mode 100644
index 680ddd729..000000000
--- a/libc/sysdeps/linux/vax/_setjmp.S
+++ /dev/null
@@ -1,53 +0,0 @@
-.globl _setjmp
-.align 4
-_setjmp:
- .word 0x0040
-
- /* push an empty word onto the stack */
- pushl $0
-
- /* now copy handler, psw, ap, fp and pc on the stack up one word */
- movl 4(%sp), (%sp) /* copy handler */
- movl 8(%sp), 4(%sp) /* psw */
- movl 12(%sp), 8(%sp) /* ap */
- movl 16(%sp), 12(%sp) /* fp */
- movl 20(%sp), 16(%sp) /* pc */
- movl 24(%sp), 20(%sp) /* r6 from register mask */
-
- movl $2, 24(%sp) /* set the number of arguments to 2 */
- movl 32(%sp), 28(%sp) /* copy the jmp_buf */
- movl $1, 32(%sp) /* put the 1 on the stack */
-
- addl3 $24, %sp, %ap
- movl %sp, %fp
-
- moval __sigsetjmp, %r0
- addl2 $2, %r0
- pushl %r0
- rsb
-
-.globl setjmp
-.align 4
-setjmp:
- .word 0x0040
- pushl $0
-
- /* now copy handler, psw, ap, fp and pc on the stack up one word */
- movl 4(%sp), (%sp)
- movl 8(%sp), 4(%sp)
- movl 12(%sp), 8(%sp)
- movl 16(%sp), 12(%sp)
- movl 20(%sp), 16(%sp)
- movl 24(%sp), 20(%sp) /* r6 from register mask */
-
- movl $2, 24(%sp) /* set the number of arguments to 2 */
- movl 32(%sp), 28(%sp) /* copy the jmp_buf */
- movl $0, 32(%sp) /* put the 0 on the stack */
-
- addl3 $24, %sp, %ap
- movl %sp, %fp
-
- moval __sigsetjmp, %r0
- addl2 $2, %r0
- pushl %r0
- rsb
diff --git a/libc/sysdeps/linux/vax/bits/byteswap.h b/libc/sysdeps/linux/vax/bits/byteswap.h
deleted file mode 100644
index 6b5115658..000000000
--- a/libc/sysdeps/linux/vax/bits/byteswap.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/* Macros to swap the order of bytes in integer values.
- Copyright (C) 1997, 1998 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. */
-
-#if !defined _BYTESWAP_H && !defined _NETINET_IN_H
-# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
-#endif
-
-/* Swap bytes in 16 bit value. */
-#ifdef __GNUC__
-# define __bswap_16(x) \
- (__extension__ \
- ({ unsigned short int __bsx = (x); \
- ((((__bsx) >> 8) & 0xff) | (((__bsx) & 0xff) << 8)); }))
-#else
-static __inline unsigned short int
-__bswap_16 (unsigned short int __bsx)
-{
- return ((((__bsx) >> 8) & 0xff) | (((__bsx) & 0xff) << 8));
-}
-#endif
-
-/* Swap bytes in 32 bit value. */
-#ifdef __GNUC__
-# define __bswap_32(x) \
- (__extension__ \
- ({ unsigned int __bsx = (x); \
- ((((__bsx) & 0xff000000) >> 24) | (((__bsx) & 0x00ff0000) >> 8) | \
- (((__bsx) & 0x0000ff00) << 8) | (((__bsx) & 0x000000ff) << 24)); }))
-#else
-static __inline unsigned int
-__bswap_32 (unsigned int __bsx)
-{
- return ((((__bsx) & 0xff000000) >> 24) | (((__bsx) & 0x00ff0000) >> 8) |
- (((__bsx) & 0x0000ff00) << 8) | (((__bsx) & 0x000000ff) << 24));
-}
-#endif
-
-#if defined __GNUC__ && __GNUC__ >= 2
-/* Swap bytes in 64 bit value. */
-# define __bswap_64(x) \
- (__extension__ \
- ({ union { unsigned long long int __ll; \
- unsigned long int __l[2]; } __v, __r; \
- __v.__ll = (x); \
- __r.__l[0] = __bswap_32 (__v.__l[1]); \
- __r.__l[1] = __bswap_32 (__v.__l[0]); \
- __r.__ll; }))
-#endif
diff --git a/libc/sysdeps/linux/vax/bits/fcntl.h b/libc/sysdeps/linux/vax/bits/fcntl.h
deleted file mode 100644
index 971245da5..000000000
--- a/libc/sysdeps/linux/vax/bits/fcntl.h
+++ /dev/null
@@ -1,214 +0,0 @@
-/* O_*, F_*, FD_* bit values for Linux.
- Copyright (C) 1995, 1996, 1997, 1998 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. */
-
-#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
-
-#ifdef __USE_GNU
-# define O_DIRECTORY 040000 /* Must be a directory. */
-# define O_NOFOLLOW 0100000 /* Do not follow links. */
-#endif
-
-/* XXX missing */
-#ifdef __USE_LARGEFILE64
-# define O_LARGEFILE 0
-#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
-
-/* 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. */
-#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). */
-
-/* XXX missing */
-#define F_GETLK64 5 /* Get record locking info. */
-#define F_SETLK64 6 /* Set record locking info (non-blocking). */
-#define F_SETLKW64 7 /* Set record locking info (blocking). */
-
-#ifdef __USE_BSD
-# 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. */
-# define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with
- close-on-exit set on new fd. */
-#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
-
-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
-
-
-#ifdef __USE_GNU
-/* 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
-
-#ifdef __USE_GNU
-
-/* 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/vax/bits/kernel_stat.h b/libc/sysdeps/linux/vax/bits/kernel_stat.h
deleted file mode 100644
index 2b5cb28f2..000000000
--- a/libc/sysdeps/linux/vax/bits/kernel_stat.h
+++ /dev/null
@@ -1,60 +0,0 @@
-#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... */
-
-struct kernel_stat {
- unsigned short st_dev;
- unsigned short __pad1;
- unsigned long st_ino;
- unsigned short st_mode;
- unsigned short st_nlink;
- unsigned short st_uid;
- unsigned short st_gid;
- unsigned short st_rdev;
- unsigned short __pad2;
- unsigned long st_size;
- unsigned long st_blksize;
- unsigned long st_blocks;
- unsigned long st_atime;
- unsigned long __unused1;
- unsigned long st_mtime;
- unsigned long __unused2;
- unsigned long st_ctime;
- unsigned long __unused3;
- unsigned long __unused4;
- unsigned long __unused5;
-};
-
-struct kernel_stat64 {
- unsigned short st_dev;
- unsigned char __pad0[10];
-#define _HAVE_STAT64___ST_INO 1
- unsigned long __st_ino;
- unsigned int st_mode;
- unsigned int st_nlink;
- unsigned long st_uid;
- unsigned long st_gid;
- unsigned short st_rdev;
- unsigned char __pad3[10];
- long long st_size;
- unsigned long st_blksize;
- unsigned long st_blocks; /* Number 512-byte blocks allocated. */
- unsigned long __pad4; /* future possible st_blocks high bits */
- unsigned long st_atime;
- unsigned long __pad5;
- unsigned long st_mtime;
- unsigned long __pad6;
- unsigned long st_ctime;
- unsigned long __pad7; /* will be high 32 bits of ctime someday */
- unsigned long long st_ino;
-};
-
-#endif /* _BITS_STAT_STRUCT_H */
-
diff --git a/libc/sysdeps/linux/vax/bits/kernel_types.h b/libc/sysdeps/linux/vax/bits/kernel_types.h
deleted file mode 100644
index aef74b549..000000000
--- a/libc/sysdeps/linux/vax/bits/kernel_types.h
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifndef _VAX_POSIX_TYPES_H
-#define _VAX_POSIX_TYPES_H
-/*
- * 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
- */
-
-
-typedef unsigned short __kernel_dev_t;
-typedef unsigned long __kernel_ino_t;
-typedef unsigned short __kernel_mode_t;
-typedef unsigned short __kernel_nlink_t;
-typedef long __kernel_off_t;
-typedef int __kernel_pid_t;
-typedef unsigned short __kernel_ipc_pid_t;
-typedef unsigned short __kernel_uid_t;
-typedef unsigned short __kernel_gid_t;
-typedef unsigned int __kernel_size_t;
-typedef int __kernel_ssize_t;
-typedef int __kernel_ptrdiff_t;
-typedef long __kernel_time_t;
-typedef long __kernel_suseconds_t;
-typedef long __kernel_clock_t;
-typedef int __kernel_daddr_t;
-typedef char * __kernel_caddr_t;
-typedef unsigned short __kernel_uid16_t;
-typedef unsigned short __kernel_gid16_t;
-typedef unsigned int __kernel_uid32_t;
-typedef unsigned int __kernel_gid32_t;
-typedef unsigned short __kernel_old_uid_t;
-typedef unsigned short __kernel_old_gid_t;
-typedef long long __kernel_loff_t;
-
-typedef struct {
-#if defined(__KERNEL__) || defined(__USE_ALL)
- int val[2];
-#else
- int __val[2];
-#endif
-} __kernel_fsid_t;
-
-#endif /* _VAX_POSIX_TYPES_H */
diff --git a/libc/sysdeps/linux/vax/bits/machine-gmon.h b/libc/sysdeps/linux/vax/bits/machine-gmon.h
deleted file mode 100644
index 841518f06..000000000
--- a/libc/sysdeps/linux/vax/bits/machine-gmon.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* i386-specific implementation of profiling support.
- Copyright (C) 1997, 2002 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
- 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 <sysdep.h>
-
-/* We need a special version of the `mcount' function since for ix86 it
- must not clobber any register. This has several reasons:
- - there is a bug in gcc as of version 2.7.2.2 which prohibits the
- use of profiling together with nested functions
- - the ELF `fixup' function uses GCC's regparm feature
- - some (future) systems might want to pass parameters in registers. */
-
-/* We must not pollute the global namespace. */
-#define mcount_internal __mcount_internal
-
-extern void mcount_internal (u_long frompc, u_long selfpc);
-
-#define _MCOUNT_DECL(frompc, selfpc) \
-void __attribute__ (( regparm (2) )) mcount_internal (u_long frompc, u_long selfpc)
-
-
-/* Define MCOUNT as empty since we have the implementation in another
- file. */
-#define MCOUNT
diff --git a/libc/sysdeps/linux/vax/bits/mman.h b/libc/sysdeps/linux/vax/bits/mman.h
deleted file mode 100644
index e29dfcc61..000000000
--- a/libc/sysdeps/linux/vax/bits/mman.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* Definitions for POSIX memory map interface. Linux/i386 version.
- Copyright (C) 1997, 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 _SYS_MMAN_H
-# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
-#endif
-
-/* The following definitions basically come from the kernel headers.
- But the kernel header is not namespace clean. */
-
-
-/* Protections are chosen from these bits, OR'd together. The
- implementation does not necessarily support PROT_EXEC or PROT_WRITE
- without PROT_READ. The only guarantees are that no writing will be
- allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
-
-#define PROT_READ 0x1 /* Page can be read. */
-#define PROT_WRITE 0x2 /* Page can be written. */
-#define PROT_EXEC 0x4 /* Page can be executed. */
-#define PROT_NONE 0x0 /* Page can not be accessed. */
-
-/* Sharing types (must choose one and only one of these). */
-#define MAP_SHARED 0x01 /* Share changes. */
-#define MAP_PRIVATE 0x02 /* Changes are private. */
-#ifdef __USE_MISC
-# define MAP_TYPE 0x0f /* Mask for type of mapping. */
-#endif
-
-/* Other flags. */
-#define MAP_FIXED 0x10 /* Interpret addr exactly. */
-#ifdef __USE_MISC
-# define MAP_FILE 0
-# define MAP_ANONYMOUS 0x20 /* Don't use a file. */
-# define MAP_ANON MAP_ANONYMOUS
-#endif
-
-/* These are Linux-specific. */
-#ifdef __USE_MISC
-# define MAP_GROWSDOWN 0x0100 /* Stack-like segment. */
-# define MAP_DENYWRITE 0x0800 /* ETXTBSY */
-# define MAP_EXECUTABLE 0x1000 /* Mark it as an executable. */
-# define MAP_LOCKED 0x2000 /* Lock the mapping. */
-# define MAP_NORESERVE 0x4000 /* Don't check for reservations. */
-#endif
-
-/* Flags to `msync'. */
-#define MS_ASYNC 1 /* Sync memory asynchronously. */
-#define MS_SYNC 4 /* Synchronous memory sync. */
-#define MS_INVALIDATE 2 /* Invalidate the caches. */
-
-/* Flags for `mlockall'. */
-#define MCL_CURRENT 1 /* Lock all currently mapped pages. */
-#define MCL_FUTURE 2 /* Lock all additions to address
- space. */
-
-/* Flags for `mremap'. */
-#ifdef __USE_GNU
-# define MREMAP_MAYMOVE 1 /* Mapping address may change. */
-# define MREMAP_FIXED 2 /* Fifth argument sets new address. */
-#endif
-
-/* Advice to `madvise'. */
-#ifdef __USE_BSD
-# define MADV_NORMAL 0 /* No further special treatment. */
-# define MADV_RANDOM 1 /* Expect random page references. */
-# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
-# define MADV_WILLNEED 3 /* Will need these pages. */
-# define MADV_DONTNEED 4 /* Don't need these pages. */
-#endif
-
-/* The POSIX people had to invent similar names for the same things. */
-#ifdef __USE_XOPEN2K
-# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
-# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
-# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
-# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
-# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
-#endif
diff --git a/libc/sysdeps/linux/vax/bits/sem.h b/libc/sysdeps/linux/vax/bits/sem.h
deleted file mode 100644
index c5c04bad1..000000000
--- a/libc/sysdeps/linux/vax/bits/sem.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/* Copyright (C) 1995, 1996, 1997, 1998, 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. */
-
-#ifndef _SYS_SEM_H
-# error "Never include <bits/sem.h> directly; use <sys/sem.h> instead."
-#endif
-
-#include <sys/types.h>
-
-/* Flags for `semop'. */
-#define SEM_UNDO 0x1000 /* undo the operation on exit */
-
-/* Commands for `semctl'. */
-#define GETPID 11 /* get sempid */
-#define GETVAL 12 /* get semval */
-#define GETALL 13 /* get all semval's */
-#define GETNCNT 14 /* get semncnt */
-#define GETZCNT 15 /* get semzcnt */
-#define SETVAL 16 /* set semval */
-#define SETALL 17 /* set all semval's */
-
-
-/* Data structure describing a set of semaphores. */
-struct semid_ds
-{
- struct ipc_perm sem_perm; /* operation permission struct */
- __time_t sem_otime; /* last semop() time */
- unsigned long int __unused1;
- __time_t sem_ctime; /* last time changed by semctl() */
- unsigned long int __unused2;
- unsigned long int sem_nsems; /* number of semaphores in set */
- unsigned long int __unused3;
- unsigned long int __unused4;
-};
-
-/* The user should define a union like the following to use it for arguments
- for `semctl'.
-
- union semun
- {
- int val; <= value for SETVAL
- struct semid_ds *buf; <= buffer for IPC_STAT & IPC_SET
- unsigned short int *array; <= array for GETALL & SETALL
- struct seminfo *__buf; <= buffer for IPC_INFO
- };
-
- Previous versions of this file used to define this union but this is
- incorrect. One can test the macro _SEM_SEMUN_UNDEFINED to see whether
- one must define the union or not. */
-#define _SEM_SEMUN_UNDEFINED 1
-
-#ifdef __USE_MISC
-
-/* ipcs ctl cmds */
-# define SEM_STAT 18
-# define SEM_INFO 19
-
-struct seminfo
-{
- int semmap;
- int semmni;
- int semmns;
- int semmnu;
- int semmsl;
- int semopm;
- int semume;
- int semusz;
- int semvmx;
- int semaem;
-};
-
-#endif /* __USE_MISC */
diff --git a/libc/sysdeps/linux/vax/bits/setjmp.h b/libc/sysdeps/linux/vax/bits/setjmp.h
deleted file mode 100644
index 68a1b32ba..000000000
--- a/libc/sysdeps/linux/vax/bits/setjmp.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Define the machine-dependent type `jmp_buf'. Vax version. */
-
-#ifndef _SETJMP_H
-# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
-#endif
-
-/* we want to save enough that we can use this to fool RET,
- * So we basically save all of the CALLS stack frame. Plus regs. */
-#ifndef _ASM
-typedef int __jmp_buf[16];
-#endif
-
-/* Test if longjmp to JMPBUF would unwind the frame
- containing a local variable at ADDRESS. */
-#define _JMPBUF_UNWINDS(jmpbuf, address) \
- ((void *) (address) < (void *) (jmpbuf[4]))
-/*
- jmp_buf layout. jmp_buf[0]
- void *__cond; The condition handler
- void *__psw; mask and PSW bits
- void *__ap; argument pointer
- void *__fp; frame pointer
- void *__pc; program counter
- no need to save r0
- void *__r1; regs, r0->r11.
- void *__r2; regs, r0->r11.
- void *__r3; regs, r0->r11.
- void *__r4; regs, r0->r11.
- void *__r5; regs, r0->r11.
- void *__r6; regs, r0->r11.
- void *__r7; regs, r0->r11.
- void *__r8; regs, r0->r11.
- void *__r9; regs, r0->r11.
- void *__rA; regs, r0->r11.
- void *__rB; regs, r0->r11.
-*/
-
diff --git a/libc/sysdeps/linux/vax/bits/shm.h b/libc/sysdeps/linux/vax/bits/shm.h
deleted file mode 100644
index 191709f0e..000000000
--- a/libc/sysdeps/linux/vax/bits/shm.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* Copyright (C) 1995, 1996, 1997 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. */
-
-#ifndef _SYS_SHM_H
-# error "Never include <bits/shm.h> directly; use <sys/shm.h> instead."
-#endif
-
-#include <sys/types.h>
-
-/* Permission flag for shmget. */
-#define SHM_R 0400 /* or S_IRUGO from <linux/stat.h> */
-#define SHM_W 0200 /* or S_IWUGO from <linux/stat.h> */
-
-/* Flags for `shmat'. */
-#define SHM_RDONLY 010000 /* attach read-only else read-write */
-#define SHM_RND 020000 /* round attach address to SHMLBA */
-#define SHM_REMAP 040000 /* take-over region on attach */
-
-/* Commands for `shmctl'. */
-#define SHM_LOCK 11 /* lock segment (root only) */
-#define SHM_UNLOCK 12 /* unlock segment (root only) */
-
-__BEGIN_DECLS
-/* Segment low boundary address multiple. */
-#define SHMLBA (__getpagesize ())
-extern int __getpagesize (void) __THROW __attribute__ ((__const__));
-
-/* Data structure describing a set of semaphores. */
-struct shmid_ds
- {
- struct ipc_perm shm_perm; /* operation permission struct */
- int shm_segsz; /* size of segment in bytes */
- __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 */
- 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 */
- };
-
-#ifdef __USE_MISC
-
-/* ipcs ctl commands */
-# define SHM_STAT 13
-# define SHM_INFO 14
-
-/* shm_mode upper byte flags */
-# define SHM_DEST 01000 /* segment will be destroyed on last detach */
-# define SHM_LOCKED 02000 /* segment will not be swapped */
-
-struct shminfo
- {
- int shmmax;
- int shmmin;
- int shmmni;
- int shmseg;
- int shmall;
- };
-
-struct shm_info
- {
- int used_ids;
- unsigned long int shm_tot; /* total allocated shm */
- unsigned long int shm_rss; /* total resident shm */
- unsigned long int shm_swp; /* total swapped shm */
- unsigned long int swap_attempts;
- unsigned long int swap_successes;
- };
-
-#endif /* __USE_MISC */
diff --git a/libc/sysdeps/linux/vax/bits/sigcontext.h b/libc/sysdeps/linux/vax/bits/sigcontext.h
deleted file mode 100644
index 97cbf4b30..000000000
--- a/libc/sysdeps/linux/vax/bits/sigcontext.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Copyright (C) 1996, 1997, 1998 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. */
-
-#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H
-# error "Never use <bits/sigcontext.h> directly; include <signal.h> instead."
-#endif
-
-#ifndef sigcontext_struct
-/* Kernel headers before 2.1.1 define a struct sigcontext_struct, but
- we need sigcontext. */
-# define sigcontext_struct sigcontext
-
-# include <asm/sigcontext.h>
-#endif
diff --git a/libc/sysdeps/linux/vax/bits/stackinfo.h b/libc/sysdeps/linux/vax/bits/stackinfo.h
deleted file mode 100644
index 4bdad496e..000000000
--- a/libc/sysdeps/linux/vax/bits/stackinfo.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef _VAX_BITS_STACKINFO_H
-#define _VAX_BITS_STACKINFO_H
-
-/* On VAXen, the stack grows down. */
-#define _STACK_GROWS_DOWN 1
-
-#endif /* _VAX_BITS_STACKINFO_H */
diff --git a/libc/sysdeps/linux/vax/bits/statfs.h b/libc/sysdeps/linux/vax/bits/statfs.h
deleted file mode 100644
index 31ae564b4..000000000
--- a/libc/sysdeps/linux/vax/bits/statfs.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* Copyright (C) 1997, 1998 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. */
-
-#ifndef _SYS_STATFS_H
-# error "Never include <bits/statfs.h> directly; use <sys/statfs.h> instead."
-#endif
-
-#include <bits/types.h> /* for __fsid_t and __fsblkcnt_t*/
-
-struct statfs
- {
- int f_type;
- int f_bsize;
-#ifndef __USE_FILE_OFFSET64
- __fsblkcnt_t f_blocks;
- __fsblkcnt_t f_bfree;
- __fsblkcnt_t f_bavail;
- __fsfilcnt_t f_files;
- __fsfilcnt_t f_ffree;
-#else
- __fsblkcnt64_t f_blocks;
- __fsblkcnt64_t f_bfree;
- __fsblkcnt64_t f_bavail;
- __fsfilcnt64_t f_files;
- __fsfilcnt64_t f_ffree;
-#endif
- __fsid_t f_fsid;
- int f_namelen;
- int f_spare[6];
- };
-
-#ifdef __USE_LARGEFILE64
-struct statfs64
- {
- int f_type;
- int f_bsize;
- __fsblkcnt64_t f_blocks;
- __fsblkcnt64_t f_bfree;
- __fsblkcnt64_t f_bavail;
- __fsfilcnt64_t f_files;
- __fsfilcnt64_t f_ffree;
- __fsid_t f_fsid;
- int f_namelen;
- int f_spare[6];
- };
-#endif
diff --git a/libc/sysdeps/linux/vax/bits/syscalls.h b/libc/sysdeps/linux/vax/bits/syscalls.h
deleted file mode 100644
index 101aacb2e..000000000
--- a/libc/sysdeps/linux/vax/bits/syscalls.h
+++ /dev/null
@@ -1,258 +0,0 @@
-#ifndef _BITS_SYSCALLS_H
-#define _BITS_SYSCALLS_H
-#ifndef _SYSCALL_H
-# error "Never use <bits/syscall.h> directly; include <sys/syscall.h> instead."
-#endif
-
-#ifndef __ASSEMBLER__
-
-#include <errno.h>
-
-#define SYS_ify(syscall_name) (__NR_##syscall_name)
-
-#undef _syscall_return
-#define _syscall_return(type) \
- do { \
- if ((unsigned long) (_sc_ret) >= (unsigned long) (-125)) { \
- __set_errno(-_sc_ret); \
- _sc_ret = -1; \
- } \
- \
- return (type) (_sc_ret); \
- } while (0)
-
-#define _syscall_clobbers \
- "r1", "r2", "r3", "r4", \
- "r5", "r6", "r7", "r8", \
- "r9", "r10", "r11"
-
-#ifdef _syscall0
-# undef _syscall0
-#endif
-#define _syscall0(type, name) \
-type name (void) \
-{ \
- register long _sc_0 __asm__("r0") = SYS_ify (name); \
- long _sc_ret; \
- \
- __asm__ __volatile__ ( \
- " pushl %%ap \n" \
- " pushl $0x0 \n" \
- " movl %%sp, %%ap \n" \
- " chmk %%r0 \n" \
- " addl2 $4, %%sp \n" \
- " movl (%%sp)+, %%ap \n" \
- : "=r" (_sc_0) \
- : "0" (_sc_0) \
- : _syscall_clobbers); \
- \
- _sc_ret = _sc_0; \
- _syscall_return (type); \
-}
-
-#ifdef _syscall1
-# undef _syscall1
-#endif
-#define _syscall1(type, name, type1, arg1) \
-type name (type1 arg1) \
-{ \
- register long _sc_0 __asm__("r0") = SYS_ify (name); \
- long _sc_ret; \
- \
- __asm__ __volatile__ ( \
- " pushl %%ap \n" \
- " pushl %2 \n" \
- " pushl $0x1 \n" \
- " movl %%sp, %%ap \n" \
- " chmk %%r0 \n" \
- " addl2 $8, %%sp \n" \
- " movl (%%sp)+, %%ap \n" \
- : "=r" (_sc_0) \
- : "0" (_sc_0), \
- "m" (arg1) \
- : _syscall_clobbers); \
- \
- _sc_ret = _sc_0; \
- _syscall_return (type); \
-}
-
-#ifdef _syscall2
-# undef _syscall2
-#endif
-#define _syscall2(type, name, type1, arg1, type2, arg2) \
-type name (type1 arg1, \
- type2 arg2) \
-{ \
- register long _sc_0 __asm__("r0") = SYS_ify (name); \
- long _sc_ret; \
- \
- __asm__ __volatile__ ( \
- " pushl %%ap \n" \
- " pushl %3 \n" \
- " pushl %2 \n" \
- " pushl $0x2 \n" \
- " movl %%sp, %%ap \n" \
- " chmk %%r0 \n" \
- " addl2 $12, %%sp \n" \
- " movl (%%sp)+, %%ap \n" \
- : "=r" (_sc_0) \
- : "0" (_sc_0), \
- "m" (arg1), \
- "m" (arg2) \
- : _syscall_clobbers); \
- \
- _sc_ret = _sc_0; \
- _syscall_return (type); \
-}
-
-#ifdef _syscall3
-# undef _syscall3
-#endif
-#define _syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \
-type name (type1 arg1, \
- type2 arg2, \
- type3 arg3) \
-{ \
- register long _sc_0 __asm__("r0") = SYS_ify (name); \
- long _sc_ret; \
- \
- __asm__ __volatile__ ( \
- " pushl %%ap \n" \
- " pushl %4 \n" \
- " pushl %3 \n" \
- " pushl %2 \n" \
- " pushl $0x3 \n" \
- " movl %%sp, %%ap \n" \
- " chmk %%r0 \n" \
- " addl2 $16, %%sp \n" \
- " movl (%%sp)+, %%ap \n" \
- : "=r" (_sc_0) \
- : "0" (_sc_0), \
- "m" (arg1), \
- "m" (arg2), \
- "m" (arg3) \
- : _syscall_clobbers); \
- \
- _sc_ret = _sc_0; \
- _syscall_return (type); \
-}
-
-#ifdef _syscall4
-# undef _syscall4
-#endif
-#define _syscall4(type, name, type1, arg1, type2, arg2, type3, arg3, \
- type4, arg4) \
-type name (type1 arg1, \
- type2 arg2, \
- type3 arg3, \
- type4 arg4) \
-{ \
- register long _sc_0 __asm__("r0") = SYS_ify (name); \
- long _sc_ret; \
- \
- __asm__ __volatile__ ( \
- " pushl %%ap \n" \
- " pushl %5 \n" \
- " pushl %4 \n" \
- " pushl %3 \n" \
- " pushl %2 \n" \
- " pushl $0x4 \n" \
- " movl %%sp, %%ap \n" \
- " chmk %%r0 \n" \
- " addl2 $20, %%sp \n" \
- " movl (%%sp)+, %%ap \n" \
- : "=r" (_sc_0) \
- : "0" (_sc_0), \
- "m" (arg1), \
- "m" (arg2), \
- "m" (arg3), \
- "m" (arg4) \
- : _syscall_clobbers); \
- \
- _sc_ret = _sc_0; \
- _syscall_return (type); \
-}
-
-#ifdef _syscall5
-# undef _syscall5
-#endif
-#define _syscall5(type, name, type1, arg1, type2, arg2, type3, arg3, \
- type4, arg4, type5, arg5) \
-type name (type1 arg1, \
- type2 arg2, \
- type3 arg3, \
- type4 arg4, \
- type5 arg5) \
-{ \
- register long _sc_0 __asm__("r0") = SYS_ify (name); \
- long _sc_ret; \
- \
- __asm__ __volatile__ ( \
- " pushl %%ap \n" \
- " pushl %6 \n" \
- " pushl %5 \n" \
- " pushl %4 \n" \
- " pushl %3 \n" \
- " pushl %2 \n" \
- " pushl $0x5 \n" \
- " movl %%sp, %%ap \n" \
- " chmk %%r0 \n" \
- " addl2 $24, %%sp \n" \
- " movl (%%sp)+, %%ap \n" \
- : "=r" (_sc_0) \
- : "0" (_sc_0), \
- "m" (arg1), \
- "m" (arg2), \
- "m" (arg3), \
- "m" (arg4), \
- "m" (arg5) \
- : _syscall_clobbers); \
- \
- _sc_ret = _sc_0; \
- _syscall_return (type); \
-}
-
-#ifdef _syscall6
-# undef _syscall6
-#endif
-#define _syscall6(type, name, type1, arg1, type2, arg2, type3, arg3, \
- type4, arg4, type5, arg5, type6, arg6) \
-type name (type1 arg1, \
- type2 arg2, \
- type3 arg3, \
- type4 arg4, \
- type5 arg5, \
- type6 arg6) \
-{ \
- register long _sc_0 __asm__("r0") = SYS_ify (name); \
- long _sc_ret; \
- \
- __asm__ __volatile__ ( \
- " pushl %%ap \n" \
- " pushl %7 \n" \
- " pushl %6 \n" \
- " pushl %5 \n" \
- " pushl %4 \n" \
- " pushl %3 \n" \
- " pushl %2 \n" \
- " pushl $0x6 \n" \
- " movl %%sp, %%ap \n" \
- " chmk %%r0 \n" \
- " addl2 $28, %%sp \n" \
- " movl (%%sp)+, %%ap \n" \
- : "=r" (_sc_0) \
- : "0" (_sc_0), \
- "m" (arg1), \
- "m" (arg2), \
- "m" (arg3), \
- "m" (arg4), \
- "m" (arg5), \
- "m" (arg6) \
- : _syscall_clobbers); \
- \
- _sc_ret = _sc_0; \
- _syscall_return (type); \
-}
-
-#endif /* __ASSEMBLER__ */
-#endif /* _BITS_SYSCALLS_H */
diff --git a/libc/sysdeps/linux/vax/bits/wordsize.h b/libc/sysdeps/linux/vax/bits/wordsize.h
deleted file mode 100644
index 62dad0c71..000000000
--- a/libc/sysdeps/linux/vax/bits/wordsize.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/* 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 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. */
-
-#define __WORDSIZE 32
diff --git a/libc/sysdeps/linux/vax/brk.c b/libc/sysdeps/linux/vax/brk.c
deleted file mode 100644
index 47fd3e529..000000000
--- a/libc/sysdeps/linux/vax/brk.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* brk system call for Linux/VAX.
- Copyright (C) 2000, 2005 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- 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 <errno.h>
-#include <unistd.h>
-#include <sys/syscall.h>
-
-/* This must be initialized data because commons can't have aliases. */
-void *__curbrk attribute_hidden = NULL;
-
-libc_hidden_proto(brk)
-int
-brk (void *addr)
-{
- register unsigned long int result __asm__ ("%%r0");
-
- __asm__ (
- " pushl %%ap \n" /* Start frame */
- " pushl %2 \n" /* New top address we wish to get */
- " pushl $1 \n" /* One argument */
- " movl %%sp, %%ap \n" /* Finish frame */
- " chmk %1 \n" /* Perform the system call */
- " addl2 $8, %%sp \n" /* Remove pushed arg */
- " movl (%%sp)+, %%ap \n" /* Get back %AP */
- : "=r" (result)
- : "0" (__NR_brk),
- "g" (addr));
-
- if ((void *) result < addr) {
- __set_errno (ENOMEM);
- return -1;
- } else
- __curbrk = (void *) result;
-
- return 0;
-}
-libc_hidden_def(brk)
-
diff --git a/libc/sysdeps/linux/vax/clone.S b/libc/sysdeps/linux/vax/clone.S
deleted file mode 100644
index 086adc685..000000000
--- a/libc/sysdeps/linux/vax/clone.S
+++ /dev/null
@@ -1,85 +0,0 @@
-/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
-
- 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. */
-
-/* clone() is even more special than fork() as it mucks with stacks
- and invokes a function in the right context after its all over. */
-
-#include <sys/syscall.h>
-
-#warning "This file contains a hardcoded constant for SYS_clone"
-
-.section .rodata
- .align 2
-.LC0: .long 120 /* SYS_clone */
-.align 4
-.text
-.type clone,@function
-.globl clone;
-clone:
- .word 0x0040
- /* subl2 $8, %sp */
- movl 4(%ap), %r1
- movl 8(%ap), %r0
- mcoml $21, %r6
-
- /* Sanity check args. */
- tstl %r1
- jeql CLONE_ERROR_LABEL
- tstl %r0
- jeql CLONE_ERROR_LABEL
-
- /* Need to setup the child stack the same as the parent. */
- subl2 $24, %r0
- movl 16(%ap), 20(%r0)
- movl %r1, 16(%r0)
- movl %r0, %r1
- addl2 $16, %r1
- movl %r1, 12(%r0)
-
- /* Do the system call. */
- pushl %ap
- pushl %r0
- pushl 12(%ap)
- pushl $0x2
- movl %sp, %ap
- chmk .LC0 /* %r0 .LC0 -4(%fp) -8(%fp) */
- addl2 $12, %sp
- movl (%sp)+, %ap
- movl %r0, %r6
- jneq CLONE_ERROR_LABEL
-
- movl $0, %fp
- pushl 4(%ap)
- movl (%r1), %r0
- calls $1, (%r0)
- pushl %r0
- calls $1, HIDDEN_JUMPTARGET(_exit)
-
-CLONE_ERROR_LABEL:
- cmpl %r6, $-126 /* -ENOKEY?!?! Fuck, this must be wrong! FIXME */
- jlequ CLONE_RETURN_LABEL
- calls $0, __errno_location
- mnegl %r6, (%r0)
- mcoml $0, %r6
- movl %r6, %r0
- ret
-
-CLONE_RETURN_LABEL:
- ret
-
-.size clone,.-clone
-
diff --git a/libc/sysdeps/linux/vax/crt1.S b/libc/sysdeps/linux/vax/crt1.S
deleted file mode 100644
index 70960988d..000000000
--- a/libc/sysdeps/linux/vax/crt1.S
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * crt0 for VAX
- */
-
-/*
- * Program stack looks like:
- * sp-> argc argument counter (integer)
- * argv[0] program name (pointer)
- * argv[1...N] program args (pointers)
- * argv[argc-1] end of args (integer)
- * NULL
- * env[0...N] environment variables (pointers)
- * NULL
- */
-
-#include <features.h>
-
-.text
-.align 4
-
-.global __start
-__start:
-.global _start
-_start:
- /* Kernel uses a_interp + 2, so __start isn't exactly CALLSed, */
- /* but we need to have two bytes here, so we use NOPs. This */
- /* won't hurt, though R0 would be invalid to push, but at */
- /* lease this looks like a real function. */
- .word 0x0101
-
- movl $0, %fp /* FP = 0, since this is the */
- /* top-most stack frame */
- movl %sp, %r0 /* R0 = %sp */
- movl (%sp)+, %r4 /* R4 = argc */
- movl %sp, %r3 /* R3 = argv = &argv[0] */
-
-#if (defined L_crt1 || defined L_gcrt1) && defined __UCLIBC_CTOR_DTOR__
- pushl %r0 /* stack_end */
- pushl $0 /* rtld_fini. This is probably needed for the */
- /* case where a dynamic linker is involved. So */
- /* this is an open FIXME that needs to be */
- /* addressed at some time... */
- pushl $_fini
- pushl $_init
- pushl %r3 /* Argument pointer */
- pushl %r4 /* And the argument count */
- pushl $main /* main() */
-
- /* We need to call __uClibc_main which should not return.
- * __uClibc_main (int (*main) (int, char **, char **),
- * int argc,
- * char **argv,
- * void (*init) (void),
- * void (*fini) (void),
- * void (*rtld_fini) (void),
- * void *stack_end);
- */
- calls $7, __uClibc_main
-#else /* FIXME: THIS IS BROKEN!!! */
- /* start to load the arguments from the stack */
- /* arguments are on ap stack */
- pushl %r2
- pushl %r3
- pushl %r4
-
- calls $3, __uClibc_main
-#endif
-
- /* The above __uClibc_start_main() shouldn't ever return. If it */
- /* does, we just crash. */
- halt
-.align 2
-
diff --git a/libc/sysdeps/linux/vax/crti.S b/libc/sysdeps/linux/vax/crti.S
deleted file mode 100644
index 0056478bb..000000000
--- a/libc/sysdeps/linux/vax/crti.S
+++ /dev/null
@@ -1,21 +0,0 @@
- .file "initfini.c"
- .version "01.01"
-gcc2_compiled.:
-__gnu_compiled_c:
- .section .init
- .align 1
-.globl _init
- .type _init,@function
-_init:
- .word 0x0000
-
- .align 1
-
- .section .fini
- .align 1
-.globl _fini
- .type _fini,@function
-_fini:
- .word 0x0000
- .align 1
- .ident "GCC: (GNU) 2.95.2 19991024 (release) (Linux/VAX CVS)"
diff --git a/libc/sysdeps/linux/vax/crtn.S b/libc/sysdeps/linux/vax/crtn.S
deleted file mode 100644
index 6ca5c4fcd..000000000
--- a/libc/sysdeps/linux/vax/crtn.S
+++ /dev/null
@@ -1,21 +0,0 @@
- .file "initfini.c"
- .version "01.01"
-gcc2_compiled.:
-__gnu_compiled_c:
-
- .section .init
- .align 1
-.globl _init
- .type _init,@function
- ret
-.Lfe2:
- .size _init,.Lfe2-_init
-
- .section .fini
- .align 1
-.globl _fini
- .type _fini,@function
- ret
-.Lfe3:
- .size _fini,.Lfe3-_fini
- .ident "GCC: (GNU) 2.95.2 19991024 (release) (Linux/VAX CVS)"
diff --git a/libc/sysdeps/linux/vax/mmap.c b/libc/sysdeps/linux/vax/mmap.c
deleted file mode 100644
index 41bfb79f1..000000000
--- a/libc/sysdeps/linux/vax/mmap.c
+++ /dev/null
@@ -1,11 +0,0 @@
-
-#include <unistd.h>
-#include <sys/mman.h>
-#include <errno.h>
-#include <sys/syscall.h>
-
-libc_hidden_proto(mmap)
-_syscall6 (void *, mmap, void *, start, size_t, length, int, prot, int, flags,
- int, fd, off_t, offset);
-libc_hidden_def(mmap)
-
diff --git a/libc/sysdeps/linux/vax/setjmp.S b/libc/sysdeps/linux/vax/setjmp.S
deleted file mode 100644
index bdbde4b13..000000000
--- a/libc/sysdeps/linux/vax/setjmp.S
+++ /dev/null
@@ -1,39 +0,0 @@
-
-/*
- * setjmp.S atp. Sept. 2001
- * Jan-Benedict Glaw <jbglaw@lug-owl.de> 2006
- *
- * Save regs and info needed for a longjmp
- */
-
-.globl __sigsetjmp
-.align 4
-__sigsetjmp:
- .word 0x0000 /* We look after reg saving here - this */
- /* must match longjmp. */
- movl 0x4(%ap), %r0 /* Our scratch reg */
- /* kenn would probably use movq here. :-) */
- movl %r1, 0x14(%r0) /* save regs */
- movl %r2, 0x18(%r0)
- movl %r3, 0x1c(%r0)
- movl %r4, 0x20(%r0)
- movl %r5, 0x24(%r0)
- movl %r6, 0x28(%r0)
- movl %r7, 0x2c(%r0)
- movl %r8, 0x30(%r0)
- movl %r9, 0x34(%r0)
- movl %r10, 0x38(%r0)
- movl %r11, 0x3c(%r0)
- /* Now save our call frame */
- movl (%fp), (%r0) /* Condition handler (for VMS emulation) */
- movl 0x4(%fp), 0x4(%r0) /* psw */
- movl 0x8(%fp), 0x8(%r0) /* ap */
- movl 0xc(%fp), 0xc(%r0) /* fp */
- movl 0x10(%fp), 0x10(%r0) /* pc */
- /* Call the sigjmp save routine */
- pushl 8(%ap)
- pushl %r0
- calls $2, __sigjmp_save
- /* Done */
- ret
-
diff --git a/libc/sysdeps/linux/vax/sys/ucontext.h b/libc/sysdeps/linux/vax/sys/ucontext.h
deleted file mode 100644
index f57b91e4f..000000000
--- a/libc/sysdeps/linux/vax/sys/ucontext.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* Copyright (C) 1997, 1998, 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. */
-
-/* Don't rely on this, the interface is currently messed up and may need to
- be broken to be fixed. */
-#ifndef _SYS_UCONTEXT_H
-#define _SYS_UCONTEXT_H 1
-
-#include <features.h>
-#include <signal.h>
-
-/* We need the signal context definitions even if they are not used
- included in <signal.h>. */
-#include <bits/sigcontext.h>
-
-
-/* Type for general register. */
-typedef unsigned long int greg_t;
-
-/* Number of general registers. */
-#define NGREG 37
-#define NFPREG 33
-
-/* Container for all general registers. */
-/* gregset_t must be an array. The below declared array corresponds to:
-typedef struct gregset {
- greg_t g_regs[32];
- greg_t g_hi;
- greg_t g_lo;
- greg_t g_pad[3];
-} gregset_t; */
-typedef greg_t gregset_t[NGREG];
-
-/* Container for all FPU registers. */
-typedef struct fpregset {
- union {
- double fp_dregs[32];
- struct {
- float _fp_fregs;
- unsigned int _fp_pad;
- } fp_fregs[32];
- } fp_r;
- unsigned int fp_csr;
- unsigned int fp_pad;
-} fpregset_t;
-
-
-/* Context to describe whole processor state. */
-typedef struct
- {
- gregset_t gregs;
- fpregset_t fpregs;
- } mcontext_t;
-
-/* Userlevel context. */
-typedef struct ucontext
- {
- unsigned long int 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/x86_64/Makefile.arch b/libc/sysdeps/linux/x86_64/Makefile.arch
index b6ad71cbd..2bc838f0e 100644
--- a/libc/sysdeps/linux/x86_64/Makefile.arch
+++ b/libc/sysdeps/linux/x86_64/Makefile.arch
@@ -5,9 +5,15 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-CSRC := brk.c sigaction.c __syscall_error.c mmap.c
+CSRC-y := brk.c __syscall_error.c sigaction.c
-SSRC := \
- __longjmp.S vfork.S setjmp.S syscall.S bsd-setjmp.S bsd-_setjmp.S clone.S
+SSRC-y := \
+ __longjmp.S setjmp.S syscall.S bsd-setjmp.S bsd-_setjmp.S
-include $(top_srcdir)libc/sysdeps/linux/Makefile.commonarch
+SSRC-$(if $(UCLIBC_HAS_THREADS_NATIVE),,y) += vfork.S clone.S
+ARCH_OBJ_FILTEROUT-$(UCLIBC_LINUX_SPECIFIC) := sched_getcpu.c
+ifeq ($(UCLIBC_LINUX_SPECIFIC),y)
+SSRC-$(UCLIBC_HAS_TLS) += sched_getcpu.S
+endif
+CSRC-$(UCLIBC_HAS_CONTEXT_FUNCS) += makecontext.c
+SSRC-$(UCLIBC_HAS_CONTEXT_FUNCS) += setcontext.S getcontext.S swapcontext.S __start_context.S
diff --git a/libc/sysdeps/linux/x86_64/__longjmp.S b/libc/sysdeps/linux/x86_64/__longjmp.S
index db2928bf0..907b64c9d 100644
--- a/libc/sysdeps/linux/x86_64/__longjmp.S
+++ b/libc/sysdeps/linux/x86_64/__longjmp.S
@@ -12,14 +12,10 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
-#include <features.h>
-#define _ASM
-#define _SETJMP_H
-#include <bits/setjmp.h>
+#include <jmpbuf-offsets.h>
/* Jump to the position specified by ENV, causing the
setjmp call there to return VAL, or 1 if VAL is 0.
diff --git a/libc/sysdeps/linux/x86_64/__start_context.S b/libc/sysdeps/linux/x86_64/__start_context.S
new file mode 100644
index 000000000..9f2ee2373
--- /dev/null
+++ b/libc/sysdeps/linux/x86_64/__start_context.S
@@ -0,0 +1,49 @@
+/* Copyright (C) 2002-2012 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger <aj@suse.de>, 2002.
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+
+/* This is the helper code which gets called if a function which is
+ registered with 'makecontext' returns. In this case we have to
+ install the context listed in the uc_link element of the context
+ 'makecontext' manipulated at the time of the 'makecontext' call.
+ If the pointer is NULL the process must terminate. */
+
+
+ENTRY(__start_context)
+ /* This removes the parameters passed to the function given to
+ 'makecontext' from the stack. RBX contains the address
+ on the stack pointer for the next context. */
+ movq %rbx, %rsp
+
+ popq %rdi /* This is the next context. */
+ cfi_adjust_cfa_offset(-8)
+ testq %rdi, %rdi
+ je 2f /* If it is zero exit. */
+
+ call JUMPTARGET(__setcontext)
+ /* If this returns (which can happen if the syscall fails) we'll
+ exit the program with the return error value (-1). */
+ movq %rax,%rdi
+
+2:
+ call HIDDEN_JUMPTARGET(exit)
+ /* The 'exit' call should never return. In case it does cause
+ the process to terminate. */
+ hlt
+END(__start_context)
diff --git a/libc/sysdeps/linux/x86_64/bits/atomic.h b/libc/sysdeps/linux/x86_64/bits/atomic.h
index 04870cbf5..1887f79fa 100644
--- a/libc/sysdeps/linux/x86_64/bits/atomic.h
+++ b/libc/sysdeps/linux/x86_64/bits/atomic.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <stdint.h>
@@ -57,28 +56,28 @@ typedef uintmax_t uatomic_max_t;
#define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
({ __typeof (*mem) ret; \
- __asm__ __volatile__ (LOCK_PREFIX "cmpxchgb %b2, %1" \
+ __asm__ __volatile__ (LOCK_PREFIX "cmpxchgb %b2, %1" \
: "=a" (ret), "=m" (*mem) \
: "q" (newval), "m" (*mem), "0" (oldval)); \
ret; })
#define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \
({ __typeof (*mem) ret; \
- __asm__ __volatile__ (LOCK_PREFIX "cmpxchgw %w2, %1" \
+ __asm__ __volatile__ (LOCK_PREFIX "cmpxchgw %w2, %1" \
: "=a" (ret), "=m" (*mem) \
: "r" (newval), "m" (*mem), "0" (oldval)); \
ret; })
#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
({ __typeof (*mem) ret; \
- __asm__ __volatile__ (LOCK_PREFIX "cmpxchgl %2, %1" \
+ __asm__ __volatile__ (LOCK_PREFIX "cmpxchgl %2, %1" \
: "=a" (ret), "=m" (*mem) \
: "r" (newval), "m" (*mem), "0" (oldval)); \
ret; })
#define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
({ __typeof (*mem) ret; \
- __asm__ __volatile__ (LOCK_PREFIX "cmpxchgq %q2, %1" \
+ __asm__ __volatile__ (LOCK_PREFIX "cmpxchgq %q2, %1" \
: "=a" (ret), "=m" (*mem) \
: "r" ((long) (newval)), "m" (*mem), \
"0" ((long) (oldval))); \
@@ -97,7 +96,7 @@ typedef uintmax_t uatomic_max_t;
: "=r" (result), "=m" (*mem) \
: "0" (newvalue), "m" (*mem)); \
else if (sizeof (*mem) == 4) \
- __asm__ __volatile__ ("xchgl %0, %1" \
+ __asm__ __volatile__ ("xchgl %0, %1" \
: "=r" (result), "=m" (*mem) \
: "0" (newvalue), "m" (*mem)); \
else \
@@ -110,11 +109,11 @@ typedef uintmax_t uatomic_max_t;
#define atomic_exchange_and_add(mem, value) \
({ __typeof (*mem) result; \
if (sizeof (*mem) == 1) \
- __asm__ __volatile__ (LOCK_PREFIX "xaddb %b0, %1" \
+ __asm__ __volatile__ (LOCK_PREFIX "xaddb %b0, %1" \
: "=r" (result), "=m" (*mem) \
: "0" (value), "m" (*mem)); \
else if (sizeof (*mem) == 2) \
- __asm__ __volatile__ (LOCK_PREFIX "xaddw %w0, %1" \
+ __asm__ __volatile__ (LOCK_PREFIX "xaddw %w0, %1" \
: "=r" (result), "=m" (*mem) \
: "0" (value), "m" (*mem)); \
else if (sizeof (*mem) == 4) \
@@ -122,7 +121,7 @@ typedef uintmax_t uatomic_max_t;
: "=r" (result), "=m" (*mem) \
: "0" (value), "m" (*mem)); \
else \
- __asm__ __volatile__ (LOCK_PREFIX "xaddq %q0, %1" \
+ __asm__ __volatile__ (LOCK_PREFIX "xaddq %q0, %1" \
: "=r" (result), "=m" (*mem) \
: "0" ((long) (value)), "m" (*mem)); \
result; })
@@ -155,11 +154,11 @@ typedef uintmax_t uatomic_max_t;
#define atomic_add_negative(mem, value) \
({ unsigned char __result; \
if (sizeof (*mem) == 1) \
- __asm__ __volatile__ (LOCK_PREFIX "addb %b2, %0; sets %1" \
+ __asm__ __volatile__ (LOCK_PREFIX "addb %b2, %0; sets %1" \
: "=m" (*mem), "=qm" (__result) \
: "ir" (value), "m" (*mem)); \
else if (sizeof (*mem) == 2) \
- __asm__ __volatile__ (LOCK_PREFIX "addw %w2, %0; sets %1" \
+ __asm__ __volatile__ (LOCK_PREFIX "addw %w2, %0; sets %1" \
: "=m" (*mem), "=qm" (__result) \
: "ir" (value), "m" (*mem)); \
else if (sizeof (*mem) == 4) \
@@ -167,7 +166,7 @@ typedef uintmax_t uatomic_max_t;
: "=m" (*mem), "=qm" (__result) \
: "ir" (value), "m" (*mem)); \
else \
- __asm__ __volatile__ (LOCK_PREFIX "addq %q2, %0; sets %1" \
+ __asm__ __volatile__ (LOCK_PREFIX "addq %q2, %0; sets %1" \
: "=m" (*mem), "=qm" (__result) \
: "ir" ((long) (value)), "m" (*mem)); \
__result; })
@@ -176,11 +175,11 @@ typedef uintmax_t uatomic_max_t;
#define atomic_add_zero(mem, value) \
({ unsigned char __result; \
if (sizeof (*mem) == 1) \
- __asm__ __volatile__ (LOCK_PREFIX "addb %b2, %0; setz %1" \
+ __asm__ __volatile__ (LOCK_PREFIX "addb %b2, %0; setz %1" \
: "=m" (*mem), "=qm" (__result) \
: "ir" (value), "m" (*mem)); \
else if (sizeof (*mem) == 2) \
- __asm__ __volatile__ (LOCK_PREFIX "addw %w2, %0; setz %1" \
+ __asm__ __volatile__ (LOCK_PREFIX "addw %w2, %0; setz %1" \
: "=m" (*mem), "=qm" (__result) \
: "ir" (value), "m" (*mem)); \
else if (sizeof (*mem) == 4) \
@@ -188,7 +187,7 @@ typedef uintmax_t uatomic_max_t;
: "=m" (*mem), "=qm" (__result) \
: "ir" (value), "m" (*mem)); \
else \
- __asm__ __volatile__ (LOCK_PREFIX "addq %q2, %0; setz %1" \
+ __asm__ __volatile__ (LOCK_PREFIX "addq %q2, %0; setz %1" \
: "=m" (*mem), "=qm" (__result) \
: "ir" ((long) (value)), "m" (*mem)); \
__result; })
@@ -196,19 +195,19 @@ typedef uintmax_t uatomic_max_t;
#define atomic_increment(mem) \
(void) ({ if (sizeof (*mem) == 1) \
- __asm__ __volatile__ (LOCK_PREFIX "incb %b0" \
+ __asm__ __volatile__ (LOCK_PREFIX "incb %b0" \
: "=m" (*mem) \
: "m" (*mem)); \
else if (sizeof (*mem) == 2) \
- __asm__ __volatile__ (LOCK_PREFIX "incw %w0" \
+ __asm__ __volatile__ (LOCK_PREFIX "incw %w0" \
: "=m" (*mem) \
: "m" (*mem)); \
else if (sizeof (*mem) == 4) \
- __asm__ __volatile__ (LOCK_PREFIX "incl %0" \
+ __asm__ __volatile__ (LOCK_PREFIX "incl %0" \
: "=m" (*mem) \
: "m" (*mem)); \
else \
- __asm__ __volatile__ (LOCK_PREFIX "incq %q0" \
+ __asm__ __volatile__ (LOCK_PREFIX "incq %q0" \
: "=m" (*mem) \
: "m" (*mem)); \
})
@@ -225,7 +224,7 @@ typedef uintmax_t uatomic_max_t;
: "=m" (*mem), "=qm" (__result) \
: "m" (*mem)); \
else if (sizeof (*mem) == 4) \
- __asm__ __volatile__ (LOCK_PREFIX "incl %0; sete %1" \
+ __asm__ __volatile__ (LOCK_PREFIX "incl %0; sete %1" \
: "=m" (*mem), "=qm" (__result) \
: "m" (*mem)); \
else \
@@ -237,19 +236,19 @@ typedef uintmax_t uatomic_max_t;
#define atomic_decrement(mem) \
(void) ({ if (sizeof (*mem) == 1) \
- __asm__ __volatile__ (LOCK_PREFIX "decb %b0" \
+ __asm__ __volatile__ (LOCK_PREFIX "decb %b0" \
: "=m" (*mem) \
: "m" (*mem)); \
else if (sizeof (*mem) == 2) \
- __asm__ __volatile__ (LOCK_PREFIX "decw %w0" \
+ __asm__ __volatile__ (LOCK_PREFIX "decw %w0" \
: "=m" (*mem) \
: "m" (*mem)); \
else if (sizeof (*mem) == 4) \
- __asm__ __volatile__ (LOCK_PREFIX "decl %0" \
+ __asm__ __volatile__ (LOCK_PREFIX "decl %0" \
: "=m" (*mem) \
: "m" (*mem)); \
else \
- __asm__ __volatile__ (LOCK_PREFIX "decq %q0" \
+ __asm__ __volatile__ (LOCK_PREFIX "decq %q0" \
: "=m" (*mem) \
: "m" (*mem)); \
})
@@ -266,7 +265,7 @@ typedef uintmax_t uatomic_max_t;
: "=m" (*mem), "=qm" (__result) \
: "m" (*mem)); \
else if (sizeof (*mem) == 4) \
- __asm__ __volatile__ (LOCK_PREFIX "decl %0; sete %1" \
+ __asm__ __volatile__ (LOCK_PREFIX "decl %0; sete %1" \
: "=m" (*mem), "=qm" (__result) \
: "m" (*mem)); \
else \
@@ -314,7 +313,7 @@ typedef uintmax_t uatomic_max_t;
__asm__ __volatile__ (LOCK_PREFIX "btsl %3, %1; setc %0" \
: "=q" (__result), "=m" (*mem) \
: "m" (*mem), "ir" (bit)); \
- else \
+ else \
__asm__ __volatile__ (LOCK_PREFIX "btsq %3, %1; setc %0" \
: "=q" (__result), "=m" (*mem) \
: "m" (*mem), "ir" (bit)); \
diff --git a/libc/sysdeps/linux/x86_64/bits/byteswap.h b/libc/sysdeps/linux/x86_64/bits/byteswap.h
index e1c861c75..2a759bed4 100644
--- a/libc/sysdeps/linux/x86_64/bits/byteswap.h
+++ b/libc/sysdeps/linux/x86_64/bits/byteswap.h
@@ -13,121 +13,55 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
-#if !defined _BYTESWAP_H && !defined _NETINET_IN_H
-# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
-#endif
-
-#ifndef _BITS_BYTESWAP_H
-#define _BITS_BYTESWAP_H 1
+#ifndef _ASM_BITS_BYTESWAP_H
+#define _ASM_BITS_BYTESWAP_H 1
#include <bits/wordsize.h>
-/* Swap bytes in 16 bit value. */
-#define __bswap_constant_16(x) \
- ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))
-
-#if defined __GNUC__ && __GNUC__ >= 2
-# define __bswap_16(x) \
+#define __bswap_non_constant_16(x) \
(__extension__ \
- ({ register unsigned short int __v, __x = (x); \
- if (__builtin_constant_p (__x)) \
- __v = __bswap_constant_16 (__x); \
- else \
- __asm__ ("rorw $8, %w0" \
- : "=r" (__v) \
- : "0" (__x) \
- : "cc"); \
+ ({ register unsigned short int __v; \
+ __asm__ ("rorw $8, %w0" \
+ : "=r" (__v) \
+ : "0" (x) \
+ : "cc"); \
__v; }))
-#else
-/* This is better than nothing. */
-# define __bswap_16(x) \
- (__extension__ \
- ({ register unsigned short int __x = (x); __bswap_constant_16 (__x); }))
-#endif
-
-
-/* Swap bytes in 32 bit value. */
-#define __bswap_constant_32(x) \
- ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
- (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
-#if defined __GNUC__ && __GNUC__ >= 2
-# if __WORDSIZE == 64 || (defined __i486__ || defined __pentium__ \
- || defined __pentiumpro__ || defined __pentium4__ \
- || defined __k8__ || defined __athlon__ \
- || defined __k6__)
+#if __WORDSIZE == 64 || (defined __i486__ || defined __pentium__ \
+ || defined __pentiumpro__ || defined __pentium4__ \
+ || defined __k8__ || defined __athlon__ \
+ || defined __k6__)
/* To swap the bytes in a word the i486 processors and up provide the
`bswap' opcode. On i386 we have to use three instructions. */
-# define __bswap_32(x) \
+# define __bswap_non_constant_32(x) \
(__extension__ \
- ({ register unsigned int __v, __x = (x); \
- if (__builtin_constant_p (__x)) \
- __v = __bswap_constant_32 (__x); \
- else \
- __asm__ ("bswap %0" : "=r" (__v) : "0" (__x)); \
+ ({ register unsigned int __v; \
+ __asm__ ("bswap %0" : "=r" (__v) : "0" (x)); \
__v; }))
-# else
-# define __bswap_32(x) \
- (__extension__ \
- ({ register unsigned int __v, __x = (x); \
- if (__builtin_constant_p (__x)) \
- __v = __bswap_constant_32 (__x); \
- else \
- __asm__ ("rorw $8, %w0;" \
- "rorl $16, %0;" \
- "rorw $8, %w0" \
- : "=r" (__v) \
- : "0" (__x) \
- : "cc"); \
- __v; }))
-# endif
#else
-# define __bswap_32(x) \
+# define __bswap_non_constant_32(x) \
(__extension__ \
- ({ register unsigned int __x = (x); __bswap_constant_32 (__x); }))
+ ({ register unsigned int __v; \
+ __asm__ ("rorw $8, %w0;" \
+ "rorl $16, %0;" \
+ "rorw $8, %w0" \
+ : "=r" (__v) \
+ : "0" (x) \
+ : "cc"); \
+ __v; }))
#endif
-
-#if defined __GNUC__ && __GNUC__ >= 2
-/* Swap bytes in 64 bit value. */
-# define __bswap_constant_64(x) \
- ((((x) & 0xff00000000000000ull) >> 56) \
- | (((x) & 0x00ff000000000000ull) >> 40) \
- | (((x) & 0x0000ff0000000000ull) >> 24) \
- | (((x) & 0x000000ff00000000ull) >> 8) \
- | (((x) & 0x00000000ff000000ull) << 8) \
- | (((x) & 0x0000000000ff0000ull) << 24) \
- | (((x) & 0x000000000000ff00ull) << 40) \
- | (((x) & 0x00000000000000ffull) << 56))
-
-# if __WORDSIZE == 64
-# define __bswap_64(x) \
+#if __WORDSIZE == 64
+# define __bswap_non_constant_64(x) \
(__extension__ \
- ({ register unsigned long __v, __x = (x); \
- if (__builtin_constant_p (__x)) \
- __v = __bswap_constant_64 (__x); \
- else \
- __asm__ ("bswap %q0" : "=r" (__v) : "0" (__x)); \
+ ({ register unsigned long __v; \
+ __asm__ ("bswap %q0" : "=r" (__v) : "0" (x)); \
__v; }))
-# else
-# define __bswap_64(x) \
- (__extension__ \
- ({ union { __extension__ unsigned long long int __ll; \
- unsigned int __l[2]; } __w, __r; \
- if (__builtin_constant_p (x)) \
- __r.__ll = __bswap_constant_64 (x); \
- else \
- { \
- __w.__ll = (x); \
- __r.__l[0] = __bswap_32 (__w.__l[1]); \
- __r.__l[1] = __bswap_32 (__w.__l[0]); \
- } \
- __r.__ll; }))
-# endif
#endif
-#endif /* _BITS_BYTESWAP_H */
+#endif
+
+#include <bits/byteswap-common.h>
diff --git a/libc/sysdeps/linux/x86_64/bits/environments.h b/libc/sysdeps/linux/x86_64/bits/environments.h
index a51a564cb..007f4fcce 100644
--- a/libc/sysdeps/linux/x86_64/bits/environments.h
+++ b/libc/sysdeps/linux/x86_64/bits/environments.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _UNISTD_H
# error "Never include this file directly. Use <unistd.h> instead"
diff --git a/libc/sysdeps/linux/x86_64/bits/epoll.h b/libc/sysdeps/linux/x86_64/bits/epoll.h
new file mode 100644
index 000000000..be1f5a636
--- /dev/null
+++ b/libc/sysdeps/linux/x86_64/bits/epoll.h
@@ -0,0 +1,31 @@
+/* Copyright (C) 2002-2012 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_EPOLL_H
+# error "Never use <bits/epoll.h> directly; include <sys/epoll.h> instead."
+#endif
+
+/* Flags to be passed to epoll_create1. */
+enum
+ {
+ EPOLL_CLOEXEC = 02000000,
+#define EPOLL_CLOEXEC EPOLL_CLOEXEC
+ EPOLL_NONBLOCK = 00004000
+#define EPOLL_NONBLOCK EPOLL_NONBLOCK
+ };
+
+#define __EPOLL_PACKED __attribute__ ((__packed__))
diff --git a/libc/sysdeps/linux/x86_64/bits/fcntl.h b/libc/sysdeps/linux/x86_64/bits/fcntl.h
index 42c790a51..757d6be22 100644
--- a/libc/sysdeps/linux/x86_64/bits/fcntl.h
+++ b/libc/sysdeps/linux/x86_64/bits/fcntl.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FCNTL_H
# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
@@ -50,9 +49,8 @@
# define O_DIRECTORY 0200000 /* Must be a directory. */
# define O_NOFOLLOW 0400000 /* Do not follow links. */
# define O_NOATIME 01000000 /* Do not set atime. */
-# if 0
# define O_CLOEXEC 02000000 /* Set close_on_exec. */
-# endif
+# define O_PATH 010000000 /* Resolve pathname but do not open file. */
#endif
/* For now Linux has synchronisity options for data and read operations.
@@ -116,6 +114,8 @@
# define F_NOTIFY 1026 /* Request notfications on a directory. */
# define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with
close-on-exit set on new fd. */
+# define F_SETPIPE_SZ 1031 /* Set pipe page size array. */
+# define F_GETPIPE_SZ 1032 /* Get pipe page size array. */
#endif
/* For F_[GET|SET]FD. */
@@ -203,7 +203,7 @@ struct flock64
#endif
-#ifdef __USE_GNU
+#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
@@ -226,7 +226,7 @@ struct flock64
__BEGIN_DECLS
-#ifdef __USE_GNU
+#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)
diff --git a/libc/sysdeps/linux/x86_64/bits/fenv.h b/libc/sysdeps/linux/x86_64/bits/fenv.h
index 11859f00c..8c720e675 100644
--- a/libc/sysdeps/linux/x86_64/bits/fenv.h
+++ b/libc/sysdeps/linux/x86_64/bits/fenv.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FENV_H
# error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
@@ -89,9 +88,9 @@ typedef struct
fenv_t;
/* If the default argument is used we use this value. */
-#define FE_DFL_ENV ((__const fenv_t *) -1)
+#define FE_DFL_ENV ((const fenv_t *) -1)
#ifdef __USE_GNU
/* Floating-point environment where none of the exception is masked. */
-# define FE_NOMASK_ENV ((__const fenv_t *) -2)
+# define FE_NOMASK_ENV ((const fenv_t *) -2)
#endif
diff --git a/libc/sysdeps/linux/x86_64/bits/kernel_stat.h b/libc/sysdeps/linux/x86_64/bits/kernel_stat.h
index 7dca5ffbb..e194a7f76 100644
--- a/libc/sysdeps/linux/x86_64/bits/kernel_stat.h
+++ b/libc/sysdeps/linux/x86_64/bits/kernel_stat.h
@@ -1,14 +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
-
-#define STAT_HAVE_NSEC 1
+#ifndef _BITS_STAT_STRUCT_H
+#define _BITS_STAT_STRUCT_H
struct kernel_stat {
unsigned long st_dev;
@@ -24,30 +18,12 @@ struct kernel_stat {
long st_blksize;
long st_blocks; /* Number 512-byte blocks allocated. */
- unsigned long st_atime;
- unsigned long st_atime_nsec;
- unsigned long st_mtime;
- unsigned long st_mtime_nsec;
- unsigned long st_ctime;
- unsigned long st_ctime_nsec;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
long __unused[3];
};
-/* For 32bit emulation */
-struct __old_kernel_stat {
- unsigned short st_dev;
- unsigned short st_ino;
- unsigned short st_mode;
- unsigned short st_nlink;
- unsigned short st_uid;
- unsigned short st_gid;
- unsigned short st_rdev;
- unsigned int st_size;
- unsigned int st_atime;
- unsigned int st_mtime;
- unsigned int st_ctime;
-};
-
/* x86-64 stat64 is same as stat */
#define kernel_stat64 kernel_stat
diff --git a/libc/sysdeps/linux/x86_64/bits/kernel_types.h b/libc/sysdeps/linux/x86_64/bits/kernel_types.h
index 73f6ffb54..0cae08c60 100644
--- a/libc/sysdeps/linux/x86_64/bits/kernel_types.h
+++ b/libc/sysdeps/linux/x86_64/bits/kernel_types.h
@@ -4,8 +4,17 @@
* our private content, and not the kernel header, will win.
* -Erik
*/
-#ifndef _ASM_X86_64_POSIX_TYPES_H
+
+/* a hack for compiling a 32 bit user space with 64 bit
+ * kernel on x86_64 */
+#if !defined(__ARCH_I386_POSIX_TYPES_H) && \
+ !defined(_ASM_X86_64_POSIX_TYPES_H) && \
+ !defined(_ASM_X86_POSIX_TYPES_32_H) && \
+ !defined(_ASM_X86_POSIX_TYPES_64_H)
#define _ASM_X86_64_POSIX_TYPES_H
+#define __ARCH_I386_POSIX_TYPES_H
+#define _ASM_X86_POSIX_TYPES_32_H
+#define _ASM_X86_POSIX_TYPES_64_H
typedef unsigned long __kernel_dev_t;
typedef unsigned long __kernel_ino_t;
@@ -31,6 +40,8 @@ typedef unsigned int __kernel_gid32_t;
typedef unsigned short __kernel_old_uid_t;
typedef unsigned short __kernel_old_gid_t;
typedef __kernel_dev_t __kernel_old_dev_t;
+typedef long __kernel_long_t;
+typedef unsigned long __kernel_ulong_t;
typedef long long __kernel_loff_t;
typedef struct {
@@ -41,4 +52,4 @@ typedef struct {
#endif
} __kernel_fsid_t;
-#endif /* _ASM_X86_64_POSIX_TYPES_H */
+#endif
diff --git a/libc/sysdeps/linux/x86_64/bits/mathdef.h b/libc/sysdeps/linux/x86_64/bits/mathdef.h
index b0567e4d4..fc6524898 100644
--- a/libc/sysdeps/linux/x86_64/bits/mathdef.h
+++ b/libc/sysdeps/linux/x86_64/bits/mathdef.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#if !defined _MATH_H && !defined _COMPLEX_H
# error "Never use <bits/mathdef.h> directly; include <math.h> instead"
diff --git a/libc/sysdeps/linux/x86_64/bits/mathinline.h b/libc/sysdeps/linux/x86_64/bits/mathinline.h
index 39d11b678..d706ae4d0 100644
--- a/libc/sysdeps/linux/x86_64/bits/mathinline.h
+++ b/libc/sysdeps/linux/x86_64/bits/mathinline.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _MATH_H
# error "Never use <bits/mathinline.h> directly; include <math.h> instead."
@@ -25,7 +24,7 @@
#ifdef __cplusplus
# define __MATH_INLINE __inline
#else
-# define __MATH_INLINE extern __inline
+# define __MATH_INLINE __extern_inline
#endif
diff --git a/libc/sysdeps/linux/x86_64/bits/mman.h b/libc/sysdeps/linux/x86_64/bits/mman.h
index 535c9edcf..a0b7a0e97 100644
--- a/libc/sysdeps/linux/x86_64/bits/mman.h
+++ b/libc/sysdeps/linux/x86_64/bits/mman.h
@@ -1,104 +1,4 @@
-/* Definitions for POSIX memory map interface. Linux/x86_64 version.
- Copyright (C) 2001, 2003, 2005, 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 _SYS_MMAN_H
-# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
-#endif
-
-/* The following definitions basically come from the kernel headers.
- But the kernel header is not namespace clean. */
-
-
-/* Protections are chosen from these bits, OR'd together. The
- implementation does not necessarily support PROT_EXEC or PROT_WRITE
- without PROT_READ. The only guarantees are that no writing will be
- allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
-
-#define PROT_READ 0x1 /* Page can be read. */
-#define PROT_WRITE 0x2 /* Page can be written. */
-#define PROT_EXEC 0x4 /* Page can be executed. */
-#define PROT_NONE 0x0 /* Page can not be accessed. */
-#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of
- growsdown vma (mprotect only). */
-#define PROT_GROWSUP 0x02000000 /* Extend change to start of
- growsup vma (mprotect only). */
-
-/* Sharing types (must choose one and only one of these). */
-#define MAP_SHARED 0x01 /* Share changes. */
-#define MAP_PRIVATE 0x02 /* Changes are private. */
-#ifdef __USE_MISC
-# define MAP_TYPE 0x0f /* Mask for type of mapping. */
-#endif
-
-/* Other flags. */
-#define MAP_FIXED 0x10 /* Interpret addr exactly. */
#ifdef __USE_MISC
-# define MAP_FILE 0
-# define MAP_ANONYMOUS 0x20 /* Don't use a file. */
-# define MAP_ANON MAP_ANONYMOUS
# define MAP_32BIT 0x40 /* Only give out 32-bit addresses. */
#endif
-
-/* These are Linux-specific. */
-#ifdef __USE_MISC
-# define MAP_GROWSDOWN 0x00100 /* Stack-like segment. */
-# define MAP_DENYWRITE 0x00800 /* ETXTBSY */
-# define MAP_EXECUTABLE 0x01000 /* Mark it as an executable. */
-# define MAP_LOCKED 0x02000 /* Lock the mapping. */
-# define MAP_NORESERVE 0x04000 /* Don't check for reservations. */
-# define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */
-# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */
-#endif
-
-/* Flags to `msync'. */
-#define MS_ASYNC 1 /* Sync memory asynchronously. */
-#define MS_SYNC 4 /* Synchronous memory sync. */
-#define MS_INVALIDATE 2 /* Invalidate the caches. */
-
-/* Flags for `mlockall'. */
-#define MCL_CURRENT 1 /* Lock all currently mapped pages. */
-#define MCL_FUTURE 2 /* Lock all additions to address
- space. */
-
-/* Flags for `mremap'. */
-#ifdef __USE_GNU
-# define MREMAP_MAYMOVE 1
-# define MREMAP_FIXED 2
-#endif
-
-/* Advice to `madvise'. */
-#ifdef __USE_BSD
-# define MADV_NORMAL 0 /* No further special treatment. */
-# define MADV_RANDOM 1 /* Expect random page references. */
-# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
-# define MADV_WILLNEED 3 /* Will need these pages. */
-# define MADV_DONTNEED 4 /* Don't need these pages. */
-# define MADV_REMOVE 9 /* Remove these pages and resources. */
-# define MADV_DONTFORK 10 /* Do not inherit across fork. */
-# define MADV_DOFORK 11 /* Do inherit across fork. */
-#endif
-
-/* The POSIX people had to invent similar names for the same things. */
-#ifdef __USE_XOPEN2K
-# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
-# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
-# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
-# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
-# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
-#endif
+#include <bits/mman-common.h>
diff --git a/libc/sysdeps/linux/x86_64/bits/msq.h b/libc/sysdeps/linux/x86_64/bits/msq.h
index 422218a5f..838910713 100644
--- a/libc/sysdeps/linux/x86_64/bits/msq.h
+++ b/libc/sysdeps/linux/x86_64/bits/msq.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_MSG_H
# error "Never use <bits/msq.h> directly; include <sys/msg.h> instead."
diff --git a/libc/sysdeps/linux/x86_64/bits/sem.h b/libc/sysdeps/linux/x86_64/bits/sem.h
index 9b1d993ee..8c09031c7 100644
--- a/libc/sysdeps/linux/x86_64/bits/sem.h
+++ b/libc/sysdeps/linux/x86_64/bits/sem.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_SEM_H
# error "Never include <bits/sem.h> directly; use <sys/sem.h> instead."
diff --git a/libc/sysdeps/linux/x86_64/bits/setjmp.h b/libc/sysdeps/linux/x86_64/bits/setjmp.h
index 515d769be..9a2c12863 100644
--- a/libc/sysdeps/linux/x86_64/bits/setjmp.h
+++ b/libc/sysdeps/linux/x86_64/bits/setjmp.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2001,2002,2003,2005,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
@@ -12,13 +12,12 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* Define the machine-dependent type `jmp_buf'. x86-64 version. */
#ifndef _BITS_SETJMP_H
-#define _BITS_SETJMP_H 1
+#define _BITS_SETJMP_H 1
#if !defined _SETJMP_H && !defined _PTHREAD_H
# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
@@ -27,52 +26,9 @@
#include <bits/wordsize.h>
#if __WORDSIZE == 64
-
-/* We only need to save callee-saved registers plus stackpointer and
- program counter. */
-# if defined __USE_MISC || defined _ASM
-# define JB_RBX 0
-# define JB_RBP 1
-# define JB_R12 2
-# define JB_R13 3
-# define JB_R14 4
-# define JB_R15 5
-# define JB_RSP 6
-# define JB_PC 7
-# define JB_SIZE (8*8)
-# endif
-
-#else
-
-# if defined __USE_MISC || defined _ASM
-# define JB_BX 0
-# define JB_SI 1
-# define JB_DI 2
-# define JB_BP 3
-# define JB_SP 4
-# define JB_PC 5
-# define JB_SIZE 24
-# endif
-
-#endif
-
-#ifndef _ASM
-
-# if __WORDSIZE == 64
typedef long int __jmp_buf[8];
-# else
+#else
typedef int __jmp_buf[6];
-# endif
-
-/* Test if longjmp to JMPBUF would unwind the frame
- containing a local variable at ADDRESS. */
-# if __WORDSIZE == 64
-# define _JMPBUF_UNWINDS(jmpbuf, address) \
- ((void *) (address) < (void *) (jmpbuf)[JB_RSP])
-# else
-# define _JMPBUF_UNWINDS(jmpbuf, address) \
- ((void *) (address) < (void *) (jmpbuf)[JB_SP])
-# endif
#endif
-#endif /* bits/setjmp.h */
+#endif /* bits/setjmp.h */
diff --git a/libc/sysdeps/linux/x86_64/bits/shm.h b/libc/sysdeps/linux/x86_64/bits/shm.h
index 3d8c05d21..3a25de562 100644
--- a/libc/sysdeps/linux/x86_64/bits/shm.h
+++ b/libc/sysdeps/linux/x86_64/bits/shm.h
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_SHM_H
# error "Never include <bits/shm.h> directly; use <sys/shm.h> instead."
diff --git a/libc/sysdeps/linux/x86_64/bits/sigcontext.h b/libc/sysdeps/linux/x86_64/bits/sigcontext.h
index c0d5fe72d..197c14883 100644
--- a/libc/sysdeps/linux/x86_64/bits/sigcontext.h
+++ b/libc/sysdeps/linux/x86_64/bits/sigcontext.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _BITS_SIGCONTEXT_H
#define _BITS_SIGCONTEXT_H 1
diff --git a/libc/sysdeps/linux/x86_64/bits/sigcontextinfo.h b/libc/sysdeps/linux/x86_64/bits/sigcontextinfo.h
index 11493c580..1c4b89240 100644
--- a/libc/sysdeps/linux/x86_64/bits/sigcontextinfo.h
+++ b/libc/sysdeps/linux/x86_64/bits/sigcontextinfo.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#define SIGCONTEXT siginfo_t *_si, struct ucontext *
#define SIGCONTEXT_EXTRA_ARGS _si,
diff --git a/libc/sysdeps/linux/x86_64/bits/stackinfo.h b/libc/sysdeps/linux/x86_64/bits/stackinfo.h
index 60668d10b..2d50e7575 100644
--- a/libc/sysdeps/linux/x86_64/bits/stackinfo.h
+++ b/libc/sysdeps/linux/x86_64/bits/stackinfo.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* This file contains a bit of information about the stack allocation
of the processor. */
diff --git a/libc/sysdeps/linux/x86_64/bits/stat.h b/libc/sysdeps/linux/x86_64/bits/stat.h
index 3a9c7740a..e25f01521 100644
--- a/libc/sysdeps/linux/x86_64/bits/stat.h
+++ b/libc/sysdeps/linux/x86_64/bits/stat.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999,2000,2001,2002,2003 Free Software Foundation, Inc.
+/* Copyright (C) 1999,2000,2001,2002,2003,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
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_STAT_H
# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
@@ -61,7 +60,7 @@ struct stat
__uid_t st_uid; /* User ID of the file's owner. */
__gid_t st_gid; /* Group ID of the file's group.*/
#if __WORDSIZE == 64
- int pad0;
+ int __pad0;
#endif
__dev_t st_rdev; /* Device number, if device. */
#if __WORDSIZE == 32
@@ -78,7 +77,7 @@ struct stat
#else
__blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
#endif
-#if 0 /*def __USE_MISC*/
+#ifdef __USE_MISC
/* Nanosecond resolution timestamps are stored in a format
equivalent to 'struct timespec'. This is the type used
whenever possible but the Unix namespace rules do not allow the
@@ -129,7 +128,7 @@ struct stat64
__uid_t st_uid; /* User ID of the file's owner. */
__gid_t st_gid; /* Group ID of the file's group.*/
#if __WORDSIZE == 64
- int pad0;
+ int __pad0;
__dev_t st_rdev; /* Device number, if device. */
__off_t st_size; /* Size of file, in bytes. */
#else
@@ -139,7 +138,7 @@ struct stat64
#endif
__blksize_t st_blksize; /* Optimal block size for I/O. */
__blkcnt64_t st_blocks; /* Nr. 512-byte blocks allocated. */
-#if 0 /*def __USE_MISC*/
+#ifdef __USE_MISC
/* Nanosecond resolution timestamps are stored in a format
equivalent to 'struct timespec'. This is the type used
whenever possible but the Unix namespace rules do not allow the
@@ -201,3 +200,8 @@ struct stat64
#define __S_IREAD 0400 /* Read by owner. */
#define __S_IWRITE 0200 /* Write by owner. */
#define __S_IEXEC 0100 /* Execute by owner. */
+
+#ifdef __USE_ATFILE
+# define UTIME_NOW ((1l << 30) - 1l)
+# define UTIME_OMIT ((1l << 30) - 2l)
+#endif
diff --git a/libc/sysdeps/linux/x86_64/bits/syscalls.h b/libc/sysdeps/linux/x86_64/bits/syscalls.h
index 80f42596a..e4ea4d833 100644
--- a/libc/sysdeps/linux/x86_64/bits/syscalls.h
+++ b/libc/sysdeps/linux/x86_64/bits/syscalls.h
@@ -13,59 +13,6 @@
#include <errno.h>
-#define SYS_ify(syscall_name) (__NR_##syscall_name)
-
-#undef _syscall0
-#define _syscall0(type,name) \
-type name(void) \
-{ \
-return (type) (INLINE_SYSCALL(name, 0)); \
-}
-
-#undef _syscall1
-#define _syscall1(type,name,type1,arg1) \
-type name(type1 arg1) \
-{ \
-return (type) (INLINE_SYSCALL(name, 1, arg1)); \
-}
-
-#undef _syscall2
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name(type1 arg1,type2 arg2) \
-{ \
-return (type) (INLINE_SYSCALL(name, 2, arg1, arg2)); \
-}
-
-#undef _syscall3
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name(type1 arg1,type2 arg2,type3 arg3) \
-{ \
-return (type) (INLINE_SYSCALL(name, 3, arg1, arg2, arg3)); \
-}
-
-#undef _syscall4
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
-{ \
-return (type) (INLINE_SYSCALL(name, 4, arg1, arg2, arg3, arg4)); \
-}
-
-#undef _syscall5
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
- type5,arg5) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
-{ \
-return (type) (INLINE_SYSCALL(name, 5, arg1, arg2, arg3, arg4, arg5)); \
-}
-
-#undef _syscall6
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
- type5,arg5,type6,arg6) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
-{ \
-return (type) (INLINE_SYSCALL(name, 6, arg1, arg2, arg3, arg4, arg5, arg6)); \
-}
-
/* The Linux/x86-64 kernel expects the system call parameters in
registers according to the following table:
@@ -103,9 +50,6 @@ return (type) (INLINE_SYSCALL(name, 6, arg1, arg2, arg3, arg4, arg5, arg6)); \
Syscalls of more than 6 arguments are not supported. */
-#undef SYS_ify
-#define SYS_ify(syscall_name) __NR_##syscall_name
-
#undef DO_CALL
#define DO_CALL(syscall_name, args) \
DOARGS_##args \
@@ -122,41 +66,19 @@ return (type) (INLINE_SYSCALL(name, 6, arg1, arg2, arg3, arg4, arg5, arg6)); \
/* Define a macro which expands inline into the wrapper code for a system
call. */
-#undef INLINE_SYSCALL
-#define INLINE_SYSCALL(name, nr, args...) \
- ({ \
- unsigned long _resultvar = INTERNAL_SYSCALL (name, , nr, args); \
- if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (_resultvar, ), 0)) \
- { \
- __set_errno (INTERNAL_SYSCALL_ERRNO (_resultvar, )); \
- _resultvar = (unsigned long) -1; \
- } \
- (long) _resultvar; })
-
-#undef INTERNAL_SYSCALL_DECL
-#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
-
#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+(__extension__ \
({ \
unsigned long resultvar; \
LOAD_ARGS_##nr (args) \
LOAD_REGS_##nr \
- __asm__ __volatile__ ( \
+ __asm__ __volatile__ ( \
"syscall\n\t" \
: "=a" (resultvar) \
: "0" (name) ASM_ARGS_##nr : "memory", "cc", "r11", "cx"); \
- (long) resultvar; })
-#undef INTERNAL_SYSCALL
-#define INTERNAL_SYSCALL(name, err, nr, args...) \
- INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
-
-#undef INTERNAL_SYSCALL_ERROR_P
-#define INTERNAL_SYSCALL_ERROR_P(val, err) \
- ((unsigned long) (val) >= -4095L)
-
-#undef INTERNAL_SYSCALL_ERRNO
-#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
-
+ (long) resultvar; \
+ }) \
+)
#define LOAD_ARGS_0()
#define LOAD_REGS_0
#define ASM_ARGS_0
@@ -165,49 +87,49 @@ return (type) (INLINE_SYSCALL(name, 6, arg1, arg2, arg3, arg4, arg5, arg6)); \
long int __arg1 = (long) (a1); \
LOAD_ARGS_0 ()
#define LOAD_REGS_1 \
- register long int _a1 __asm__ ("rdi") = __arg1; \
+ register long int __a1 __asm__ ("rdi") = __arg1; \
LOAD_REGS_0
-#define ASM_ARGS_1 ASM_ARGS_0, "r" (_a1)
+#define ASM_ARGS_1 ASM_ARGS_0, "r" (__a1)
#define LOAD_ARGS_2(a1, a2) \
long int __arg2 = (long) (a2); \
LOAD_ARGS_1 (a1)
#define LOAD_REGS_2 \
- register long int _a2 __asm__ ("rsi") = __arg2; \
+ register long int __a2 __asm__ ("rsi") = __arg2; \
LOAD_REGS_1
-#define ASM_ARGS_2 ASM_ARGS_1, "r" (_a2)
+#define ASM_ARGS_2 ASM_ARGS_1, "r" (__a2)
#define LOAD_ARGS_3(a1, a2, a3) \
long int __arg3 = (long) (a3); \
LOAD_ARGS_2 (a1, a2)
#define LOAD_REGS_3 \
- register long int _a3 __asm__ ("rdx") = __arg3; \
+ register long int __a3 __asm__ ("rdx") = __arg3; \
LOAD_REGS_2
-#define ASM_ARGS_3 ASM_ARGS_2, "r" (_a3)
+#define ASM_ARGS_3 ASM_ARGS_2, "r" (__a3)
#define LOAD_ARGS_4(a1, a2, a3, a4) \
long int __arg4 = (long) (a4); \
LOAD_ARGS_3 (a1, a2, a3)
#define LOAD_REGS_4 \
- register long int _a4 __asm__ ("r10") = __arg4; \
+ register long int __a4 __asm__ ("r10") = __arg4; \
LOAD_REGS_3
-#define ASM_ARGS_4 ASM_ARGS_3, "r" (_a4)
+#define ASM_ARGS_4 ASM_ARGS_3, "r" (__a4)
#define LOAD_ARGS_5(a1, a2, a3, a4, a5) \
long int __arg5 = (long) (a5); \
LOAD_ARGS_4 (a1, a2, a3, a4)
#define LOAD_REGS_5 \
- register long int _a5 __asm__ ("r8") = __arg5; \
+ register long int __a5 __asm__ ("r8") = __arg5; \
LOAD_REGS_4
-#define ASM_ARGS_5 ASM_ARGS_4, "r" (_a5)
+#define ASM_ARGS_5 ASM_ARGS_4, "r" (__a5)
#define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6) \
long int __arg6 = (long) (a6); \
LOAD_ARGS_5 (a1, a2, a3, a4, a5)
#define LOAD_REGS_6 \
- register long int _a6 __asm__ ("r9") = __arg6; \
+ register long int __a6 __asm__ ("r9") = __arg6; \
LOAD_REGS_5
-#define ASM_ARGS_6 ASM_ARGS_5, "r" (_a6)
+#define ASM_ARGS_6 ASM_ARGS_5, "r" (__a6)
#endif /* __ASSEMBLER__ */
#endif /* _BITS_SYSCALLS_H */
diff --git a/libc/sysdeps/linux/x86_64/bits/uClibc_arch_features.h b/libc/sysdeps/linux/x86_64/bits/uClibc_arch_features.h
index e3e2c8332..43801699e 100644
--- a/libc/sysdeps/linux/x86_64/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/x86_64/bits/uClibc_arch_features.h
@@ -11,28 +11,31 @@
/* 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 align 64bit values in register pairs ? (32bit arches only) */
+#undef __UCLIBC_SYSCALL_ALIGN_64BIT__
/* 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 */
+#define __UCLIBC_HAVE_ASM_CFI_DIRECTIVES__
/* define if target supports IEEE signed zero floats */
#define __UCLIBC_HAVE_SIGNED_ZERO__
+/* only weird assemblers generally need this */
+#undef __UCLIBC_ASM_LINE_SEP__
+
#endif /* _BITS_UCLIBC_ARCH_FEATURES_H */
diff --git a/libc/sysdeps/linux/x86_64/bits/wordsize.h b/libc/sysdeps/linux/x86_64/bits/wordsize.h
index 0cce4ead9..9db982c90 100644
--- a/libc/sysdeps/linux/x86_64/bits/wordsize.h
+++ b/libc/sysdeps/linux/x86_64/bits/wordsize.h
@@ -1,8 +1,12 @@
/* Determine the wordsize from the preprocessor defines. */
-#if defined __x86_64__
+#if defined __x86_64__ && !defined __ILP32__
# define __WORDSIZE 64
-/*# define __WORDSIZE_COMPAT32 1*/
#else
# define __WORDSIZE 32
#endif
+
+#ifdef __x86_64__
+/* This makes /var/run/utmp compatible with 32-bit environment: */
+# define __WORDSIZE_TIME64_COMPAT32 1
+#endif
diff --git a/libc/sysdeps/linux/x86_64/brk.c b/libc/sysdeps/linux/x86_64/brk.c
index eddfd9830..66b34b527 100644
--- a/libc/sysdeps/linux/x86_64/brk.c
+++ b/libc/sysdeps/linux/x86_64/brk.c
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <errno.h>
#include <unistd.h>
@@ -24,20 +23,20 @@
/* This must be initialized data because commons can't have aliases. */
void *__curbrk attribute_hidden = 0;
-libc_hidden_proto(brk)
-int brk (void *addr)
+int brk(void *addr)
{
- void *__unbounded newbrk;
+ void *newbrk;
__asm__ ("syscall\n"
- : "=a" (newbrk)
- : "0" (__NR_brk), "D" (__ptrvalue (addr))
- : "r11","rcx","memory");
+ : "=a" (newbrk)
+ : "0" (__NR_brk), "D" (addr)
+ : "r11", "rcx"
+ );
__curbrk = newbrk;
if (newbrk < addr) {
- __set_errno (ENOMEM);
+ __set_errno(ENOMEM);
return -1;
}
diff --git a/libc/sysdeps/linux/x86_64/bsd-_setjmp.S b/libc/sysdeps/linux/x86_64/bsd-_setjmp.S
index 81a4352f3..7fd985958 100644
--- a/libc/sysdeps/linux/x86_64/bsd-_setjmp.S
+++ b/libc/sysdeps/linux/x86_64/bsd-_setjmp.S
@@ -13,17 +13,18 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* This just does a tail-call to `__sigsetjmp (ARG, 0)'.
We cannot do it in C because it must be a tail-call, so frame-unwinding
in setjmp doesn't clobber the state restored by longjmp. */
+#include <sysdep.h>
+
.global _setjmp
.type _setjmp,%function
_setjmp:
xorq %rsi, %rsi
- jmp __sigsetjmp@PLT
+ jmp HIDDEN_JUMPTARGET(__sigsetjmp)
.size _setjmp,.-_setjmp
diff --git a/libc/sysdeps/linux/x86_64/bsd-setjmp.S b/libc/sysdeps/linux/x86_64/bsd-setjmp.S
index a906a6132..1d3b8ee1f 100644
--- a/libc/sysdeps/linux/x86_64/bsd-setjmp.S
+++ b/libc/sysdeps/linux/x86_64/bsd-setjmp.S
@@ -13,17 +13,12 @@
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 _ASM
-#define _SETJMP_H
-#include <bits/setjmp.h>
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
.global setjmp
.type setjmp,%function
setjmp:
movq $1, %rsi
- jmp __sigsetjmp@PLT
+ jmp HIDDEN_JUMPTARGET(__sigsetjmp)
.size setjmp,.-setjmp
diff --git a/libc/sysdeps/linux/x86_64/clone.S b/libc/sysdeps/linux/x86_64/clone.S
index dc5eeb0a0..374504140 100644
--- a/libc/sysdeps/linux/x86_64/clone.S
+++ b/libc/sysdeps/linux/x86_64/clone.S
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* clone() is even more special than fork() as it mucks with stacks
and invokes a function in the right context after its all over. */
@@ -109,6 +108,8 @@ clone:
call *%rax
/* Call exit with return value from function call. */
movq %rax, %rdi
- call HIDDEN_JUMPTARGET(_exit)
+ movl $__NR_exit, %eax
+ syscall
.size clone,.-clone
+weak_alias(clone, __clone)
diff --git a/libc/sysdeps/linux/x86_64/crt1.S b/libc/sysdeps/linux/x86_64/crt1.S
index f6c1eb1e7..87777dd5d 100644
--- a/libc/sysdeps/linux/x86_64/crt1.S
+++ b/libc/sysdeps/linux/x86_64/crt1.S
@@ -31,9 +31,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* Originally based on glibc's sysdeps/x86_64/elf/start.S */
@@ -55,7 +54,9 @@
...
NULL
*/
-
+#if defined NOT_IN_libc
+# error error in build framework
+#endif
#include <features.h>
.text
diff --git a/libc/sysdeps/linux/x86_64/crtn.S b/libc/sysdeps/linux/x86_64/crtn.S
index 5b110d967..9804e0f76 100644
--- a/libc/sysdeps/linux/x86_64/crtn.S
+++ b/libc/sysdeps/linux/x86_64/crtn.S
@@ -7,7 +7,6 @@
.type _init, %function
addq $8, %rsp
ret
-.size _init,.-_init
.section .fini
@@ -15,4 +14,3 @@
.type _fini, %function
addq $8, %rsp
ret
-.size _fini, .-_fini
diff --git a/libc/sysdeps/linux/x86_64/fpu_control.h b/libc/sysdeps/linux/x86_64/fpu_control.h
index 6e9b3b362..2ff4edb53 100644
--- a/libc/sysdeps/linux/x86_64/fpu_control.h
+++ b/libc/sysdeps/linux/x86_64/fpu_control.h
@@ -14,9 +14,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FPU_CONTROL_H
#define _FPU_CONTROL_H 1
diff --git a/libc/sysdeps/linux/x86_64/getcontext.S b/libc/sysdeps/linux/x86_64/getcontext.S
new file mode 100644
index 000000000..dcebc4f29
--- /dev/null
+++ b/libc/sysdeps/linux/x86_64/getcontext.S
@@ -0,0 +1,88 @@
+/* Save current context.
+ Copyright (C) 2002-2012 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger <aj@suse.de>, 2002.
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+
+#include "ucontext_i.h"
+
+/* int __getcontext (ucontext_t *ucp)
+
+ Saves the machine context in UCP such that when it is activated,
+ it appears as if __getcontext() returned again.
+
+ This implementation is intended to be used for *synchronous* context
+ switches only. Therefore, it does not have to save anything
+ other than the PRESERVED state. */
+
+
+ENTRY(__getcontext)
+ /* Save the preserved registers, the registers used for passing
+ args, and the return address. */
+ movq %rbx, oRBX(%rdi)
+ movq %rbp, oRBP(%rdi)
+ movq %r12, oR12(%rdi)
+ movq %r13, oR13(%rdi)
+ movq %r14, oR14(%rdi)
+ movq %r15, oR15(%rdi)
+
+ movq %rdi, oRDI(%rdi)
+ movq %rsi, oRSI(%rdi)
+ movq %rdx, oRDX(%rdi)
+ movq %rcx, oRCX(%rdi)
+ movq %r8, oR8(%rdi)
+ movq %r9, oR9(%rdi)
+
+ movq (%rsp), %rcx
+ movq %rcx, oRIP(%rdi)
+ leaq 8(%rsp), %rcx /* Exclude the return address. */
+ movq %rcx, oRSP(%rdi)
+
+ /* We have separate floating-point register content memory on the
+ stack. We use the __fpregs_mem block in the context. Set the
+ links up correctly. */
+
+ leaq oFPREGSMEM(%rdi), %rcx
+ movq %rcx, oFPREGS(%rdi)
+ /* Save the floating-point environment. */
+ fnstenv (%rcx)
+ fldenv (%rcx)
+ stmxcsr oMXCSR(%rdi)
+
+ /* Save the current signal mask with
+ rt_sigprocmask (SIG_BLOCK, NULL, set,_NSIG/8). */
+ leaq oSIGMASK(%rdi), %rdx
+ xorl %esi,%esi
+#if SIG_BLOCK == 0
+ xorl %edi, %edi
+#else
+ movl $SIG_BLOCK, %edi
+#endif
+ movl $_NSIG8,%r10d
+ movl $__NR_rt_sigprocmask, %eax
+ syscall
+ cmpq $-4095, %rax /* Check %rax for error. */
+ jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
+
+ /* All done, return 0 for success. */
+ xorl %eax, %eax
+L(pseudo_end):
+ ret
+PSEUDO_END(__getcontext)
+
+weak_alias (__getcontext, getcontext)
diff --git a/libc/sysdeps/linux/x86_64/jmpbuf-offsets.h b/libc/sysdeps/linux/x86_64/jmpbuf-offsets.h
new file mode 100644
index 000000000..55f7c9719
--- /dev/null
+++ b/libc/sysdeps/linux/x86_64/jmpbuf-offsets.h
@@ -0,0 +1,45 @@
+/* Private macros for accessing __jmp_buf contents. x86-64 version.
+ Copyright (C) 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <bits/wordsize.h>
+
+#if __WORDSIZE == 64
+
+/* We only need to save callee-saved registers plus stackpointer and
+ program counter. */
+# define JB_RBX 0
+# define JB_RBP 1
+# define JB_R12 2
+# define JB_R13 3
+# define JB_R14 4
+# define JB_R15 5
+# define JB_RSP 6
+# define JB_PC 7
+# define JB_SIZE (8*8)
+
+#else
+
+# define JB_BX 0
+# define JB_SI 1
+# define JB_DI 2
+# define JB_BP 3
+# define JB_SP 4
+# define JB_PC 5
+# define JB_SIZE 24
+
+#endif
diff --git a/libc/sysdeps/linux/x86_64/jmpbuf-unwind.h b/libc/sysdeps/linux/x86_64/jmpbuf-unwind.h
new file mode 100644
index 000000000..152587222
--- /dev/null
+++ b/libc/sysdeps/linux/x86_64/jmpbuf-unwind.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+#include <setjmp.h>
+#include <jmpbuf-offsets.h>
+
+/* Test if longjmp to JMPBUF would unwind the frame
+ containing a local variable at ADDRESS. */
+#if __WORDSIZE == 64
+# define _JMPBUF_UNWINDS(jmpbuf, address) \
+ ((void *) (address) < (void *) (jmpbuf)[JB_RSP])
+#else
+# define _JMPBUF_UNWINDS(jmpbuf, address) \
+ ((void *) (address) < (void *) (jmpbuf)[JB_SP])
+#endif
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <stdint.h>
+#include <unwind.h>
+
+#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
+ _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
+
+#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
+ ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[JB_RSP] - (_adj))
+#endif
diff --git a/libc/sysdeps/linux/x86_64/makecontext.c b/libc/sysdeps/linux/x86_64/makecontext.c
new file mode 100644
index 000000000..54730312a
--- /dev/null
+++ b/libc/sysdeps/linux/x86_64/makecontext.c
@@ -0,0 +1,121 @@
+/* Create new context.
+ Copyright (C) 2002, 2004, 2005, 2008 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger <aj@suse.de>, 2002.
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <ucontext.h>
+
+#include "ucontext_i.h"
+
+/* This implementation can handle any ARGC value but only
+ normal integer parameters.
+ makecontext sets up a stack and the registers for the
+ user context. The stack looks like this:
+ +-----------------------+
+ | next context |
+ +-----------------------+
+ | parameter 7-n |
+ +-----------------------+
+ | trampoline address |
+ %rsp -> +-----------------------+
+
+ The registers are set up like this:
+ %rdi,%rsi,%rdx,%rcx,%r8,%r9: parameter 1 to 6
+ %rbx : address of next context
+ %rsp : stack pointer.
+*/
+
+/* XXX: This implementation currently only handles integer arguments.
+ To handle long int and pointer arguments the va_arg arguments needs
+ to be changed to long and also the stdlib/tst-setcontext.c file needs
+ to be changed to pass long arguments to makecontext. */
+
+
+void
+__makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...)
+{
+ extern void __start_context (void);
+ greg_t *sp;
+ unsigned int idx_uc_link;
+ va_list ap;
+ int i;
+
+ /* Generate room on stack for parameter if needed and uc_link. */
+ sp = (greg_t *) ((uintptr_t) ucp->uc_stack.ss_sp
+ + ucp->uc_stack.ss_size);
+ sp -= (argc > 6 ? argc - 6 : 0) + 1;
+ /* Align stack and make space for trampoline address. */
+ sp = (greg_t *) ((((uintptr_t) sp) & -16L) - 8);
+
+ idx_uc_link = (argc > 6 ? argc - 6 : 0) + 1;
+
+ /* Setup context ucp. */
+ /* Address to jump to. */
+ ucp->uc_mcontext.gregs[REG_RIP] = (uintptr_t) func;
+ /* Setup rbx.*/
+ ucp->uc_mcontext.gregs[REG_RBX] = (uintptr_t) &sp[idx_uc_link];
+ ucp->uc_mcontext.gregs[REG_RSP] = (uintptr_t) sp;
+
+ /* Setup stack. */
+ sp[0] = (uintptr_t) &__start_context;
+ sp[idx_uc_link] = (uintptr_t) ucp->uc_link;
+
+ va_start (ap, argc);
+ /* Handle arguments.
+
+ The standard says the parameters must all be int values. This is
+ an historic accident and would be done differently today. For
+ x86-64 all integer values are passed as 64-bit values and
+ therefore extending the API to copy 64-bit values instead of
+ 32-bit ints makes sense. It does not break existing
+ functionality and it does not violate the standard which says
+ that passing non-int values means undefined behavior. */
+ for (i = 0; i < argc; ++i)
+ switch (i)
+ {
+ case 0:
+ ucp->uc_mcontext.gregs[REG_RDI] = va_arg (ap, greg_t);
+ break;
+ case 1:
+ ucp->uc_mcontext.gregs[REG_RSI] = va_arg (ap, greg_t);
+ break;
+ case 2:
+ ucp->uc_mcontext.gregs[REG_RDX] = va_arg (ap, greg_t);
+ break;
+ case 3:
+ ucp->uc_mcontext.gregs[REG_RCX] = va_arg (ap, greg_t);
+ break;
+ case 4:
+ ucp->uc_mcontext.gregs[REG_R8] = va_arg (ap, greg_t);
+ break;
+ case 5:
+ ucp->uc_mcontext.gregs[REG_R9] = va_arg (ap, greg_t);
+ break;
+ default:
+ /* Put value on stack. */
+ sp[i - 5] = va_arg (ap, greg_t);
+ break;
+ }
+ va_end (ap);
+
+}
+
+
+weak_alias (__makecontext, makecontext)
diff --git a/libc/sysdeps/linux/x86_64/mmap.c b/libc/sysdeps/linux/x86_64/mmap.c
deleted file mode 100644
index baaee6847..000000000
--- a/libc/sysdeps/linux/x86_64/mmap.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * mmap() for uClibc/x86_64
- *
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- * Copyright (C) 2005 by Mike Frysinger <vapier@gentoo.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-#include <errno.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <sys/syscall.h>
-
-libc_hidden_proto(mmap)
-
-_syscall6(void *, mmap, void *, start, size_t, length, int, prot,
- int, flags, int, fd, off_t, offset);
-libc_hidden_def(mmap)
diff --git a/libc/sysdeps/linux/x86_64/sched_getcpu.S b/libc/sysdeps/linux/x86_64/sched_getcpu.S
new file mode 100644
index 000000000..f8c09c0f2
--- /dev/null
+++ b/libc/sysdeps/linux/x86_64/sched_getcpu.S
@@ -0,0 +1,71 @@
+/* Copyright (C) 2007, 2011 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#include <tls.h>
+#define _ERRNO_H 1
+#include <bits/errno.h>
+#include <bits/kernel-features.h>
+
+/* For the calculation see asm/vsyscall.h. */
+#define VSYSCALL_ADDR_vgetcpu 0xffffffffff600800
+
+
+ENTRY (sched_getcpu)
+ /* Align stack and create local variable for result. */
+ sub $0x8, %rsp
+ cfi_adjust_cfa_offset(8)
+
+ movq %rsp, %rdi
+ xorl %esi, %esi
+ movl $VGETCPU_CACHE_OFFSET, %edx
+ addq %fs:0, %rdx
+
+#ifdef SHARED
+ movq __vdso_getcpu(%rip), %rax
+ PTR_DEMANGLE (%rax)
+ callq *%rax
+#else
+# ifdef __NR_getcpu
+ movl $__NR_getcpu, %eax
+ syscall
+# ifndef __ASSUME_GETCPU_SYSCALL
+ cmpq $-ENOSYS, %rax
+ jne 1f
+# endif
+# endif
+# ifndef __ASSUME_GETCPU_SYSCALL
+ movq $VSYSCALL_ADDR_vgetcpu, %rax
+ callq *%rax
+1:
+# else
+# ifndef __NR_getcpu
+# error "cannot happen"
+# endif
+# endif
+#endif
+
+ cmpq $-4095, %rax
+ jae SYSCALL_ERROR_LABEL
+
+ movl (%rsp), %eax
+
+L(pseudo_end):
+ add $0x8, %rsp
+ cfi_adjust_cfa_offset(-8)
+ ret
+PSEUDO_END(sched_getcpu)
diff --git a/libc/sysdeps/linux/x86_64/setcontext.S b/libc/sysdeps/linux/x86_64/setcontext.S
new file mode 100644
index 000000000..561ab9f75
--- /dev/null
+++ b/libc/sysdeps/linux/x86_64/setcontext.S
@@ -0,0 +1,103 @@
+/* Install given context.
+ Copyright (C) 2002-2012 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger <aj@suse.de>, 2002.
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+
+#include "ucontext_i.h"
+
+
+/* int __setcontext (const ucontext_t *ucp)
+
+ Restores the machine context in UCP and thereby resumes execution
+ in that context.
+
+ This implementation is intended to be used for *synchronous* context
+ switches only. Therefore, it does not have to restore anything
+ other than the PRESERVED state. */
+
+ENTRY(__setcontext)
+ /* Save argument since syscall will destroy it. */
+ pushq %rdi
+ cfi_adjust_cfa_offset(8)
+
+ /* Set the signal mask with
+ rt_sigprocmask (SIG_SETMASK, mask, NULL, _NSIG/8). */
+ leaq oSIGMASK(%rdi), %rsi
+ xorl %edx, %edx
+ movl $SIG_SETMASK, %edi
+ movl $_NSIG8,%r10d
+ movl $__NR_rt_sigprocmask, %eax
+ syscall
+ popq %rdi /* Reload %rdi, adjust stack. */
+ cfi_adjust_cfa_offset(-8)
+ cmpq $-4095, %rax /* Check %rax for error. */
+ jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
+
+ /* Restore the floating-point context. Not the registers, only the
+ rest. */
+ movq oFPREGS(%rdi), %rcx
+ fldenv (%rcx)
+ ldmxcsr oMXCSR(%rdi)
+
+
+ /* Load the new stack pointer, the preserved registers and
+ registers used for passing args. */
+ cfi_def_cfa(%rdi, 0)
+ cfi_offset(%rbx,oRBX)
+ cfi_offset(%rbp,oRBP)
+ cfi_offset(%r12,oR12)
+ cfi_offset(%r13,oR13)
+ cfi_offset(%r14,oR14)
+ cfi_offset(%r15,oR15)
+ cfi_offset(%rsp,oRSP)
+ cfi_offset(%rip,oRIP)
+
+ movq oRSP(%rdi), %rsp
+ movq oRBX(%rdi), %rbx
+ movq oRBP(%rdi), %rbp
+ movq oR12(%rdi), %r12
+ movq oR13(%rdi), %r13
+ movq oR14(%rdi), %r14
+ movq oR15(%rdi), %r15
+
+ /* The following ret should return to the address set with
+ getcontext. Therefore push the address on the stack. */
+ movq oRIP(%rdi), %rcx
+ pushq %rcx
+
+ movq oRSI(%rdi), %rsi
+ movq oRDX(%rdi), %rdx
+ movq oRCX(%rdi), %rcx
+ movq oR8(%rdi), %r8
+ movq oR9(%rdi), %r9
+
+ /* Setup finally %rdi. */
+ movq oRDI(%rdi), %rdi
+
+ /* End FDE here, we fall into another context. */
+ cfi_endproc
+ cfi_startproc
+
+ /* Clear rax to indicate success. */
+ xorl %eax, %eax
+L(pseudo_end):
+ ret
+PSEUDO_END(__setcontext)
+
+weak_alias (__setcontext, setcontext)
diff --git a/libc/sysdeps/linux/x86_64/setjmp.S b/libc/sysdeps/linux/x86_64/setjmp.S
index eb4b97363..648946f54 100644
--- a/libc/sysdeps/linux/x86_64/setjmp.S
+++ b/libc/sysdeps/linux/x86_64/setjmp.S
@@ -13,13 +13,10 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
-#define _ASM
-#define _SETJMP_H
-#include <bits/setjmp.h>
+#include <jmpbuf-offsets.h>
.global __sigsetjmp
.type __sigsetjmp,%function
@@ -43,3 +40,4 @@ __sigsetjmp:
jmp __sigjmp_save
#endif
.size __sigsetjmp,.-__sigsetjmp
+libc_hidden_def(__sigsetjmp)
diff --git a/libc/sysdeps/linux/x86_64/sigaction.c b/libc/sysdeps/linux/x86_64/sigaction.c
index aa5c0d472..a4042a9c8 100644
--- a/libc/sysdeps/linux/x86_64/sigaction.c
+++ b/libc/sysdeps/linux/x86_64/sigaction.c
@@ -13,9 +13,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <errno.h>
@@ -25,90 +24,64 @@
#include <sys/syscall.h>
-/* The difference here is that the sigaction structure used in the
- kernel is not the same as we use in the libc. Therefore we must
- translate it here. */
#include <bits/kernel_sigaction.h>
/* We do not globally define the SA_RESTORER flag so do it here. */
#define SA_RESTORER 0x04000000
-extern __typeof(sigaction) __libc_sigaction;
-
#ifdef __NR_rt_sigaction
+
/* Using the hidden attribute here does not change the code but it
helps to avoid warnings. */
-extern void restore_rt (void) __asm__ ("__restore_rt") attribute_hidden;
-extern void restore (void) __asm__ ("__restore") attribute_hidden;
-
-/* Experimentally off - libc_hidden_proto(memcpy) */
+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)
+__libc_sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
{
- int result;
- struct kernel_sigaction kact, koact;
+ struct sigaction kact;
if (act) {
- kact.k_sa_handler = act->sa_handler;
- memcpy (&kact.sa_mask, &act->sa_mask, sizeof (sigset_t));
- kact.sa_flags = act->sa_flags | SA_RESTORER;
-
+ memcpy(&kact, act, sizeof(kact));
+ kact.sa_flags |= SA_RESTORER;
kact.sa_restorer = &restore_rt;
+ act = &kact;
}
-
- /* XXX The size argument hopefully will have to be changed to the
- real size of the user-level sigset_t. */
- result = INLINE_SYSCALL (rt_sigaction, 4,
- 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 (sigset_t));
- oact->sa_flags = koact.sa_flags;
- oact->sa_restorer = koact.sa_restorer;
- }
- return result;
+ /* NB: kernel (as of 2.6.25) will return EINVAL
+ * if sizeof(act->sa_mask) does not match kernel's sizeof(sigset_t) */
+ return INLINE_SYSCALL(rt_sigaction, 4, sig, act, oact, sizeof(act->sa_mask));
}
+
#else
-extern void restore (void) __asm__ ("__restore") 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)
+__libc_sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
{
int result;
struct old_kernel_sigaction kact, koact;
-#ifdef SIGCANCEL
- if (sig == SIGCANCEL) {
- __set_errno (EINVAL);
- return -1;
- }
-#endif
-
if (act) {
kact.k_sa_handler = act->sa_handler;
kact.sa_mask = act->sa_mask.__val[0];
kact.sa_flags = act->sa_flags | SA_RESTORER;
kact.sa_restorer = &restore;
}
-
- __asm__ __volatile__ ("syscall\n"
- : "=a" (result)
- : "0" (__NR_sigaction), "mr" (sig),
- "c" (act ? __ptrvalue (&kact) : 0),
- "d" (oact ? __ptrvalue (&koact) : 0));
-
+ __asm__ __volatile__ (
+ "syscall\n"
+ : "=a" (result)
+ : "0" (__NR_sigaction), "mr" (sig),
+ "c" (act ? &kact : NULL),
+ "d" (oact ? &koact : NULL));
if (result < 0) {
__set_errno(-result);
return -1;
}
-
if (oact) {
oact->sa_handler = koact.k_sa_handler;
oact->sa_mask.__val[0] = koact.sa_mask;
@@ -117,34 +90,50 @@ __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
}
return result;
}
+
#endif
+
#ifndef LIBC_SIGACTION
-libc_hidden_proto(sigaction)
+# ifndef __UCLIBC_HAS_THREADS__
+strong_alias(__libc_sigaction,sigaction)
+libc_hidden_def(sigaction)
+# else
weak_alias(__libc_sigaction,sigaction)
libc_hidden_weak(sigaction)
+# endif
#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_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" \
- "__" #name ":\n" \
- " movq $" #syscall ", %rax\n" \
- " syscall\n" \
- );
+ appropriate GDB maintainer.
+
+ The unwind information starts a byte before __restore_rt, so that
+ it is found when unwinding, to get an address the unwinder assumes
+ will be in the middle of a call instruction. See the Linux kernel
+ (the i386 vsyscall, in particular) for an explanation of the complex
+ unwind information used here in order to get the traditional CFA.
+ */
+
+#define RESTORE(name, syscall) RESTORE2(name, syscall)
+#define RESTORE2(name, syscall) \
+__asm__ ( \
+ "nop\n" \
+ ".text\n" \
+ "__" #name ":\n" \
+ " movq $" #syscall ", %rax\n" \
+ " syscall\n" \
+);
+
#ifdef __NR_rt_sigaction
/* The return code for realtime-signals. */
-RESTORE (restore_rt, __NR_rt_sigreturn)
+RESTORE(restore_rt, __NR_rt_sigreturn)
#endif
#ifdef __NR_sigreturn
-RESTORE (restore, __NR_sigreturn)
+RESTORE(restore, __NR_sigreturn)
#endif
diff --git a/libc/sysdeps/linux/x86_64/swapcontext.S b/libc/sysdeps/linux/x86_64/swapcontext.S
new file mode 100644
index 000000000..6d2ebb823
--- /dev/null
+++ b/libc/sysdeps/linux/x86_64/swapcontext.S
@@ -0,0 +1,121 @@
+/* Save current context and install the given one.
+ Copyright (C) 2002-2012 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger <aj@suse.de>, 2002.
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+
+#include "ucontext_i.h"
+
+
+/* int __swapcontext (ucontext_t *oucp, const ucontext_t *ucp);
+
+ Saves the machine context in oucp such that when it is activated,
+ it appears as if __swapcontextt() returned again, restores the
+ machine context in ucp and thereby resumes execution in that
+ context.
+
+ This implementation is intended to be used for *synchronous* context
+ switches only. Therefore, it does not have to save anything
+ other than the PRESERVED state. */
+
+ENTRY(__swapcontext)
+ /* Save the preserved registers, the registers used for passing args,
+ and the return address. */
+ movq %rbx, oRBX(%rdi)
+ movq %rbp, oRBP(%rdi)
+ movq %r12, oR12(%rdi)
+ movq %r13, oR13(%rdi)
+ movq %r14, oR14(%rdi)
+ movq %r15, oR15(%rdi)
+
+ movq %rdi, oRDI(%rdi)
+ movq %rsi, oRSI(%rdi)
+ movq %rdx, oRDX(%rdi)
+ movq %rcx, oRCX(%rdi)
+ movq %r8, oR8(%rdi)
+ movq %r9, oR9(%rdi)
+
+ movq (%rsp), %rcx
+ movq %rcx, oRIP(%rdi)
+ leaq 8(%rsp), %rcx /* Exclude the return address. */
+ movq %rcx, oRSP(%rdi)
+
+ /* We have separate floating-point register content memory on the
+ stack. We use the __fpregs_mem block in the context. Set the
+ links up correctly. */
+ leaq oFPREGSMEM(%rdi), %rcx
+ movq %rcx, oFPREGS(%rdi)
+ /* Save the floating-point environment. */
+ fnstenv (%rcx)
+ stmxcsr oMXCSR(%rdi)
+
+
+ /* The syscall destroys some registers, save them. */
+ movq %rsi, %r12
+
+ /* Save the current signal mask and install the new one with
+ rt_sigprocmask (SIG_BLOCK, newset, oldset,_NSIG/8). */
+ leaq oSIGMASK(%rdi), %rdx
+ leaq oSIGMASK(%rsi), %rsi
+ movl $SIG_SETMASK, %edi
+ movl $_NSIG8,%r10d
+ movl $__NR_rt_sigprocmask, %eax
+ syscall
+ cmpq $-4095, %rax /* Check %rax for error. */
+ jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
+
+ /* Restore destroyed registers. */
+ movq %r12, %rsi
+
+ /* Restore the floating-point context. Not the registers, only the
+ rest. */
+ movq oFPREGS(%rsi), %rcx
+ fldenv (%rcx)
+ ldmxcsr oMXCSR(%rsi)
+
+ /* Load the new stack pointer and the preserved registers. */
+ movq oRSP(%rsi), %rsp
+ movq oRBX(%rsi), %rbx
+ movq oRBP(%rsi), %rbp
+ movq oR12(%rsi), %r12
+ movq oR13(%rsi), %r13
+ movq oR14(%rsi), %r14
+ movq oR15(%rsi), %r15
+
+ /* The following ret should return to the address set with
+ getcontext. Therefore push the address on the stack. */
+ movq oRIP(%rsi), %rcx
+ pushq %rcx
+
+ /* Setup registers used for passing args. */
+ movq oRDI(%rsi), %rdi
+ movq oRDX(%rsi), %rdx
+ movq oRCX(%rsi), %rcx
+ movq oR8(%rsi), %r8
+ movq oR9(%rsi), %r9
+
+ /* Setup finally %rsi. */
+ movq oRSI(%rsi), %rsi
+
+ /* Clear rax to indicate success. */
+ xorl %eax, %eax
+L(pseudo_end):
+ ret
+PSEUDO_END(__swapcontext)
+
+weak_alias (__swapcontext, swapcontext)
diff --git a/libc/sysdeps/linux/x86_64/sys/debugreg.h b/libc/sysdeps/linux/x86_64/sys/debugreg.h
index 8abbf7546..170431ed0 100644
--- a/libc/sysdeps/linux/x86_64/sys/debugreg.h
+++ b/libc/sysdeps/linux/x86_64/sys/debugreg.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_DEBUGREG_H
#define _SYS_DEBUGREG_H 1
diff --git a/libc/sysdeps/linux/x86_64/sys/epoll.h b/libc/sysdeps/linux/x86_64/sys/epoll.h
deleted file mode 100644
index 02672d3c7..000000000
--- a/libc/sysdeps/linux/x86_64/sys/epoll.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/* Copyright (C) 2002,2003,2004,2005,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 _SYS_EPOLL_H
-#define _SYS_EPOLL_H 1
-
-#include <stdint.h>
-#include <sys/types.h>
-
-
-enum EPOLL_EVENTS
- {
- EPOLLIN = 0x001,
-#define EPOLLIN EPOLLIN
- EPOLLPRI = 0x002,
-#define EPOLLPRI EPOLLPRI
- EPOLLOUT = 0x004,
-#define EPOLLOUT EPOLLOUT
- EPOLLRDNORM = 0x040,
-#define EPOLLRDNORM EPOLLRDNORM
- EPOLLRDBAND = 0x080,
-#define EPOLLRDBAND EPOLLRDBAND
- EPOLLWRNORM = 0x100,
-#define EPOLLWRNORM EPOLLWRNORM
- EPOLLWRBAND = 0x200,
-#define EPOLLWRBAND EPOLLWRBAND
- EPOLLMSG = 0x400,
-#define EPOLLMSG EPOLLMSG
- EPOLLERR = 0x008,
-#define EPOLLERR EPOLLERR
- EPOLLHUP = 0x010,
-#define EPOLLHUP EPOLLHUP
- EPOLLONESHOT = (1 << 30),
-#define EPOLLONESHOT EPOLLONESHOT
- EPOLLET = (1 << 31)
-#define EPOLLET EPOLLET
- };
-
-
-/* Valid opcodes ( "op" parameter ) to issue to epoll_ctl(). */
-#define EPOLL_CTL_ADD 1 /* Add a file decriptor to the interface. */
-#define EPOLL_CTL_DEL 2 /* Remove a file decriptor from the interface. */
-#define EPOLL_CTL_MOD 3 /* Change file decriptor epoll_event structure. */
-
-
-typedef union epoll_data
-{
- void *ptr;
- int fd;
- uint32_t u32;
- uint64_t u64;
-} epoll_data_t;
-
-struct epoll_event
-{
- uint32_t events; /* Epoll events */
- epoll_data_t data; /* User data variable */
-} __attribute__ ((__packed__));
-
-
-__BEGIN_DECLS
-
-/* Creates an epoll instance. Returns an fd for the new instance.
- The "size" parameter is a hint specifying the number of file
- descriptors to be associated with the new instance. The fd
- returned by epoll_create() should be closed with close(). */
-extern int epoll_create (int __size) __THROW;
-
-
-/* Manipulate an epoll instance "epfd". Returns 0 in case of success,
- -1 in case of error ( the "errno" variable will contain the
- specific error code ) The "op" parameter is one of the EPOLL_CTL_*
- constants defined above. The "fd" parameter is the target of the
- operation. The "event" parameter describes which events the caller
- is interested in and any associated user data. */
-extern int epoll_ctl (int __epfd, int __op, int __fd,
- struct epoll_event *__event) __THROW;
-
-
-/* Wait for events on an epoll instance "epfd". Returns the number of
- triggered events returned in "events" buffer. Or -1 in case of
- error with the "errno" variable set to the specific error code. The
- "events" parameter is a buffer that will contain triggered
- events. The "maxevents" is the maximum number of events to be
- returned ( usually size of "events" ). The "timeout" parameter
- specifies the maximum wait time in milliseconds (-1 == infinite).
-
- This function is a cancellation point and therefore not marked with
- __THROW. */
-extern int epoll_wait (int __epfd, struct epoll_event *__events,
- int __maxevents, int __timeout);
-
-__END_DECLS
-
-#endif /* sys/epoll.h */
diff --git a/libc/sysdeps/linux/x86_64/sys/io.h b/libc/sysdeps/linux/x86_64/sys/io.h
index 802a0dfb4..7a65a16a8 100644
--- a/libc/sysdeps/linux/x86_64/sys/io.h
+++ b/libc/sysdeps/linux/x86_64/sys/io.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_IO_H
#define _SYS_IO_H 1
@@ -23,6 +22,7 @@
__BEGIN_DECLS
+#if defined __UCLIBC_LINUX_SPECIFIC__
/* If TURN_ON is TRUE, request for permission to do direct i/o on the
port numbers in the range [FROM,FROM+NUM-1]. Otherwise, turn I/O
permission off for that range. This call requires root privileges.
@@ -37,6 +37,7 @@ extern int ioperm (unsigned long int __from, unsigned long int __num,
access any I/O port is granted. This call requires root
privileges. */
extern int iopl (int __level) __THROW;
+#endif /* __UCLIBC_LINUX_SPECIFIC__ */
#if defined __GNUC__ && __GNUC__ >= 2
diff --git a/libc/sysdeps/linux/x86_64/sys/perm.h b/libc/sysdeps/linux/x86_64/sys/perm.h
index 382fa92ee..cbfeaf825 100644
--- a/libc/sysdeps/linux/x86_64/sys/perm.h
+++ b/libc/sysdeps/linux/x86_64/sys/perm.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_PERM_H
diff --git a/libc/sysdeps/linux/x86_64/sys/procfs.h b/libc/sysdeps/linux/x86_64/sys/procfs.h
index 5995b7115..fd2960169 100644
--- a/libc/sysdeps/linux/x86_64/sys/procfs.h
+++ b/libc/sysdeps/linux/x86_64/sys/procfs.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_PROCFS_H
#define _SYS_PROCFS_H 1
diff --git a/libc/sysdeps/linux/x86_64/sys/reg.h b/libc/sysdeps/linux/x86_64/sys/reg.h
index 865e34559..0718e1fca 100644
--- a/libc/sysdeps/linux/x86_64/sys/reg.h
+++ b/libc/sysdeps/linux/x86_64/sys/reg.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_REG_H
#define _SYS_REG_H 1
diff --git a/libc/sysdeps/linux/x86_64/sys/ucontext.h b/libc/sysdeps/linux/x86_64/sys/ucontext.h
index b59cd292f..a39762058 100644
--- a/libc/sysdeps/linux/x86_64/sys/ucontext.h
+++ b/libc/sysdeps/linux/x86_64/sys/ucontext.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_UCONTEXT_H
#define _SYS_UCONTEXT_H 1
diff --git a/libc/sysdeps/linux/x86_64/sys/user.h b/libc/sysdeps/linux/x86_64/sys/user.h
index 5ff68e575..9d0bd8d96 100644
--- a/libc/sysdeps/linux/x86_64/sys/user.h
+++ b/libc/sysdeps/linux/x86_64/sys/user.h
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_USER_H
#define _SYS_USER_H 1
diff --git a/libc/sysdeps/linux/x86_64/syscall.S b/libc/sysdeps/linux/x86_64/syscall.S
index ee223e3e6..5c92dc34f 100644
--- a/libc/sysdeps/linux/x86_64/syscall.S
+++ b/libc/sysdeps/linux/x86_64/syscall.S
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* Please consult the file sysdeps/unix/sysv/linux/x86-64/sysdep.h for
more information about the value -4095 used below. */
diff --git a/libc/sysdeps/linux/x86_64/sysdep.h b/libc/sysdeps/linux/x86_64/sysdep.h
new file mode 100644
index 000000000..3bfeaca50
--- /dev/null
+++ b/libc/sysdeps/linux/x86_64/sysdep.h
@@ -0,0 +1,330 @@
+/* Copyright (C) 2001-2005, 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _LINUX_X86_64_SYSDEP_H
+#define _LINUX_X86_64_SYSDEP_H 1
+
+/* There is some commonality. */
+#include <sys/syscall.h>
+#include <common/sysdep.h>
+
+#ifdef __ASSEMBLER__
+
+/* Syntactic details of assembler. */
+
+/* ELF uses byte-counts for .align, most others use log2 of count of bytes. */
+#define ALIGNARG(log2) 1<<log2
+/* For ELF we need the `.type' directive to make shared libs work right. */
+#define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg;
+#define ASM_SIZE_DIRECTIVE(name) .size name,.-name;
+
+/* In ELF C symbols are asm symbols. */
+#undef NO_UNDERSCORES
+#define NO_UNDERSCORES
+
+/* Define an entry point visible from C. */
+#define ENTRY(name) \
+ .globl C_SYMBOL_NAME(name); \
+ ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
+ .align ALIGNARG(4); \
+ C_LABEL(name) \
+ cfi_startproc; \
+ CALL_MCOUNT
+
+#undef END
+#define END(name) \
+ cfi_endproc; \
+ ASM_SIZE_DIRECTIVE(name)
+
+/* If compiled for profiling, call `mcount' at the start of each function. */
+#ifdef PROF
+/* The mcount code relies on a normal frame pointer being on the stack
+ to locate our caller, so push one just for its benefit. */
+#define CALL_MCOUNT \
+ pushq %rbp; \
+ cfi_adjust_cfa_offset(8); \
+ movq %rsp, %rbp; \
+ cfi_def_cfa_register(%rbp); \
+ call JUMPTARGET(mcount); \
+ popq %rbp; \
+ cfi_def_cfa(rsp,8);
+#else
+#define CALL_MCOUNT /* Do nothing. */
+#endif
+
+#ifdef NO_UNDERSCORES
+/* Since C identifiers are not normally prefixed with an underscore
+ on this system, the asm identifier `syscall_error' intrudes on the
+ C name space. Make sure we use an innocuous name. */
+#define syscall_error __syscall_error
+#define mcount _mcount
+#endif
+
+#define PSEUDO(name, syscall_name, args) \
+lose: \
+ jmp JUMPTARGET(syscall_error) \
+ .globl syscall_error; \
+ ENTRY (name) \
+ DO_CALL (syscall_name, args); \
+ jb lose
+
+#undef PSEUDO_END
+#define PSEUDO_END(name) \
+ END (name)
+
+#undef JUMPTARGET
+#ifdef __PIC__
+#define JUMPTARGET(name) name##@PLT
+#else
+#define JUMPTARGET(name) name
+#endif
+
+/* Local label name for asm code. */
+#ifndef L
+#define L(name) .L##name
+#endif
+
+#endif /* __ASSEMBLER__ */
+
+/* For Linux we can use the system call table in the header file
+ /usr/include/asm/unistd.h
+ of the kernel. But these symbols do not follow the SYS_* syntax
+ so we have to redefine the `SYS_ify' macro here. */
+#undef SYS_ify
+#define SYS_ify(syscall_name) __NR_##syscall_name
+
+/* This is a kludge to make syscalls.list find these under the names
+ pread and pwrite, since some kernel headers define those names
+ and some define the *64 names for the same system calls. */
+#if !defined __NR_pread && defined __NR_pread64
+# define __NR_pread __NR_pread64
+#endif
+#if !defined __NR_pwrite && defined __NR_pwrite64
+# define __NR_pwrite __NR_pwrite64
+#endif
+
+/* This is to help the old kernel headers where __NR_semtimedop is not
+ available. */
+#ifndef __NR_semtimedop
+# define __NR_semtimedop 220
+#endif
+
+
+#ifdef __ASSEMBLER__
+
+/* Linux uses a negative return value to indicate syscall errors,
+ unlike most Unices, which use the condition codes' carry flag.
+
+ Since version 2.1 the return value of a system call might be
+ negative even if the call succeeded. E.g., the `lseek' system call
+ might return a large offset. Therefore we must not anymore test
+ for < 0, but test for a real error by making sure the value in %eax
+ is a real error number. Linus said he will make sure the no syscall
+ returns a value in -1 .. -4095 as a valid result so we can savely
+ test with -4095. */
+
+/* We don't want the label for the error handle to be global when we define
+ it here. */
+# ifdef __PIC__
+# define SYSCALL_ERROR_LABEL 0f
+# else
+# define SYSCALL_ERROR_LABEL syscall_error
+# endif
+
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .text; \
+ ENTRY (name) \
+ DO_CALL (syscall_name, args); \
+ cmpq $-4095, %rax; \
+ jae SYSCALL_ERROR_LABEL; \
+ L(pseudo_end):
+
+# undef PSEUDO_END
+# define PSEUDO_END(name) \
+ SYSCALL_ERROR_HANDLER \
+ END (name)
+
+# undef PSEUDO_NOERRNO
+# define PSEUDO_NOERRNO(name, syscall_name, args) \
+ .text; \
+ ENTRY (name) \
+ DO_CALL (syscall_name, args)
+
+# undef PSEUDO_END_NOERRNO
+# define PSEUDO_END_NOERRNO(name) \
+ END (name)
+
+# define ret_NOERRNO ret
+
+# undef PSEUDO_ERRVAL
+# define PSEUDO_ERRVAL(name, syscall_name, args) \
+ .text; \
+ ENTRY (name) \
+ DO_CALL (syscall_name, args); \
+ negq %rax
+
+# undef PSEUDO_END_ERRVAL
+# define PSEUDO_END_ERRVAL(name) \
+ END (name)
+
+# ifndef __PIC__
+# define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */
+# elif defined(RTLD_PRIVATE_ERRNO)
+# define SYSCALL_ERROR_HANDLER \
+0: \
+ leaq rtld_errno(%rip), %rcx; \
+ xorl %edx, %edx; \
+ subq %rax, %rdx; \
+ movl %edx, (%rcx); \
+ orq $-1, %rax; \
+ jmp L(pseudo_end);
+# elif USE___THREAD
+# ifndef NOT_IN_libc
+# define SYSCALL_ERROR_ERRNO __libc_errno
+# else
+# define SYSCALL_ERROR_ERRNO errno
+# endif
+# define SYSCALL_ERROR_HANDLER \
+0: \
+ movq SYSCALL_ERROR_ERRNO@GOTTPOFF(%rip), %rcx;\
+ xorl %edx, %edx; \
+ subq %rax, %rdx; \
+ movl %edx, %fs:(%rcx); \
+ orq $-1, %rax; \
+ jmp L(pseudo_end);
+# elif defined _LIBC_REENTRANT
+/* Store (- %rax) into errno through the GOT.
+ Note that errno occupies only 4 bytes. */
+# define SYSCALL_ERROR_HANDLER \
+0: \
+ xorl %edx, %edx; \
+ subq %rax, %rdx; \
+ pushq %rdx; \
+ cfi_adjust_cfa_offset(8); \
+ call __errno_location@PLT; \
+ popq %rdx; \
+ cfi_adjust_cfa_offset(-8); \
+ movl %edx, (%rax); \
+ orq $-1, %rax; \
+ jmp L(pseudo_end);
+
+/* A quick note: it is assumed that the call to `__errno_location' does
+ not modify the stack! */
+# else /* Not _LIBC_REENTRANT. */
+# define SYSCALL_ERROR_HANDLER \
+0:movq errno@GOTPCREL(%RIP), %rcx; \
+ xorl %edx, %edx; \
+ subq %rax, %rdx; \
+ movl %edx, (%rcx); \
+ orq $-1, %rax; \
+ jmp L(pseudo_end);
+# endif /* __PIC__ */
+
+/* The Linux/x86-64 kernel expects the system call parameters in
+ registers according to the following table:
+
+ syscall number rax
+ arg 1 rdi
+ arg 2 rsi
+ arg 3 rdx
+ arg 4 r10
+ arg 5 r8
+ arg 6 r9
+
+ The Linux kernel uses and destroys internally these registers:
+ return address from
+ syscall rcx
+ eflags from syscall r11
+
+ Normal function call, including calls to the system call stub
+ functions in the libc, get the first six parameters passed in
+ registers and the seventh parameter and later on the stack. The
+ register use is as follows:
+
+ system call number in the DO_CALL macro
+ arg 1 rdi
+ arg 2 rsi
+ arg 3 rdx
+ arg 4 rcx
+ arg 5 r8
+ arg 6 r9
+
+ We have to take care that the stack is aligned to 16 bytes. When
+ called the stack is not aligned since the return address has just
+ been pushed.
+
+
+ Syscalls of more than 6 arguments are not supported. */
+
+# undef DO_CALL
+# define DO_CALL(syscall_name, args) \
+ DOARGS_##args \
+ movl $SYS_ify (syscall_name), %eax; \
+ syscall;
+
+# define DOARGS_0 /* nothing */
+# define DOARGS_1 /* nothing */
+# define DOARGS_2 /* nothing */
+# define DOARGS_3 /* nothing */
+# define DOARGS_4 movq %rcx, %r10;
+# define DOARGS_5 DOARGS_4
+# define DOARGS_6 DOARGS_5
+
+#endif /* __ASSEMBLER__ */
+
+
+/* Pointer mangling support. */
+#if defined NOT_IN_libc && defined IS_IN_rtld
+/* We cannot use the thread descriptor because in ld.so we use setjmp
+ earlier than the descriptor is initialized. */
+# ifdef __ASSEMBLER__
+# define PTR_MANGLE(reg) xorq __pointer_chk_guard_local(%rip), reg; \
+ rolq $17, reg
+# define PTR_DEMANGLE(reg) rorq $17, reg; \
+ xorq __pointer_chk_guard_local(%rip), reg
+# else
+# define PTR_MANGLE(reg) __asm__ ("xorq __pointer_chk_guard_local(%%rip), %0\n" \
+ "rolq $17, %0" \
+ : "=r" (reg) : "0" (reg))
+# define PTR_DEMANGLE(reg) __asm__ ("rorq $17, %0\n" \
+ "xorq __pointer_chk_guard_local(%%rip), %0" \
+ : "=r" (reg) : "0" (reg))
+# endif
+#else
+# ifdef __ASSEMBLER__
+# define PTR_MANGLE(reg) xorq %fs:POINTER_GUARD, reg; \
+ rolq $17, reg
+# define PTR_DEMANGLE(reg) rorq $17, reg; \
+ xorq %fs:POINTER_GUARD, reg
+# else
+# define PTR_MANGLE(var) __asm__ ("xorq %%fs:%c2, %0\n" \
+ "rolq $17, %0" \
+ : "=r" (var) \
+ : "0" (var), \
+ "i" (offsetof (tcbhead_t, \
+ pointer_guard)))
+# define PTR_DEMANGLE(var) __asm__ ("rorq $17, %0\n" \
+ "xorq %%fs:%c2, %0" \
+ : "=r" (var) \
+ : "0" (var), \
+ "i" (offsetof (tcbhead_t, \
+ pointer_guard)))
+# endif
+#endif
+
+#endif /* linux/x86_64/sysdep.h */
diff --git a/libc/sysdeps/linux/x86_64/ucontext_i.sym b/libc/sysdeps/linux/x86_64/ucontext_i.sym
new file mode 100644
index 000000000..af3e0e544
--- /dev/null
+++ b/libc/sysdeps/linux/x86_64/ucontext_i.sym
@@ -0,0 +1,37 @@
+#include <stddef.h>
+#include <signal.h>
+#include <sys/ucontext.h>
+
+--
+
+SIG_BLOCK
+SIG_SETMASK
+
+_NSIG8 (_NSIG / 8)
+
+#define ucontext(member) offsetof (ucontext_t, member)
+#define mcontext(member) ucontext (uc_mcontext.member)
+#define mreg(reg) mcontext (gregs[REG_##reg])
+
+oRBP mreg (RBP)
+oRSP mreg (RSP)
+oRBX mreg (RBX)
+oR8 mreg (R8)
+oR9 mreg (R9)
+oR10 mreg (R10)
+oR11 mreg (R11)
+oR12 mreg (R12)
+oR13 mreg (R13)
+oR14 mreg (R14)
+oR15 mreg (R15)
+oRDI mreg (RDI)
+oRSI mreg (RSI)
+oRDX mreg (RDX)
+oRAX mreg (RAX)
+oRCX mreg (RCX)
+oRIP mreg (RIP)
+oEFL mreg (EFL)
+oFPREGS mcontext (fpregs)
+oSIGMASK ucontext (uc_sigmask)
+oFPREGSMEM ucontext (__fpregs_mem)
+oMXCSR ucontext (__fpregs_mem.mxcsr)
diff --git a/libc/sysdeps/linux/x86_64/vfork.S b/libc/sysdeps/linux/x86_64/vfork.S
index 2dadbbfe0..a8a2f6e4b 100644
--- a/libc/sysdeps/linux/x86_64/vfork.S
+++ b/libc/sysdeps/linux/x86_64/vfork.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2002, 2004, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -12,9 +12,8 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <sys/syscall.h>
@@ -31,7 +30,7 @@
.text
.global __vfork
.hidden __vfork
-.type __vfork,%function
+.type __vfork,%function
__vfork:
@@ -39,6 +38,10 @@ __vfork:
is preserved by the syscall and that we're allowed to destroy. */
popq %rdi
+#ifdef SAVE_PID
+ SAVE_PID
+#endif
+
/* Stuff the syscall number in RAX and enter into the kernel. */
movl $__NR_vfork, %eax
syscall
@@ -46,6 +49,10 @@ __vfork:
/* Push back the return PC. */
pushq %rdi
+#ifdef RESTORE_PID
+ RESTORE_PID
+#endif
+
cmpl $-4095, %eax
jae __syscall_error /* Branch forward if it failed. */
@@ -55,4 +62,4 @@ __vfork:
.size __vfork,.-__vfork
weak_alias(__vfork,vfork)
-libc_hidden_weak(vfork)
+libc_hidden_def(vfork)
diff --git a/libc/sysdeps/linux/xtensa/Makefile.arch b/libc/sysdeps/linux/xtensa/Makefile.arch
index f54886444..b9b6b87d5 100644
--- a/libc/sysdeps/linux/xtensa/Makefile.arch
+++ b/libc/sysdeps/linux/xtensa/Makefile.arch
@@ -5,10 +5,10 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-CSRC := brk.c fork.c posix_fadvise.c posix_fadvise64.c pread_write.c \
- sigaction.c __syscall_error.c
+CSRC-y := brk.c sigaction.c __syscall_error.c
-SSRC := bsd-_setjmp.S bsd-setjmp.S setjmp.S clone.S \
+SSRC-y := bsd-_setjmp.S bsd-setjmp.S setjmp.S clone.S \
sigrestorer.S syscall.S mmap.S windowspill.S __longjmp.S vfork.S
-include $(top_srcdir)libc/sysdeps/linux/Makefile.commonarch
+CSRC-$(if $(UCLIBC_HAS_THREADS_NATIVE),,y) += fork.c
+SSRC-$(if $(UCLIBC_HAS_THREADS_NATIVE),,y) += clone.S
diff --git a/libc/sysdeps/linux/xtensa/__longjmp.S b/libc/sysdeps/linux/xtensa/__longjmp.S
index 0fa939095..acc0b4ff2 100644
--- a/libc/sysdeps/linux/xtensa/__longjmp.S
+++ b/libc/sysdeps/linux/xtensa/__longjmp.S
@@ -14,9 +14,8 @@
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., 51 Franklin Street - Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* This implementation relies heavily on the Xtensa register window
mechanism. Setjmp flushes all the windows except its own to the
@@ -49,6 +48,7 @@
ENTRY (__longjmp)
+#if defined(__XTENSA_WINDOWED_ABI__)
/* Invalidate all but the current window. Reading and writing
special registers WINDOWBASE and WINDOWSTART are
privileged operations, so user processes must call the
@@ -84,7 +84,7 @@ ENTRY (__longjmp)
slli a4, a7, 4
sub a6, a8, a4
addi a5, a2, 16
- addi a8, a8, -16 // a8 = end of register overflow area
+ addi a8, a8, -16 /* a8 = end of register overflow area */
.Lljloop:
l32i a7, a5, 0
l32i a4, a5, 4
@@ -105,8 +105,8 @@ ENTRY (__longjmp)
case the contents were moved by an alloca after calling
setjmp. This is a bit paranoid but it doesn't cost much. */
- l32i a7, a2, 4 // load the target stack pointer
- addi a7, a7, -16 // find the destination save area
+ l32i a7, a2, 4 /* load the target stack pointer */
+ addi a7, a7, -16 /* find the destination save area */
l32i a4, a2, 48
l32i a5, a2, 52
s32i a4, a7, 0
@@ -121,6 +121,22 @@ ENTRY (__longjmp)
movnez a2, a3, a3
retw
+#elif defined(__XTENSA_CALL0_ABI__)
+ l32i a0, a2, 0
+ l32i a1, a2, 4
+ l32i a12, a2, 8
+ l32i a13, a2, 12
+ l32i a14, a2, 16
+ l32i a15, a2, 20
+
+ /* Return v ? v : 1. */
+ movi a2, 1
+ movnez a2, a3, a3
+
+ ret
+#else
+#error Unsupported Xtensa ABI
+#endif
END (__longjmp)
libc_hidden_def (__longjmp)
diff --git a/libc/sysdeps/linux/xtensa/bits/atomic.h b/libc/sysdeps/linux/xtensa/bits/atomic.h
new file mode 100644
index 000000000..b2be547f0
--- /dev/null
+++ b/libc/sysdeps/linux/xtensa/bits/atomic.h
@@ -0,0 +1,232 @@
+/* Copyright (C) 2012 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _BITS_ATOMIC_H
+#define _BITS_ATOMIC_H 1
+
+#include <inttypes.h>
+
+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 int64_t atomic64_t;
+typedef uint64_t uatomic64_t;
+typedef int_fast64_t atomic_fast64_t;
+typedef uint_fast64_t uatomic_fast64_t;
+
+typedef intptr_t atomicptr_t;
+typedef uintptr_t uatomicptr_t;
+typedef intmax_t atomic_max_t;
+typedef uintmax_t uatomic_max_t;
+
+
+/* Xtensa has only a 32-bit form of a store-conditional instruction. */
+
+#define __arch_compare_and_exchange_bool_8_acq(mem, newval, oldval) \
+ (abort (), 0)
+
+#define __arch_compare_and_exchange_bool_16_acq(mem, newval, oldval) \
+ (abort (), 0)
+
+#define __arch_compare_and_exchange_bool_8_rel(mem, newval, oldval) \
+ (abort (), 0)
+
+#define __arch_compare_and_exchange_bool_16_rel(mem, newval, oldval) \
+ (abort (), 0)
+
+/* Atomically store NEWVAL in *MEM if *MEM is equal to OLDVAL.
+ Return the old *MEM value. */
+
+#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
+ ({__typeof__(*(mem)) __tmp, __value; \
+ __asm__ __volatile__( \
+ "1: l32i %1, %2, 0 \n" \
+ " bne %1, %4, 2f \n" \
+ " wsr %1, SCOMPARE1 \n" \
+ " mov %0, %1 \n" \
+ " mov %1, %3 \n" \
+ " s32c1i %1, %2, 0 \n" \
+ " bne %0, %1, 1b \n" \
+ "2: \n" \
+ : "=&a" (__value), "=&a" (__tmp) \
+ : "a" (mem), "a" (newval), "a" (oldval) \
+ : "memory" ); \
+ __tmp; \
+ })
+
+/* Atomically store NEWVAL in *MEM if *MEM is equal to OLDVAL.
+ Return zero if *MEM was changed or non-zero if no exchange happened. */
+
+#define __arch_compare_and_exchange_bool_32_acq(mem, newval, oldval) \
+ ({__typeof__(*(mem)) __tmp, __value; \
+ __asm__ __volatile__( \
+ "1: l32i %0, %2, 0 \n" \
+ " sub %1, %4, %0 \n" \
+ " bnez %1, 2f \n" \
+ " wsr %0, SCOMPARE1 \n" \
+ " mov %1, %3 \n" \
+ " s32c1i %1, %2, 0 \n" \
+ " bne %0, %1, 1b \n" \
+ " movi %1, 0 \n" \
+ "2: \n" \
+ : "=&a" (__value), "=&a" (__tmp) \
+ : "a" (mem), "a" (newval), "a" (oldval) \
+ : "memory" ); \
+ __tmp != 0; \
+ })
+
+/* Store NEWVALUE in *MEM and return the old value. */
+
+#define __arch_exchange_32_acq(mem, newval) \
+ ({__typeof__(*(mem)) __tmp, __value; \
+ __asm__ __volatile__( \
+ "1: l32i %0, %2, 0 \n" \
+ " wsr %0, SCOMPARE1 \n" \
+ " mov %1, %3 \n" \
+ " s32c1i %1, %2, 0 \n" \
+ " bne %0, %1, 1b \n" \
+ : "=&a" (__value), "=&a" (__tmp) \
+ : "a" (mem), "a" (newval) \
+ : "memory" ); \
+ __tmp; \
+ })
+
+/* Add VALUE to *MEM and return the old value of *MEM. */
+
+#define __arch_atomic_exchange_and_add_32(mem, value) \
+ ({__typeof__(*(mem)) __tmp, __value; \
+ __asm__ __volatile__( \
+ "1: l32i %0, %2, 0 \n" \
+ " wsr %0, SCOMPARE1 \n" \
+ " add %1, %0, %3 \n" \
+ " s32c1i %1, %2, 0 \n" \
+ " bne %0, %1, 1b \n" \
+ : "=&a" (__value), "=&a" (__tmp) \
+ : "a" (mem), "a" (value) \
+ : "memory" ); \
+ __tmp; \
+ })
+
+/* Subtract VALUE from *MEM and return the old value of *MEM. */
+
+#define __arch_atomic_exchange_and_sub_32(mem, value) \
+ ({__typeof__(*(mem)) __tmp, __value; \
+ __asm__ __volatile__( \
+ "1: l32i %0, %2, 0 \n" \
+ " wsr %0, SCOMPARE1 \n" \
+ " sub %1, %0, %3 \n" \
+ " s32c1i %1, %2, 0 \n" \
+ " bne %0, %1, 1b \n" \
+ : "=&a" (__value), "=&a" (__tmp) \
+ : "a" (mem), "a" (value) \
+ : "memory" ); \
+ __tmp; \
+ })
+
+/* Decrement *MEM if it is > 0, and return the old value. */
+
+#define __arch_atomic_decrement_if_positive_32(mem) \
+ ({__typeof__(*(mem)) __tmp, __value; \
+ __asm__ __volatile__( \
+ "1: l32i %0, %2, 0 \n" \
+ " blti %0, 1, 2f \n" \
+ " wsr %0, SCOMPARE1 \n" \
+ " addi %1, %0, -1 \n" \
+ " s32c1i %1, %2, 0 \n" \
+ " bne %0, %1, 1b \n" \
+ "2: \n" \
+ : "=&a" (__value), "=&a" (__tmp) \
+ : "a" (mem) \
+ : "memory" ); \
+ __value; \
+ })
+
+
+/* These are the preferred public interfaces: */
+
+#define atomic_compare_and_exchange_val_acq(mem, newval, oldval) \
+ ({ \
+ if (sizeof (*mem) != 4) \
+ abort(); \
+ __arch_compare_and_exchange_val_32_acq(mem, newval, oldval); \
+ })
+
+#define atomic_exchange_acq(mem, newval) \
+ ({ \
+ if (sizeof(*(mem)) != 4) \
+ abort(); \
+ __arch_exchange_32_acq(mem, newval); \
+ })
+
+#define atomic_exchange_and_add(mem, newval) \
+ ({ \
+ if (sizeof(*(mem)) != 4) \
+ abort(); \
+ __arch_atomic_exchange_and_add_32(mem, newval); \
+ })
+
+#define atomic_exchange_and_sub(mem, newval) \
+ ({ \
+ if (sizeof(*(mem)) != 4) \
+ abort(); \
+ __arch_atomic_exchange_and_sub_32(mem, newval); \
+ })
+
+#define atomic_decrement_if_positive(mem) \
+ ({ \
+ if (sizeof(*(mem)) != 4) \
+ abort(); \
+ __arch_atomic_decrement_if_positive_32(mem); \
+ })
+
+
+# define __arch_compare_and_exchange_bool_64_acq(mem, newval, oldval) \
+ (abort (), 0)
+
+# define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
+ (abort (), (__typeof (*mem)) 0)
+
+# define __arch_compare_and_exchange_bool_64_rel(mem, newval, oldval) \
+ (abort (), 0)
+
+# define __arch_compare_and_exchange_val_64_rel(mem, newval, oldval) \
+ (abort (), (__typeof (*mem)) 0)
+
+# define __arch_atomic_exchange_64_acq(mem, value) \
+ ({ abort (); (*mem) = (value); })
+
+# define __arch_atomic_exchange_64_rel(mem, value) \
+ ({ abort (); (*mem) = (value); })
+
+# define __arch_atomic_exchange_and_add_64(mem, value) \
+ ({ abort (); (*mem) = (value); })
+
+# define __arch_atomic_increment_val_64(mem) \
+ ({ abort (); (*mem)++; })
+
+# define __arch_atomic_decrement_val_64(mem) \
+ ({ abort (); (*mem)--; })
+
+# define __arch_atomic_decrement_if_positive_64(mem) \
+ ({ abort (); (*mem)--; })
+
+
+
+#endif /* _BITS_ATOMIC_H */
+
diff --git a/libc/sysdeps/linux/xtensa/bits/fcntl.h b/libc/sysdeps/linux/xtensa/bits/fcntl.h
index 23de96c02..d21c4e03c 100644
--- a/libc/sysdeps/linux/xtensa/bits/fcntl.h
+++ b/libc/sysdeps/linux/xtensa/bits/fcntl.h
@@ -14,9 +14,8 @@
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., 51 Franklin Street - Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _FCNTL_H
# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
@@ -50,6 +49,8 @@
# define O_DIRECTORY 0200000 /* Must be a directory. */
# define O_NOFOLLOW 0400000 /* Do not follow links. */
# define O_NOATIME 01000000 /* Do not set atime. */
+# define O_CLOEXEC 02000000 /* set close_on_exec */
+# define O_PATH 010000000 /* Resolve pathname but do not open file. */
#endif
/* For now Linux has synchronisity options for data and read operations.
@@ -99,6 +100,8 @@
# define F_NOTIFY 1026 /* Request notfications on a directory. */
# define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with
close-on-exit set on new fd. */
+# define F_SETPIPE_SZ 1031 /* Set pipe page size array. */
+# define F_GETPIPE_SZ 1032 /* Get pipe page size array. */
#endif
/* For F_[GET|SET]FD. */
@@ -186,7 +189,7 @@ struct flock64
#endif
-#ifdef __USE_GNU
+#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
@@ -209,7 +212,7 @@ struct flock64
__BEGIN_DECLS
-#ifdef __USE_GNU
+#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)
diff --git a/libc/sysdeps/linux/xtensa/bits/ipc.h b/libc/sysdeps/linux/xtensa/bits/ipc.h
index 481bdcc52..2ad5fc0a2 100644
--- a/libc/sysdeps/linux/xtensa/bits/ipc.h
+++ b/libc/sysdeps/linux/xtensa/bits/ipc.h
@@ -12,9 +12,8 @@
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., 51 Franklin Street - Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_IPC_H
# error "Never use <bits/ipc.h> directly; include <sys/ipc.h> instead."
diff --git a/libc/sysdeps/linux/xtensa/bits/kernel_stat.h b/libc/sysdeps/linux/xtensa/bits/kernel_stat.h
index 26da9281b..5e4f5c4e5 100644
--- a/libc/sysdeps/linux/xtensa/bits/kernel_stat.h
+++ b/libc/sysdeps/linux/xtensa/bits/kernel_stat.h
@@ -1,16 +1,10 @@
#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... */
-#define STAT_HAVE_NSEC 1
-
struct kernel_stat {
unsigned long st_dev;
unsigned long st_ino;
@@ -22,12 +16,9 @@ struct kernel_stat {
long st_size;
unsigned long st_blksize;
unsigned long st_blocks;
- unsigned long st_atime;
- unsigned long st_atime_nsec;
- unsigned long st_mtime;
- unsigned long st_mtime_nsec;
- unsigned long st_ctime;
- unsigned long st_ctime_nsec;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
unsigned long __unused4;
unsigned long __unused5;
};
@@ -44,12 +35,9 @@ struct kernel_stat64 {
unsigned long st_blksize; /* Optimal block size for I/O. */
unsigned long __unused2;
unsigned long long st_blocks; /* Number 512-byte blocks allocated. */
- unsigned long st_atime; /* Time of last access. */
- unsigned long st_atime_nsec;
- unsigned long st_mtime; /* Time of last modification. */
- unsigned long st_mtime_nsec;
- unsigned long st_ctime; /* Time of last status change. */
- unsigned long st_ctime_nsec;
+ struct timespec st_atim; /* Time of last access. */
+ struct timespec st_mtim; /* Time of last modification. */
+ struct timespec st_ctim; /* Time of last status change. */
unsigned long __unused4;
unsigned long __unused5;
};
diff --git a/libc/sysdeps/linux/xtensa/bits/kernel_types.h b/libc/sysdeps/linux/xtensa/bits/kernel_types.h
index 44f1075f7..ed38f2e18 100644
--- a/libc/sysdeps/linux/xtensa/bits/kernel_types.h
+++ b/libc/sysdeps/linux/xtensa/bits/kernel_types.h
@@ -33,6 +33,8 @@ typedef unsigned int __kernel_gid32_t;
typedef unsigned short __kernel_old_uid_t;
typedef unsigned short __kernel_old_gid_t;
typedef unsigned short __kernel_old_dev_t;
+typedef long __kernel_long_t;
+typedef unsigned long __kernel_ulong_t;
typedef long long __kernel_loff_t;
/* Beginning in 2.6 kernels, which is the first version that includes the
diff --git a/libc/sysdeps/linux/xtensa/bits/mathdef.h b/libc/sysdeps/linux/xtensa/bits/mathdef.h
index 0177fa9fc..1c73cb255 100644
--- a/libc/sysdeps/linux/xtensa/bits/mathdef.h
+++ b/libc/sysdeps/linux/xtensa/bits/mathdef.h
@@ -13,9 +13,8 @@
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., 51 Franklin Street - Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#if !defined _MATH_H && !defined _COMPLEX_H
# error "Never use <bits/mathdef.h> directly; include <math.h> instead"
diff --git a/libc/sysdeps/linux/xtensa/bits/mman.h b/libc/sysdeps/linux/xtensa/bits/mman.h
index d3beae6aa..a42e92663 100644
--- a/libc/sysdeps/linux/xtensa/bits/mman.h
+++ b/libc/sysdeps/linux/xtensa/bits/mman.h
@@ -13,9 +13,8 @@
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., 51 Franklin Street - Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_MMAN_H
# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
@@ -64,6 +63,8 @@
# define MAP_NORESERVE 0x0400 /* Don't check for reservations. */
# define MAP_POPULATE 0x10000 /* Populate (prefault) pagetables. */
# define MAP_NONBLOCK 0x20000 /* Do not block on IO. */
+# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could
+ be uninitialized. */
#endif
/* Flags to `msync'. */
diff --git a/libc/sysdeps/linux/xtensa/bits/msq.h b/libc/sysdeps/linux/xtensa/bits/msq.h
index 2eca21e6c..e4f3fa317 100644
--- a/libc/sysdeps/linux/xtensa/bits/msq.h
+++ b/libc/sysdeps/linux/xtensa/bits/msq.h
@@ -12,9 +12,8 @@
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., 51 Franklin Street - Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_MSG_H
# error "Never use <bits/msq.h> directly; include <sys/msg.h> instead."
diff --git a/libc/sysdeps/linux/xtensa/bits/setjmp.h b/libc/sysdeps/linux/xtensa/bits/setjmp.h
index 1bc4896c8..5d3e5509e 100644
--- a/libc/sysdeps/linux/xtensa/bits/setjmp.h
+++ b/libc/sysdeps/linux/xtensa/bits/setjmp.h
@@ -12,9 +12,8 @@
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., 51 Franklin Street - Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* Define the machine-dependent type `jmp_buf'. Xtensa version. */
#ifndef _BITS_SETJMP_H
@@ -24,23 +23,21 @@
# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
#endif
+#if defined(__XTENSA_WINDOWED_ABI__)
/* The jmp_buf structure for Xtensa holds the following (where "proc"
is the procedure that calls setjmp): 4-12 registers from the window
of proc, the 4 words from the save area at proc's $sp (in case a
subsequent alloca in proc moves $sp), and the return address within
proc. Everything else is saved on the stack in the normal save areas. */
-#ifndef _ASM
typedef int __jmp_buf[17];
-#endif
-
-#define JB_SP 1
-#define JB_PC 16
+#elif defined(__XTENSA_CALL0_ABI__)
+/* The jmp_buf structure for Xtensa Call0 ABI holds the return address,
+ the stack pointer and callee-saved registers (a12 - a15). */
-/* Test if longjmp to JMPBUF would unwind the frame containing a local
- variable at ADDRESS. */
-
-#define _JMPBUF_UNWINDS(jmpbuf, address) \
- ((void *) (address) < (void *) (jmpbuf)[JB_SP])
+typedef int __jmp_buf[6];
+#else
+#error Unsupported Xtensa ABI
+#endif
#endif /* bits/setjmp.h */
diff --git a/libc/sysdeps/linux/xtensa/bits/shm.h b/libc/sysdeps/linux/xtensa/bits/shm.h
index de41d0d99..d288a1cca 100644
--- a/libc/sysdeps/linux/xtensa/bits/shm.h
+++ b/libc/sysdeps/linux/xtensa/bits/shm.h
@@ -13,9 +13,8 @@
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., 51 Franklin Street - Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_SHM_H
# error "Never include <bits/shm.h> directly; use <sys/shm.h> instead."
diff --git a/libc/sysdeps/linux/xtensa/bits/sigcontext.h b/libc/sysdeps/linux/xtensa/bits/sigcontext.h
new file mode 100644
index 000000000..c0af295f9
--- /dev/null
+++ b/libc/sysdeps/linux/xtensa/bits/sigcontext.h
@@ -0,0 +1,40 @@
+/* Copyright (C) 2012 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H
+# error "Never use <bits/sigcontext.h> directly; include <signal.h> instead."
+#endif
+
+#ifndef _BITS_SIGCONTEXT_H
+#define _BITS_SIGCONTEXT_H 1
+
+struct sigcontext
+{
+ unsigned long sc_pc;
+ unsigned long sc_ps;
+ unsigned long sc_lbeg;
+ unsigned long sc_lend;
+ unsigned long sc_lcount;
+ unsigned long sc_sar;
+ unsigned long sc_acclo;
+ unsigned long sc_acchi;
+ unsigned long sc_a[16];
+ void *sc_xtregs;
+};
+
+#endif /* _BITS_SIGCONTEXT_H */
+
diff --git a/libc/sysdeps/linux/xtensa/bits/sigcontextinfo.h b/libc/sysdeps/linux/xtensa/bits/sigcontextinfo.h
index 8f3301c9a..39ad5f689 100644
--- a/libc/sysdeps/linux/xtensa/bits/sigcontextinfo.h
+++ b/libc/sysdeps/linux/xtensa/bits/sigcontextinfo.h
@@ -12,9 +12,8 @@
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., 51 Franklin Street - Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* Also see register-dump.h, where we spill live registers to the
stack so that we can trace the stack backward. */
diff --git a/libc/sysdeps/linux/xtensa/bits/stackinfo.h b/libc/sysdeps/linux/xtensa/bits/stackinfo.h
index 50ddf2514..6ecdd69ba 100644
--- a/libc/sysdeps/linux/xtensa/bits/stackinfo.h
+++ b/libc/sysdeps/linux/xtensa/bits/stackinfo.h
@@ -12,9 +12,8 @@
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., 51 Franklin Street - Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* This file contains a bit of information about the stack allocation
of the processor. */
diff --git a/libc/sysdeps/linux/xtensa/bits/stat.h b/libc/sysdeps/linux/xtensa/bits/stat.h
index c6debc894..c61b188b7 100644
--- a/libc/sysdeps/linux/xtensa/bits/stat.h
+++ b/libc/sysdeps/linux/xtensa/bits/stat.h
@@ -12,9 +12,8 @@
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., 51 Franklin Street - Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_STAT_H
# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
@@ -55,7 +54,7 @@ struct stat
unsigned long __pad2;
__blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
#endif
-#if 0 /*def __USE_MISC*/
+#ifdef __USE_MISC
/* Nanosecond resolution timestamps are stored in a format
equivalent to 'struct timespec'. This is the type used
whenever possible but the Unix namespace rules do not allow the
@@ -95,7 +94,7 @@ struct stat64
unsigned long __pad2;
__blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
-#if 0 /*def __USE_MISC*/
+#ifdef __USE_MISC
/* Nanosecond resolution timestamps are stored in a format
equivalent to 'struct timespec'. This is the type used
whenever possible but the Unix namespace rules do not allow the
@@ -151,3 +150,8 @@ struct stat64
#define __S_IREAD 0400 /* Read by owner. */
#define __S_IWRITE 0200 /* Write by owner. */
#define __S_IEXEC 0100 /* Execute by owner. */
+
+#ifdef __USE_ATFILE
+# define UTIME_NOW ((1l << 30) - 1l)
+# define UTIME_OMIT ((1l << 30) - 2l)
+#endif
diff --git a/libc/sysdeps/linux/xtensa/bits/syscalls.h b/libc/sysdeps/linux/xtensa/bits/syscalls.h
index a59a8052a..7e900c590 100644
--- a/libc/sysdeps/linux/xtensa/bits/syscalls.h
+++ b/libc/sysdeps/linux/xtensa/bits/syscalls.h
@@ -9,8 +9,6 @@
glibc .../sysdeps/unix/sysv/linux/xtensa/sysdep.h
*/
-#define SYS_ify(syscall_name) __NR_##syscall_name
-
#ifdef __ASSEMBLER__
/* The register layout upon entering the function is:
@@ -74,67 +72,16 @@
/* Define a macro which expands into the inline wrapper code for a system
call. */
-#undef INLINE_SYSCALL
-#define INLINE_SYSCALL(name, nr, args...) \
- ({ unsigned long resultvar = INTERNAL_SYSCALL (name, , nr, args); \
- if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, ), 0)) \
- { \
- __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
- resultvar = (unsigned long) -1; \
- } \
- (long) resultvar; })
-
-#undef INTERNAL_SYSCALL_DECL
-#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
-
#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+(__extension__ \
({ LD_ARG(2, name); \
LD_ARGS_##nr(args); \
__asm__ __volatile__ ("syscall\n" \
: "=a" (_a2) \
: ASM_ARGS_##nr \
: "memory"); \
- (long) _a2; })
-
-#undef INTERNAL_SYSCALL
-#define INTERNAL_SYSCALL(name, err, nr, args...) \
- INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
-
-#undef INTERNAL_SYSCALL_ERROR_P
-#define INTERNAL_SYSCALL_ERROR_P(val, err) \
- ((unsigned long) (val) >= -4095L)
-
-#undef INTERNAL_SYSCALL_ERRNO
-#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
-
-#define _syscall0(args...) SYSCALL_FUNC (0, args)
-#define _syscall1(args...) SYSCALL_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)
-
-#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)); \
-}
-
+ (long) _a2; \
+ }) \
+)
#endif /* not __ASSEMBLER__ */
#endif /* _BITS_SYSCALLS_H */
diff --git a/libc/sysdeps/linux/xtensa/bits/uClibc_arch_features.h b/libc/sysdeps/linux/xtensa/bits/uClibc_arch_features.h
index d6a99b4d2..a15744c2f 100644
--- a/libc/sysdeps/linux/xtensa/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/xtensa/bits/uClibc_arch_features.h
@@ -11,8 +11,8 @@
/* can your target use syscall6() for mmap ? */
#define __UCLIBC_MMAP_HAS_6_ARGS__
-/* does your target use syscall4() for truncate64 ? (32bit arches only) */
-#define __UCLIBC_TRUNCATE64_HAS_4_ARGS__
+/* does your target align 64bit values in register pairs ? (32bit arches only) */
+#define __UCLIBC_SYSCALL_ALIGN_64BIT__
/* does your target have a broken create_module() ? */
#undef __UCLIBC_BROKEN_CREATE_MODULE__
@@ -23,19 +23,19 @@
/* 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 */
+#undef __UCLIBC_ASM_LINE_SEP__
+
#endif /* _BITS_UCLIBC_ARCH_FEATURES_H */
diff --git a/libc/sysdeps/linux/xtensa/bits/wordsize.h b/libc/sysdeps/linux/xtensa/bits/wordsize.h
index ba643b60a..ca82fd7d4 100644
--- a/libc/sysdeps/linux/xtensa/bits/wordsize.h
+++ b/libc/sysdeps/linux/xtensa/bits/wordsize.h
@@ -12,8 +12,7 @@
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. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#define __WORDSIZE 32
diff --git a/libc/sysdeps/linux/xtensa/bits/xtensa-config.h b/libc/sysdeps/linux/xtensa/bits/xtensa-config.h
index 34cf28c0a..2e60af936 100644
--- a/libc/sysdeps/linux/xtensa/bits/xtensa-config.h
+++ b/libc/sysdeps/linux/xtensa/bits/xtensa-config.h
@@ -14,9 +14,8 @@
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., 51 Franklin Street - Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef XTENSA_CONFIG_H
#define XTENSA_CONFIG_H
@@ -44,10 +43,4 @@
#undef XCHAL_NUM_AREGS
#define XCHAL_NUM_AREGS 64
-/* Set a default page size. This is currently needed when bootstrapping
- the runtime linker. See comments in dl-machine.h where this is used. */
-
-#undef XCHAL_MMU_MIN_PTE_PAGE_SIZE
-#define XCHAL_MMU_MIN_PTE_PAGE_SIZE 12
-
#endif /* !XTENSA_CONFIG_H */
diff --git a/libc/sysdeps/linux/xtensa/brk.c b/libc/sysdeps/linux/xtensa/brk.c
index 51f610b70..512810409 100644
--- a/libc/sysdeps/linux/xtensa/brk.c
+++ b/libc/sysdeps/linux/xtensa/brk.c
@@ -13,9 +13,8 @@
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., 51 Franklin Street - Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <errno.h>
#include <unistd.h>
@@ -24,7 +23,6 @@
/* This must be initialized data because commons can't have aliases. */
void *__curbrk attribute_hidden = 0;
-libc_hidden_proto(brk)
int
brk (void *addr)
{
diff --git a/libc/sysdeps/linux/xtensa/clone.S b/libc/sysdeps/linux/xtensa/clone.S
index 31921ea47..88cd6c1c3 100644
--- a/libc/sysdeps/linux/xtensa/clone.S
+++ b/libc/sysdeps/linux/xtensa/clone.S
@@ -1,35 +1,38 @@
-/* Copyright (C) 2001, 2005, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2005 Free Software Foundation, Inc.
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.
+ 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
- Lesser General Public License for more details.
+ 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; if not, write to the Free
- Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ 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. */
/* clone is even more special than fork as it mucks with stacks
- and invokes a function in the right context after it's all over. */
+ and invokes a function in the right context after its all over. */
-#include "sysdep.h"
-#include <sys/syscall.h>
+#include <features.h>
+#include <sysdep.h>
#define _ERRNO_H 1
#include <bits/errno.h>
+#ifdef RESET_PID
+#include <tls.h>
+#endif
+#define __ASSEMBLY__
+#include <linux/sched.h>
-/* int clone (a2 = int (*fn)(void *arg),
- a3 = void *child_stack,
- a4 = int flags,
- a5 = void *arg,
- a6 = pid_t *ptid,
- a7 = struct user_desc *tls,
- 16(sp) = pid_t *ctid) */
+/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg,
+ a2 a3 a4 a5
+ pid_t *ptid, struct user_desc *tls, pid_t *ctid)
+ a6 a7 16(sp)
+*/
.text
ENTRY (__clone)
@@ -40,7 +43,7 @@ ENTRY (__clone)
/* a2 and a3 are candidates for destruction by system-call return
parameters. We don't need the stack pointer after the system
- call. We trust that the kernel will preserve a7, a9, and a6. */
+ call. We trust that the kernel will preserve a6, a7 and a9. */
mov a9, a5 /* save function argument */
mov a5, a7
@@ -48,55 +51,69 @@ ENTRY (__clone)
mov a8, a6 /* use a8 as a temp */
mov a6, a4
mov a4, a8
- l32i a8, a1, 16 /* child_tid */
- movi a2, SYS_ify (clone)
-
- /* syscall (a2 = NR_clone,
- a6 = clone_flags,
- a3 = usp,
- a4 = parent_tid,
- a5 = child_tls,
- a8 = child_tid) */
+ l32i a8, a1, FRAMESIZE /* child_tid */
+ movi a2, SYS_ify(clone)
+
+ /* syscall(NR_clone,clone_flags, usp, parent_tid, child_tls, child_tid)
+ a2 a6 a3 a4 a5 a8
+ */
+
syscall
bltz a2, SYSCALL_ERROR_LABEL
beqz a2, .Lthread_start
- /* Fall through for parent. */
+ /* fall through for parent */
+
.Lpseudo_end:
- retw
+ abi_ret
.Leinval:
movi a2, -EINVAL
j SYSCALL_ERROR_LABEL
.Lthread_start:
- /* Start child thread. */
- movi a0, 0 /* terminate the stack frame */
+
+#if CLONE_THREAD != 0x00010000 || CLONE_VM != 0x00000100
+# error invalid values for CLONE_THREAD or CLONE_VM
+#endif
#ifdef RESET_PID
- /* Check and see if we need to reset the PID. */
- bbsi.l a6, 16, 1f /* CLONE_THREAD = 0x00010000 */
+ bbsi.l a6, 16, .Lskip_restore_pid /* CLONE_THREAD = 0x00010000 */
movi a2, -1
- bbsi.l a6, 8, 2f /* CLONE_VM = 0x00000100 */
- movi a2, SYS_ify (getpid)
+ bbsi a6, 8, .Lgotpid /* CLONE_VM = 0x00000100 */
+ movi a2, SYS_ify(getpid)
syscall
-2: rur a3, THREADPTR
- movi a4, PID_OFFSET
- add a4, a4, a3
- s32i a2, a4, 0
- movi a4, TID_OFFSET
- add a4, a4, a3
- s32i a2, a3, 0
-1:
-#endif /* RESET_PID */
+.Lgotpid:
+ rur a3, threadptr
+ movi a0, TLS_PRE_TCB_SIZE
+ sub a3, a3, a0
+ s32i a2, a3, PID
+ s32i a2, a3, TID
+.Lskip_restore_pid:
+#endif
+
+ /* start child thread */
+ movi a0, 0 /* terminate the stack frame */
+#if defined(__XTENSA_WINDOWED_ABI__)
mov a6, a9 /* load up the 'arg' parameter */
callx4 a7 /* call the user's function */
/* Call _exit. Note that any return parameter from the user's
- function in a6 is seen as inputs to _exit. */
+ function in a6 is seen as inputs to _exit. */
movi a2, JUMPTARGET(_exit)
callx4 a2
+#elif defined(__XTENSA_CALL0_ABI__)
+ mov a2, a9 /* load up the 'arg' parameter */
+ callx0 a7 /* call the user's function */
+
+ /* Call _exit. Note that any return parameter from the user's
+ function in a2 is seen as inputs to _exit. */
+ movi a0, JUMPTARGET(_exit)
+ callx0 a0
+#else
+#error Unsupported Xtensa ABI
+#endif
PSEUDO_END (__clone)
diff --git a/libc/sysdeps/linux/xtensa/crt1.S b/libc/sysdeps/linux/xtensa/crt1.S
index 63fbadc15..efbe264c0 100644
--- a/libc/sysdeps/linux/xtensa/crt1.S
+++ b/libc/sysdeps/linux/xtensa/crt1.S
@@ -30,9 +30,8 @@
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., 51 Franklin Street - Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <features.h>
@@ -77,6 +76,7 @@
.global _start
.type _start, @function
_start:
+#if defined(__XTENSA_WINDOWED_ABI__)
/* Clear a0 to obviously mark the outermost frame. */
movi a0, 0
@@ -105,6 +105,35 @@ _start:
But let the libc call main. */
movi a4, __uClibc_main
callx4 a4
+#elif defined(__XTENSA_CALL0_ABI__)
+ /* Setup the shared library termination function. */
+ mov a7, a2
+
+ /* Load up the user's main function. */
+ movi a2, main
+
+ /* Extract the arguments as encoded on the stack and set up
+ the arguments for `main': argc, argv. envp will be determined
+ later in __uClibc_main. */
+ l32i a3, a1, 0 /* Load the argument count. */
+ addi a4, a1, 4 /* Compute the argv pointer. */
+
+ /* Push address of our own entry points to .fini and .init. */
+ movi a5, _init
+ movi a6, _fini
+
+ /* Provide the highest stack address to the user code (for stacks
+ which grow downwards). Note that we destroy the stack version
+ of argc here. */
+ s32i a1, a1, 0
+
+ /* Call the user's main function, and exit with its value.
+ But let the libc call main. */
+ movi a0, __uClibc_main
+ callx0 a0
+#else
+#error Unsupported Xtensa ABI
+#endif
/* Crash if somehow `exit' does return. */
ill
diff --git a/libc/sysdeps/linux/xtensa/crti.S b/libc/sysdeps/linux/xtensa/crti.S
index a01c02c9f..ba804eb45 100644
--- a/libc/sysdeps/linux/xtensa/crti.S
+++ b/libc/sysdeps/linux/xtensa/crti.S
@@ -5,12 +5,25 @@
.global _init
.type _init, @function
_init:
+#if defined(__XTENSA_WINDOWED_ABI__)
entry sp, 48
-
+#elif defined(__XTENSA_CALL0_ABI__)
+ addi sp, sp, -16
+ s32i a0, sp, 0
+#else
+#error Unsupported Xtensa ABI
+#endif
.section .fini
.align 4
.global _fini
.type _fini, @function
_fini:
+#if defined(__XTENSA_WINDOWED_ABI__)
entry sp, 48
+#elif defined(__XTENSA_CALL0_ABI__)
+ addi sp, sp, -16
+ s32i a0, sp, 0
+#else
+#error Unsupported Xtensa ABI
+#endif
diff --git a/libc/sysdeps/linux/xtensa/crtn.S b/libc/sysdeps/linux/xtensa/crtn.S
index ab1a489c5..a3598da1a 100644
--- a/libc/sysdeps/linux/xtensa/crtn.S
+++ b/libc/sysdeps/linux/xtensa/crtn.S
@@ -1,8 +1,23 @@
/* glibc's sysdeps/xtensa/elf/initfini.c used for reference [EPILOG] */
.section .init
+#if defined(__XTENSA_WINDOWED_ABI__)
retw
-
+#elif defined(__XTENSA_CALL0_ABI__)
+ l32i a0, sp, 0
+ addi sp, sp, 16
+ ret
+#else
+#error Unsupported Xtensa ABI
+#endif
.section .fini
+#if defined(__XTENSA_WINDOWED_ABI__)
retw
+#elif defined(__XTENSA_CALL0_ABI__)
+ l32i a0, sp, 0
+ addi sp, sp, 16
+ ret
+#else
+#error Unsupported Xtensa ABI
+#endif
diff --git a/libc/sysdeps/linux/xtensa/fork.c b/libc/sysdeps/linux/xtensa/fork.c
index b06d934fb..4e4f937a0 100644
--- a/libc/sysdeps/linux/xtensa/fork.c
+++ b/libc/sysdeps/linux/xtensa/fork.c
@@ -7,19 +7,23 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#include <unistd.h>
-#include <sys/syscall.h>
-#define _SIGNAL_H
-#include <bits/signum.h>
/* Xtensa doesn't provide a 'fork' system call, so we use 'clone'. */
+#include <sys/syscall.h>
-extern __typeof(fork) __libc_fork;
+#if defined __NR_clone && defined __ARCH_USE_MMU__
+# include <unistd.h>
+# include <signal.h>
+# include <cancel.h>
-libc_hidden_proto (fork)
-pid_t __libc_fork (void)
+pid_t fork(void)
{
- return (pid_t) INLINE_SYSCALL (clone, 2, SIGCHLD, 0);
+ return (pid_t) INLINE_SYSCALL(clone, 2, SIGCHLD, 0);
}
-weak_alias (__libc_fork, fork)
-libc_hidden_weak (fork)
+# ifdef __UCLIBC_HAS_THREADS__
+strong_alias(fork,__libc_fork)
+libc_hidden_weak(fork)
+# else
+libc_hidden_def(fork)
+# endif
+#endif
diff --git a/libc/sysdeps/linux/xtensa/jmpbuf-offsets.h b/libc/sysdeps/linux/xtensa/jmpbuf-offsets.h
new file mode 100644
index 000000000..4078dff55
--- /dev/null
+++ b/libc/sysdeps/linux/xtensa/jmpbuf-offsets.h
@@ -0,0 +1,20 @@
+/* Private macros for accessing __jmp_buf contents. Xtensa version.
+ Copyright (C) 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#define JB_SP 1
+#define JB_PC 16
diff --git a/libc/sysdeps/linux/xtensa/jmpbuf-unwind.h b/libc/sysdeps/linux/xtensa/jmpbuf-unwind.h
new file mode 100644
index 000000000..4516d9398
--- /dev/null
+++ b/libc/sysdeps/linux/xtensa/jmpbuf-unwind.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+#include <setjmp.h>
+#include <jmpbuf-offsets.h>
+
+/* Test if longjmp to JMPBUF would unwind the frame
+ containing a local variable at ADDRESS. */
+#define _JMPBUF_UNWINDS(jmpbuf, address) \
+ ((void *) (address) < (void *) (jmpbuf)[JB_SP])
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <stdint.h>
+#include <unwind.h>
+
+#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
+ _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
+
+#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
+ ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[JB_SP] - (_adj))
+#endif
diff --git a/libc/sysdeps/linux/xtensa/mmap.S b/libc/sysdeps/linux/xtensa/mmap.S
index c991e7d27..b4dd7c53b 100644
--- a/libc/sysdeps/linux/xtensa/mmap.S
+++ b/libc/sysdeps/linux/xtensa/mmap.S
@@ -12,9 +12,8 @@
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., 51 Franklin Street - Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include "sysdep.h"
#include <sys/syscall.h>
@@ -49,7 +48,7 @@ ENTRY (__mmap)
bltz a2, SYSCALL_ERROR_LABEL
.Lpseudo_end:
- retw
+ abi_ret
PSEUDO_END (__mmap)
diff --git a/libc/sysdeps/linux/xtensa/posix_fadvise.c b/libc/sysdeps/linux/xtensa/posix_fadvise.c
deleted file mode 100644
index 0fe13a1e9..000000000
--- a/libc/sysdeps/linux/xtensa/posix_fadvise.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * posix_fadvise() for Xtensa uClibc
- *
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- * Copyright (C) 2007 Tensilica Inc.
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-#include <sys/syscall.h>
-#include <fcntl.h>
-
-int posix_fadvise (int fd, off_t offset, off_t len, int advice)
-{
-#ifdef __NR_fadvise64_64
- INTERNAL_SYSCALL_DECL (err);
- int ret = INTERNAL_SYSCALL (fadvise64_64, err, 6, fd, advice,
- __LONG_LONG_PAIR ((long) (offset >> 31),
- (long) offset),
- __LONG_LONG_PAIR ((long) (len >> 31),
- (long) len));
- if (!INTERNAL_SYSCALL_ERROR_P (ret, err))
- return 0;
- return INTERNAL_SYSCALL_ERRNO (ret, err);
-#else
- return ENOSYS;
-#endif
-}
diff --git a/libc/sysdeps/linux/xtensa/posix_fadvise64.c b/libc/sysdeps/linux/xtensa/posix_fadvise64.c
deleted file mode 100644
index 1fdeeba79..000000000
--- a/libc/sysdeps/linux/xtensa/posix_fadvise64.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * posix_fadvise64() for Xtensa uClibc
- *
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- * Copyright (C) 2007 Tensilica Inc.
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-#include <features.h>
-#include <unistd.h>
-#include <errno.h>
-#include <endian.h>
-#include <stdint.h>
-#include <sys/types.h>
-#include <sys/syscall.h>
-#include <fcntl.h>
-
-#ifdef __UCLIBC_HAS_LFS__
-
-int posix_fadvise64 (int fd, __off64_t offset, __off64_t len, int advice)
-{
-#ifdef __NR_fadvise64_64
- INTERNAL_SYSCALL_DECL (err);
- int ret = INTERNAL_SYSCALL (fadvise64_64, err, 6, fd, advice,
- __LONG_LONG_PAIR ((long) (offset >> 32),
- (long) offset),
- __LONG_LONG_PAIR ((long) (len >> 32),
- (long) len));
- if (!INTERNAL_SYSCALL_ERROR_P (ret, err))
- return 0;
- return INTERNAL_SYSCALL_ERRNO (ret, err);
-#else
- return ENOSYS;
-#endif
-}
-
-#endif /* __UCLIBC_HAS_LFS__ */
diff --git a/libc/sysdeps/linux/xtensa/pread_write.c b/libc/sysdeps/linux/xtensa/pread_write.c
deleted file mode 100644
index 40d0f0324..000000000
--- a/libc/sysdeps/linux/xtensa/pread_write.c
+++ /dev/null
@@ -1,193 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-/*
- * 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...
- */
-
-#include <sys/syscall.h>
-#include <unistd.h>
-#include <stdint.h>
-#include <endian.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
-
-#include <bits/kernel_types.h>
-
-#ifdef __NR_pread
-
-# define __NR___syscall_pread __NR_pread
-/* On Xtensa, 64-bit values are aligned in even/odd register pairs. */
-static __inline__ _syscall6(ssize_t, __syscall_pread, int, fd, void *, buf,
- size_t, count, int, pad, 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, 0, __LONG_LONG_PAIR(offset >> 31, offset));
-}
-weak_alias(__libc_pread,pread)
-
-# ifdef __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, 0, __LONG_LONG_PAIR(high, low));
-}
-weak_alias(__libc_pread64,pread64)
-# endif /* __UCLIBC_HAS_LFS__ */
-
-#endif /* __NR_pread */
-
-#ifdef __NR_pwrite
-
-# define __NR___syscall_pwrite __NR_pwrite
-/* On Xtensa, 64-bit values are aligned in even/odd register pairs. */
-static __inline__ _syscall6(ssize_t, __syscall_pwrite, int, fd, const void *, buf,
- size_t, count, int, pad, 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, 0, __LONG_LONG_PAIR(offset >> 31, offset));
-}
-weak_alias(__libc_pwrite,pwrite)
-
-# ifdef __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, 0, __LONG_LONG_PAIR(high, low));
-}
-weak_alias(__libc_pwrite64,pwrite64)
-# endif /* __UCLIBC_HAS_LFS__ */
-#endif /* __NR_pwrite */
-
-#if ! defined __NR_pread || ! defined __NR_pwrite
-libc_hidden_proto(read)
-libc_hidden_proto(write)
-libc_hidden_proto(lseek)
-
-static ssize_t __fake_pread_write(int fd, void *buf,
- size_t count, off_t offset, int do_pwrite)
-{
- int save_errno;
- ssize_t result;
- off_t old_offset;
-
- /* Since we must not change the file pointer preserve the
- * value so that we can restore it later. */
- if ((old_offset=lseek(fd, 0, SEEK_CUR)) == (off_t) -1)
- return -1;
-
- /* Set to wanted position. */
- if (lseek(fd, offset, SEEK_SET) == (off_t) -1)
- return -1;
-
- if (do_pwrite == 1) {
- /* Write the data. */
- result = write(fd, buf, count);
- } else {
- /* Read the data. */
- result = read(fd, buf, count);
- }
-
- /* Now we have to restore the position. If this fails we
- * have to return this as an error. */
- save_errno = errno;
- if (lseek(fd, old_offset, SEEK_SET) == (off_t) -1)
- {
- if (result == -1)
- __set_errno(save_errno);
- return -1;
- }
- __set_errno(save_errno);
- return(result);
-}
-
-# ifdef __UCLIBC_HAS_LFS__
-libc_hidden_proto(lseek64)
-
-static ssize_t __fake_pread_write64(int fd, void *buf,
- size_t count, off64_t offset, int do_pwrite)
-{
- int save_errno;
- ssize_t result;
- off64_t old_offset;
-
- /* Since we must not change the file pointer preserve the
- * value so that we can restore it later. */
- if ((old_offset=lseek64(fd, 0, SEEK_CUR)) == (off64_t) -1)
- return -1;
-
- /* Set to wanted position. */
- if (lseek64(fd, offset, SEEK_SET) == (off64_t) -1)
- return -1;
-
- if (do_pwrite == 1) {
- /* Write the data. */
- result = write(fd, buf, count);
- } else {
- /* Read the data. */
- result = read(fd, buf, count);
- }
-
- /* Now we have to restore the position. */
- save_errno = errno;
- if (lseek64(fd, old_offset, SEEK_SET) == (off64_t) -1) {
- if (result == -1)
- __set_errno (save_errno);
- return -1;
- }
- __set_errno (save_errno);
- return result;
-}
-# endif /* __UCLIBC_HAS_LFS__ */
-#endif /* ! defined __NR_pread || ! defined __NR_pwrite */
-
-#ifndef __NR_pread
-ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset)
-{
- return __fake_pread_write(fd, buf, count, offset, 0);
-}
-weak_alias(__libc_pread,pread)
-
-# ifdef __UCLIBC_HAS_LFS__
-ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset)
-{
- return __fake_pread_write64(fd, buf, count, offset, 0);
-}
-weak_alias(__libc_pread64,pread64)
-# endif /* __UCLIBC_HAS_LFS__ */
-#endif /* ! __NR_pread */
-
-#ifndef __NR_pwrite
-ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset)
-{
- /* we won't actually be modifying the buffer,
- *just cast it to get rid of warnings */
- return __fake_pread_write(fd, (void*)buf, count, offset, 1);
-}
-weak_alias(__libc_pwrite,pwrite)
-
-# ifdef __UCLIBC_HAS_LFS__
-ssize_t __libc_pwrite64(int fd, const void *buf, size_t count, off64_t offset)
-{
- return __fake_pread_write64(fd, (void*)buf, count, offset, 1);
-}
-weak_alias(__libc_pwrite64,pwrite64)
-# endif /* __UCLIBC_HAS_LFS__ */
-#endif /* ! __NR_pwrite */
diff --git a/libc/sysdeps/linux/xtensa/setjmp.S b/libc/sysdeps/linux/xtensa/setjmp.S
index 5e81460c7..862bf6729 100644
--- a/libc/sysdeps/linux/xtensa/setjmp.S
+++ b/libc/sysdeps/linux/xtensa/setjmp.S
@@ -13,9 +13,8 @@
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., 51 Franklin Street - Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* This implementation relies heavily on the Xtensa register window
mechanism. Setjmp flushes all the windows except its own to the
@@ -25,24 +24,52 @@
then sets things up so that it will return to the right place,
using a window underflow to automatically restore the registers.
- Note that it would probably be sufficient to only copy the
- registers from setjmp's caller into jmp_buf. However, we also copy
- the save area located at the stack pointer of setjmp's caller.
- This save area will typically remain intact until the longjmp call.
- The one exception is when there is an intervening alloca in
- setjmp's caller. This is certainly an unusual situation and is
- likely to cause problems in any case (the storage allocated on the
- stack cannot be safely accessed following the longjmp). As bad as
- it is, on most systems this situation would not necessarily lead to
- a catastrophic failure. If we did not preserve the extra save area
- on Xtensa, however, it would. When setjmp's caller returns after a
- longjmp, there will be a window underflow; an invalid return
- address or stack pointer in the save area will almost certainly
- lead to a crash. Keeping a copy of the extra save area in the
- jmp_buf avoids this with only a small additional cost. If setjmp
- and longjmp are ever time-critical, this could be removed. */
+ Note that we also save the area located just below the stack pointer
+ of the caller. This save area could get overwritten by alloca
+ following the call to setjmp. The alloca moves the stack pointer
+ to allocate memory on the stack. This newly allocated memory
+ includes(!) the original save area (alloca copies the save area
+ before it moves that stack pointer).
+
+
+ previous caller SP -> |------------------------------| <-----+
+ | caller-2 registers a0-a3 | | p
+ |------------------------------| | o
+ | caller registers a4-a8/a12 | | i
+ |------------------------------| | n
+ | caller local stack | | t
+ caller SP -> |------------------------------| <-+ | s
+ | caller-1 registers a0-a3 | -:---+
+ callee (setjmp) SP -> |==============================| |
+ | caller registers a0-a3 | --+
+ |------------------------------|
+
+ In case of an alloca, registers a0-a3 of the previous caller (caller-1)
+ are copied (*), and the original location get likely overwritten.
+
+ previous caller SP -> |------------------------------| <-----+
+ | caller-2 registers a0-a3 | | p
+ |------------------------------| | o
+ | caller registers a4-a8/a12 | | i
+ |------------------------------| | n
+ | caller local stack | | t
+ caller SP before alloca-> |------------------------------| | s
+ | alloca area (overwrites old | |
+ | copy of caller-1 registers) | |
+ caller SP after alloca -> |------------------------------| <-+ |
+ | caller-1 registers a0-a3 (*) | -:---+
+ callee (setjmp) SP -> |==============================| |
+ | caller registers a0-a3 | --+
+ |------------------------------|
+
+ So, when longcall returns to the original caller SP, it also needs
+ to restore the save area below the SP.
+
+ */
#include "sysdep.h"
+
+/* NOTE: The ENTRY macro must allocate exactly 16 bytes (entry a1, 16) */
/* int setjmp (a2 = jmp_buf env) */
@@ -57,74 +84,85 @@ ENTRY (setjmp)
j 1f
END (setjmp)
-/* int __sigsetjmp (a2 = jmp_buf env,
- a3 = int savemask) */
+/* int __sigsetjmp (a2 = jmp_buf env, a3 = int savemask) */
ENTRY (__sigsetjmp)
-1:
+1:
+#if defined(__XTENSA_WINDOWED_ABI__)
/* Flush registers. */
movi a4, __window_spill
callx4 a4
- /* Preserve the second argument (savemask) in a15. The selection
- of a15 is arbitrary, except it's otherwise unused. There is no
- risk of triggering a window overflow since we just returned
- from __window_spill(). */
- mov a15, a3
-
- /* Copy the register save area at (sp - 16). */
- addi a5, a1, -16
- l32i a3, a5, 0
- l32i a4, a5, 4
- s32i a3, a2, 0
- s32i a4, a2, 4
- l32i a3, a5, 8
- l32i a4, a5, 12
- s32i a3, a2, 8
- s32i a4, a2, 12
-
- /* Copy 0-8 words from the register overflow area. */
- extui a3, a0, 30, 2
- blti a3, 2, .Lendsj
- l32i a7, a1, 4
- slli a4, a3, 4
- sub a5, a7, a4
- addi a6, a2, 16
- addi a7, a7, -16 // a7 = end of register overflow area
+ /* Copy the caller register a0-a3 at (sp - 16) to jmpbuf. */
+ addi a7, a1, -16
+ l32i a4, a7, 0
+ l32i a5, a7, 4
+ s32i a4, a2, 0
+ s32i a5, a2, 4
+ l32i a4, a7, 8
+ l32i a5, a7, 12
+ s32i a4, a2, 8
+ s32i a5, a2, 12
+
+ /* Copy the caller registers a4-a8/a12 from the overflow area. */
+ /* Note that entry moved the SP by 16B, so SP of caller-1 is at 4(sp) */
+ extui a7, a0, 30, 2
+ blti a7, 2, .Lendsj
+ l32i a8, a1, 4 /* a8: SP of 'caller-1' */
+ slli a4, a7, 4
+ sub a6, a8, a4
+ addi a5, a2, 16
+ addi a8, a8, -16 /* a8: end of register overflow area */
.Lsjloop:
- l32i a3, a5, 0
- l32i a4, a5, 4
- s32i a3, a6, 0
- s32i a4, a6, 4
- l32i a3, a5, 8
- l32i a4, a5, 12
- s32i a3, a6, 8
- s32i a4, a6, 12
- addi a5, a5, 16
+ l32i a7, a6, 0
+ l32i a4, a6, 4
+ s32i a7, a5, 0
+ s32i a4, a5, 4
+ l32i a7, a6, 8
+ l32i a4, a6, 12
+ s32i a7, a5, 8
+ s32i a4, a5, 12
+ addi a5, a6, 16
addi a6, a6, 16
- blt a5, a7, .Lsjloop
+ blt a6, a8, .Lsjloop
.Lendsj:
- /* Copy the register save area at sp. */
- l32i a3, a1, 0
- l32i a4, a1, 4
- s32i a3, a2, 48
- s32i a4, a2, 52
- l32i a3, a1, 8
- l32i a4, a1, 12
- s32i a3, a2, 56
- s32i a4, a2, 60
+ /* Copy previous caller registers (this is assuming 'entry a1,16') */
+ l32i a4, a1, 0
+ l32i a5, a1, 4
+ s32i a4, a2, 48
+ s32i a5, a2, 52
+ l32i a4, a1, 8
+ l32i a5, a1, 12
+ s32i a4, a2, 56
+ s32i a5, a2, 60
/* Save the return address, including the window size bits. */
s32i a0, a2, 64
- /* a2 still addresses jmp_buf. a15 contains savemask. */
+ /* a2 still points to jmp_buf. a3 contains savemask. */
mov a6, a2
- mov a7, a15
+ mov a7, a3
movi a3, __sigjmp_save
callx4 a3
mov a2, a6
retw
+#elif defined(__XTENSA_CALL0_ABI__)
+ s32i a0, a2, 0
+ s32i a1, a2, 4
+ s32i a12, a2, 8
+ s32i a13, a2, 12
+ s32i a14, a2, 16
+ s32i a15, a2, 20
+ mov a12, a2
+ movi a0, __sigjmp_save
+ callx0 a0
+ l32i a0, a12, 0
+ l32i a12, a12, 8
+ ret
+#else
+#error Unsupported Xtensa ABI
+#endif
END(__sigsetjmp)
weak_extern(_setjmp)
diff --git a/libc/sysdeps/linux/xtensa/sigaction.c b/libc/sysdeps/linux/xtensa/sigaction.c
index 790a8f21f..2a20c6859 100644
--- a/libc/sysdeps/linux/xtensa/sigaction.c
+++ b/libc/sysdeps/linux/xtensa/sigaction.c
@@ -15,45 +15,30 @@
#define SA_RESTORER 0x04000000
-extern void __default_sa_restorer (void);
+extern void __default_sa_restorer(void);
-/* Experimentally off - libc_hidden_proto(memcpy) */
-
-int __libc_sigaction (int signum, const struct sigaction *act,
- struct sigaction *oldact)
+int __libc_sigaction(int sig, const struct sigaction *act,
+ struct sigaction *oact)
{
- struct kernel_sigaction kact, koldact;
- int result;
-
- 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;
-
- if (kact.sa_flags & SA_RESTORER) {
- kact.sa_restorer = act->sa_restorer;
- } else {
- kact.sa_restorer = __default_sa_restorer;
- kact.sa_flags |= SA_RESTORER;
- }
- }
-
- result = __syscall_rt_sigaction(signum, act ? __ptrvalue (&kact) : NULL,
- oldact ? __ptrvalue (&koldact) : NULL,
- _NSIG / 8);
+ struct sigaction kact;
- if (oldact && result >= 0) {
- oldact->sa_handler = koldact.k_sa_handler;
- memcpy(&oldact->sa_mask, &koldact.sa_mask, sizeof(oldact->sa_mask));
- oldact->sa_flags = koldact.sa_flags;
- oldact->sa_restorer = koldact.sa_restorer;
+ if (act && !(act->sa_flags & SA_RESTORER)) {
+ memcpy(&kact, act, sizeof(kact));
+ kact.sa_restorer = __default_sa_restorer;
+ kact.sa_flags |= SA_RESTORER;
+ act = &kact;
}
-
- return result;
+ /* NB: kernel (as of 2.6.25) will return EINVAL
+ * if sizeof(act->sa_mask) does not match kernel's sizeof(sigset_t) */
+ return __syscall_rt_sigaction(sig, act, oact, sizeof(act->sa_mask));
}
#ifndef LIBC_SIGACTION
-libc_hidden_proto (sigaction)
-weak_alias (__libc_sigaction, sigaction)
-libc_hidden_weak (sigaction)
+# ifndef __UCLIBC_HAS_THREADS__
+strong_alias(__libc_sigaction,sigaction)
+libc_hidden_def(sigaction)
+# else
+weak_alias(__libc_sigaction,sigaction)
+libc_hidden_weak(sigaction)
+# endif
#endif
diff --git a/libc/sysdeps/linux/xtensa/sigrestorer.S b/libc/sysdeps/linux/xtensa/sigrestorer.S
index 474a89319..697f54e1d 100644
--- a/libc/sysdeps/linux/xtensa/sigrestorer.S
+++ b/libc/sysdeps/linux/xtensa/sigrestorer.S
@@ -11,6 +11,12 @@
#endif
.text
+ /* This space separates __default_sa_restorer from the previous
+ * function, so that its corresponding FDE is not mistakenly found
+ * by the libgcc stack unwinder. This is important for correct signal
+ * stack unwinding.
+ */
+ .space 1
.align 4
.global __default_sa_restorer
.type __default_sa_restorer, @function
diff --git a/libc/sysdeps/linux/xtensa/sys/procfs.h b/libc/sysdeps/linux/xtensa/sys/procfs.h
index f6f8752bc..484460449 100644
--- a/libc/sysdeps/linux/xtensa/sys/procfs.h
+++ b/libc/sysdeps/linux/xtensa/sys/procfs.h
@@ -12,9 +12,8 @@
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., 51 Franklin Street - Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_PROCFS_H
#define _SYS_PROCFS_H 1
diff --git a/libc/sysdeps/linux/xtensa/sys/ucontext.h b/libc/sysdeps/linux/xtensa/sys/ucontext.h
index 4c37201ea..da75d988f 100644
--- a/libc/sysdeps/linux/xtensa/sys/ucontext.h
+++ b/libc/sysdeps/linux/xtensa/sys/ucontext.h
@@ -12,9 +12,8 @@
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., 51 Franklin Street - Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _SYS_UCONTEXT_H
#define _SYS_UCONTEXT_H 1
diff --git a/libc/sysdeps/linux/xtensa/sys/user.h b/libc/sysdeps/linux/xtensa/sys/user.h
new file mode 100644
index 000000000..f97f93edb
--- /dev/null
+++ b/libc/sysdeps/linux/xtensa/sys/user.h
@@ -0,0 +1,20 @@
+/*
+ * include/asm-xtensa/user.h
+ *
+ * Xtensa Processor version.
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2001 - 2005 Tensilica Inc.
+ */
+
+#ifndef _XTENSA_USER_H
+#define _XTENSA_USER_H
+
+/* This file usually defines a 'struct user' structure. However, it it only
+ * used for a.out file, which are not supported on Xtensa.
+ */
+
+#endif /* _XTENSA_USER_H */
diff --git a/libc/sysdeps/linux/xtensa/syscall.S b/libc/sysdeps/linux/xtensa/syscall.S
index 955e889cf..790a8d018 100644
--- a/libc/sysdeps/linux/xtensa/syscall.S
+++ b/libc/sysdeps/linux/xtensa/syscall.S
@@ -12,9 +12,8 @@
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., 51 Franklin Street - Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include "sysdep.h"
@@ -27,7 +26,7 @@
*/
ENTRY (syscall)
- l32i a9, a1, 16 /* load extra argument from stack */
+ l32i a9, a1, FRAMESIZE/* load extra argument from stack */
mov a8, a7
mov a7, a3 /* preserve a3 in a7 */
mov a3, a4
@@ -38,5 +37,5 @@ ENTRY (syscall)
movi a4, -4095
bgeu a2, a4, SYSCALL_ERROR_LABEL
.Lpseudo_end:
- retw
+ abi_ret
PSEUDO_END (syscall)
diff --git a/libc/sysdeps/linux/xtensa/sysdep.h b/libc/sysdeps/linux/xtensa/sysdep.h
index 5708a8114..f5a40eb3a 100644
--- a/libc/sysdeps/linux/xtensa/sysdep.h
+++ b/libc/sysdeps/linux/xtensa/sysdep.h
@@ -13,9 +13,14 @@
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., 51 Franklin Street - Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _LINUX_XTENSA_SYSDEP_H
+#define _LINUX_XTENSA_SYSDEP_H 1
+
+#include <common/sysdep.h>
+#include <sys/syscall.h>
#ifdef __ASSEMBLER__
@@ -23,29 +28,53 @@
#define ASM_TYPE_DIRECTIVE(name, typearg) .type name, typearg
#define ASM_SIZE_DIRECTIVE(name) .size name, . - name
-#ifdef __STDC__
-#define C_LABEL(name) name :
+#if defined(__XTENSA_WINDOWED_ABI__)
+#define abi_entry(reg, frame_size) entry reg, frame_size
+#define abi_ret retw
+#elif defined(__XTENSA_CALL0_ABI__)
+#define abi_entry(reg, frame_size)
+#define abi_ret ret
#else
-#define C_LABEL(name) name/**/:
+#error Unsupported Xtensa ABI
#endif
+
#define ENTRY(name) \
- ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
+ .globl C_SYMBOL_NAME(name); \
ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name), @function); \
.align ALIGNARG(2); \
LITERAL_POSITION; \
C_LABEL(name) \
- entry sp, FRAMESIZE; \
+ abi_entry(sp, FRAMESIZE); \
+ CALL_MCOUNT
+
+#define HIDDEN_ENTRY(name) \
+ .globl C_SYMBOL_NAME(name); \
+ .hidden C_SYMBOL_NAME(name); \
+ ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name), @function); \
+ .align ALIGNARG(2); \
+ LITERAL_POSITION; \
+ C_LABEL(name) \
+ abi_entry(sp, FRAMESIZE); \
CALL_MCOUNT
#undef END
#define END(name) ASM_SIZE_DIRECTIVE(name)
+/* Local label name for asm code. */
+#ifndef L
+# ifdef HAVE_ELF
+# define L(name) .L##name
+# else
+# define L(name) name
+# endif
+#endif
+
/* Define a macro for this directive so it can be removed in a few places. */
#define LITERAL_POSITION .literal_position
#undef JUMPTARGET
-#ifdef PIC
+#ifdef __PIC__
/* The "@PLT" suffix is currently a no-op for non-shared linking, but
it doesn't hurt to use it conditionally for PIC code in case that
changes someday. */
@@ -54,7 +83,15 @@
#define JUMPTARGET(name) name
#endif
+#ifndef FRAMESIZE
+#if defined(__XTENSA_WINDOWED_ABI__)
#define FRAMESIZE 16
+#elif defined(__XTENSA_CALL0_ABI__)
+#define FRAMESIZE 0
+#else
+#error Unsupported Xtensa ABI
+#endif
+#endif
#define CALL_MCOUNT /* Do nothing. */
@@ -98,7 +135,7 @@
END (name)
#undef ret_NOERRNO
-#define ret_NOERRNO retw
+#define ret_NOERRNO abi_ret
/* The function has to return the error code. */
#undef PSEUDO_ERRVAL
@@ -112,19 +149,11 @@
#define PSEUDO_END_ERRVAL(name) \
END (name)
-#define ret_ERRVAL retw
-
-#if RTLD_PRIVATE_ERRNO
-# define SYSCALL_ERROR_HANDLER \
-0: movi a4, rtld_errno; \
- neg a2, a2; \
- s32i a2, a4, 0; \
- movi a2, -1; \
- j .Lpseudo_end;
+#undef ret_ERRVAL
+#define ret_ERRVAL abi_ret
-#elif defined _LIBC_REENTRANT
-
-# if USE___THREAD
+#if defined _LIBC_REENTRANT
+# if defined USE___THREAD
# ifndef NOT_IN_libc
# define SYSCALL_ERROR_ERRNO __libc_errno
# else
@@ -139,6 +168,8 @@
movi a2, -1; \
j .Lpseudo_end;
# else /* !USE___THREAD */
+
+#if defined(__XTENSA_WINDOWED_ABI__)
# define SYSCALL_ERROR_HANDLER \
0: neg a2, a2; \
mov a6, a2; \
@@ -147,6 +178,24 @@
s32i a2, a6, 0; \
movi a2, -1; \
j .Lpseudo_end;
+#elif defined(__XTENSA_CALL0_ABI__)
+# define SYSCALL_ERROR_HANDLER \
+0: neg a2, a2; \
+ addi a1, a1, -16; \
+ s32i a0, a1, 0; \
+ s32i a2, a1, 4; \
+ movi a0, __errno_location@PLT; \
+ callx0 a0; \
+ l32i a0, a1, 0; \
+ l32i a3, a1, 4; \
+ addi a1, a1, 16; \
+ s32i a3, a2, 0; \
+ movi a2, -1; \
+ j .Lpseudo_end;
+#else
+#error Unsupported Xtensa ABI
+#endif
+
# endif /* !USE___THREAD */
#else /* !_LIBC_REENTRANT */
#define SYSCALL_ERROR_HANDLER \
@@ -158,3 +207,9 @@
#endif /* _LIBC_REENTRANT */
#endif /* __ASSEMBLER__ */
+
+/* Pointer mangling is not yet supported for Xtensa. */
+#define PTR_MANGLE(var) (void) (var)
+#define PTR_DEMANGLE(var) (void) (var)
+
+#endif /* _LINUX_XTENSA_SYSDEP_H */
diff --git a/libc/sysdeps/linux/xtensa/vfork.S b/libc/sysdeps/linux/xtensa/vfork.S
index 830a0cd4d..8058fb057 100644
--- a/libc/sysdeps/linux/xtensa/vfork.S
+++ b/libc/sysdeps/linux/xtensa/vfork.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2005-2013 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
@@ -12,80 +12,78 @@
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., 51 Franklin Street - Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include "sysdep.h"
#include <sys/syscall.h>
#define _SIGNAL_H
#include <bits/signum.h>
+#define __ASSEMBLY__
+#include <linux/sched.h>
-/* Clone the calling process, but without copying the whole address space.
+/*
+ Clone the calling process, but without copying the whole address space.
The calling process is suspended until the new process exits or is
replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
and the process ID of the new process to the old process.
Note that it is important that we don't create a new stack frame for the
- caller. */
+ caller.
-
-/* The following are defined in linux/sched.h, which unfortunately
- is not safe for inclusion in an assembly file. */
-#define CLONE_VM 0x00000100 /* set if VM shared between processes */
-#define CLONE_VFORK 0x00004000 /* set if the parent wants the child to
- wake it up on mm_release */
+*/
#ifndef SAVE_PID
-#define SAVE_PID
+#define SAVE_PID(a,b,c,d)
#endif
-
#ifndef RESTORE_PID
-#define RESTORE_PID
+#define RESTORE_PID(a,b,c)
+#endif
+#ifndef RESTORE_PID12
+#define RESTORE_PID12(a,b,c)
#endif
+/*
+ pid_t vfork(void);
+ Implemented as __clone_syscall(CLONE_VFORK | CLONE_VM | SIGCHLD, 0)
+ */
-/* pid_t vfork(void);
- Implemented as __clone_syscall(CLONE_VFORK | CLONE_VM | SIGCHLD, 0) */
-ENTRY (__vfork)
+HIDDEN_ENTRY (__vfork)
- movi a6, .Ljumptable
- extui a2, a0, 30, 2 // call-size: call4/8/12 = 1/2/3
- addx4 a4, a2, a6 // find return address in jumptable
- l32i a4, a4, 0
- add a4, a4, a6
+#if defined(__XTENSA_WINDOWED_ABI__)
+ .literal .Ljumptable, 0, .L4, .L8, .L12
+ mov a3, a0 # move return address out of the way
+ movi a0, .Ljumptable
+ extui a2, a3, 30, 2 # call-size: call4/8/12 = 1/2/3
+ addx4 a0, a2, a0 # find return address in jumptable
+ l32i a0, a0, 0
+ # exchange top 2 bits of a0 and a3:
+ xor a2, a0, a3
+ extui a2, a2, 30, 2
slli a2, a2, 30
- xor a3, a0, a2 // remove call-size from return address
- extui a5, a4, 30, 2 // get high bits of jump target
- slli a5, a5, 30
- or a3, a3, a5 // stuff them into the return address
- xor a4, a4, a5 // clear high bits of jump target
- or a0, a4, a2 // create temporary return address
- retw // "return" to .L4, .L8, or .L12
-
- .align 4
-.Ljumptable:
- .word 0
- .word .L4 - .Ljumptable
- .word .L8 - .Ljumptable
- .word .L12 - .Ljumptable
+ xor a0, a0, a2
+ xor a3, a3, a2
+ retw
/* a7: return address */
+
.L4: mov a12, a2
mov a13, a3
- SAVE_PID
+ SAVE_PID(a5,a15,a2,a3)
- /* Use syscall 'clone'. Set new stack pointer to the same address. */
- movi a2, SYS_ify (clone)
- movi a3, 0
+ /* use syscall 'clone' and set new stack pointer to the same address */
+
+ movi a2, SYS_ify(clone)
+ movi a3, 0
movi a6, CLONE_VM | CLONE_VFORK | SIGCHLD
+
syscall
- RESTORE_PID
+ RESTORE_PID(a5,a15,a2)
movi a5, -4096
@@ -95,22 +93,24 @@ ENTRY (__vfork)
bgeu a6, a5, 1f
jx a7
-1: call4 .Lerr // returns to original caller
+1: call4 .Lerr
/* a11: return address */
+
.L8: mov a12, a2
mov a13, a3
mov a14, a6
- SAVE_PID
+ SAVE_PID(a9,a15,a2,a3)
- movi a2, SYS_ify (clone)
+ movi a2, SYS_ify(clone)
movi a3, 0
movi a6, CLONE_VM | CLONE_VFORK | SIGCHLD
+
syscall
- RESTORE_PID
+ RESTORE_PID(a9,a15,a2)
movi a9, -4096
@@ -121,22 +121,25 @@ ENTRY (__vfork)
bgeu a10, a9, 1f
jx a11
-1: call8 .Lerr // returns to original caller
+
+1: call8 .Lerr
/* a15: return address */
+
.L12: mov a12, a2
mov a13, a3
mov a14, a6
- SAVE_PID
+ SAVE_PID (a2,a3,a2,a6)
- movi a2, SYS_ify (clone)
+ movi a2, SYS_ify(clone)
movi a3, 0
movi a6, CLONE_VM | CLONE_VFORK | SIGCHLD
+
syscall
- RESTORE_PID
+ RESTORE_PID12(a3,a6,a15)
mov a3, a13
movi a13, -4096
@@ -148,23 +151,43 @@ ENTRY (__vfork)
bgeu a14, a13, 1f
jx a15
-1: call12 .Lerr // returns to original caller
+1: call12 .Lerr
.align 4
+
.Lerr: entry a1, 16
- /* Restore the return address. */
- extui a4, a0, 30, 2 // get the call-size bits
+ /* Restore return address */
+
+ extui a4, a0, 30, 2
slli a4, a4, 30
- slli a3, a3, 2 // clear high bits of target address
- srli a3, a3, 2
- or a0, a3, a4 // combine them
+ or a0, a3, a4
PSEUDO_END (__vfork)
.Lpseudo_end:
retw
+#elif defined(__XTENSA_CALL0_ABI__)
+ SAVE_PID(a5, a8, a3, a4)
+
+ /* Use syscall 'clone'. Set new stack pointer to the same address. */
+ movi a2, SYS_ify (clone)
+ movi a3, 0
+ movi a6, CLONE_VM | CLONE_VFORK | SIGCHLD
+ syscall
+
+ RESTORE_PID(a5, a8, a2)
-libc_hidden_def (__vfork)
+ movi a3, -4096
+ bgeu a2, a3, 1f
+ ret
+1:
+ PSEUDO_END (__vfork)
+.Lpseudo_end:
+ ret
+#else
+#error Unsupported Xtensa ABI
+#endif
weak_alias (__vfork, vfork)
+libc_hidden_def(vfork)
diff --git a/libc/sysdeps/linux/xtensa/windowspill.S b/libc/sysdeps/linux/xtensa/windowspill.S
index a63771756..013025648 100644
--- a/libc/sysdeps/linux/xtensa/windowspill.S
+++ b/libc/sysdeps/linux/xtensa/windowspill.S
@@ -13,12 +13,12 @@
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., 51 Franklin Street - Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <bits/xtensa-config.h>
+#ifdef __XTENSA_WINDOWED_ABI__
.text
.align 4
.literal_position
@@ -26,8 +26,8 @@
.type __window_spill, @function
__window_spill:
entry a1, 48
- bbci.l a0, 31, .L4 // branch if called with call4
- bbsi.l a0, 30, .L12 // branch if called with call12
+ bbci.l a0, 31, .L4 /* branch if called with call4 */
+ bbsi.l a0, 30, .L12 /* branch if called with call12 */
/* Called with call8: touch register NUM_REGS-12 (4/20/52) */
.L8:
@@ -36,18 +36,18 @@ __window_spill:
retw
.align 4
-1: _entry a1, 48 // touch NUM_REGS-24 (x/8/40)
+1: _entry a1, 48 /* touch NUM_REGS-24 (x/8/40) */
#if XCHAL_NUM_AREGS == 32
mov a8, a0
retw
#else
mov a12, a0
- _entry a1, 48 // touch NUM_REGS-36 (x/x/28)
+ _entry a1, 48 /* touch NUM_REGS-36 (x/x/28) */
mov a12, a0
- _entry a1, 48 // touch NUM_REGS-48 (x/x/16)
+ _entry a1, 48 /* touch NUM_REGS-48 (x/x/16) */
mov a12, a0
- _entry a1, 16 // touch NUM_REGS-60 (x/x/4)
+ _entry a1, 16 /* touch NUM_REGS-60 (x/x/4) */
#endif
#endif
mov a4, a0
@@ -62,14 +62,14 @@ __window_spill:
retw
.align 4
-1: _entry a1, 48 // touch NUM_REGS-20 (x/12/44)
+1: _entry a1, 48 /* touch NUM_REGS-20 (x/12/44) */
mov a12, a0
#if XCHAL_NUM_AREGS > 32
- _entry a1, 48 // touch NUM_REGS-32 (x/x/32)
+ _entry a1, 48 /* touch NUM_REGS-32 (x/x/32) */
mov a12, a0
- _entry a1, 48 // touch NUM_REGS-44 (x/x/20)
+ _entry a1, 48 /* touch NUM_REGS-44 (x/x/20) */
mov a12, a0
- _entry a1, 48 // touch NUM_REGS-56 (x/x/8)
+ _entry a1, 48 /* touch NUM_REGS-56 (x/x/8) */
mov a8, a0
#endif
#endif
@@ -82,15 +82,17 @@ __window_spill:
retw
.align 4
-1: _entry a1, 48 // touch NUM_REGS-28 (x/4/36)
+1: _entry a1, 48 /* touch NUM_REGS-28 (x/4/36) */
#if XCHAL_NUM_AREGS == 32
mov a4, a0
#else
mov a12, a0
- _entry a1, 48 // touch NUM_REGS-40 (x/x/24)
+ _entry a1, 48 /* touch NUM_REGS-40 (x/x/24) */
mov a12, a0
- _entry a1, 48 // touch NUM_REGS-52 (x/x/12)
+ _entry a1, 48 /* touch NUM_REGS-52 (x/x/12) */
mov a12, a0
#endif
#endif
retw
+
+#endif